MythTV
master
|
#include <mythmediamonitor.h>
Public Slots | |
void | mediaStatusChanged (MythMediaStatus oldStatus, MythMediaDevice *pMedia) const |
Slot which is called when the device status changes and posts a media event to the mainwindow. More... | |
Public Member Functions | |
virtual void | deleteLater (void) |
bool | IsActive (void) const |
virtual void | StartMonitoring (void) |
Start the monitoring thread if needed. More... | |
void | StopMonitoring (void) |
Stop the monitoring thread if needed. More... | |
void | ChooseAndEjectMedia (void) |
Unmounts and ejects removable media devices. More... | |
void | EjectMedia (const QString &path) |
bool | ValidateAndLock (MythMediaDevice *pMedia) |
Validates the MythMediaDevice and increments its reference count. More... | |
void | Unlock (MythMediaDevice *pMedia) |
decrements the MythMediaDevices reference count More... | |
QList< MythMediaDevice * > | GetRemovable (bool showMounted=false, bool showUsable=false) |
Generate a list of removable drives. More... | |
QList< MythMediaDevice * > | GetMedias (unsigned mediatypes) |
Ask for available media. Must be locked with ValidateAndLock(). More... | |
MythMediaDevice * | GetMedia (const QString &path) |
Get media device by pathname. Must be locked with ValidateAndLock(). More... | |
void | RegisterMediaHandler (const QString &destination, const QString &description, void(*callback)(MythMediaDevice *), int mediaType, const QString &extensions) |
Register a handler for media related events. More... | |
void | JumpToMediaHandler (MythMediaDevice *pMedia) |
Find a relevant jump point for this type of media. More... | |
virtual QStringList | GetCDROMBlockDevices (void)=0 |
Static Public Member Functions | |
static MediaMonitor * | GetMediaMonitor (void) |
static QString | GetMountPath (const QString &devPath) |
If the device is being monitored, return its mountpoint. More... | |
static void | SetCDSpeed (const char *device, int speed) |
static QString | defaultCDdevice () |
CDDevice, user-selected drive, or /dev/cdrom. More... | |
static QString | defaultVCDdevice () |
VCDDeviceLocation, user-selected drive, or /dev/cdrom. More... | |
static QString | defaultDVDdevice () |
DVDDeviceLocation, user-selected drive, or /dev/dvd. More... | |
static QString | defaultCDWriter () |
CDWriterDeviceLocation, user-selected drive, or /dev/cdrom. More... | |
static QString | defaultDVDWriter () |
MythArchiveDVDLocation, user-selected drive, or /dev/dvd. More... | |
static void | ejectOpticalDisc (void) |
Eject a disk, unmount a drive, open a tray. More... | |
Protected Member Functions | |
MediaMonitor (QObject *par, unsigned long interval, bool allowEject) | |
Lookup some settings, and do OS-specific stuff in sub-classes. More... | |
~MediaMonitor () override=default | |
void | CheckDevices (void) |
Poll the devices in our list. More... | |
virtual void | CheckDeviceNotifications (void) |
virtual bool | AddDevice (MythMediaDevice *pDevice)=0 |
bool | RemoveDevice (const QString &dev) |
Remove a device from the media monitor. More... | |
bool | shouldIgnore (const MythMediaDevice *device) |
Check user preferences to see if this device should be monitored. More... | |
bool | eventFilter (QObject *obj, QEvent *event) override |
Installed into the main window's event chain, so that the main thread can safely jump to plugin code. More... | |
QString | listDevices (void) |
A string summarising the current devices, for debugging. More... | |
MythMediaDevice * | selectDrivePopup (const QString &label, bool showMounted=false, bool showUsable=false) |
List removable drives, let the user select one. More... | |
Static Protected Member Functions | |
static void | AttemptEject (MythMediaDevice *device) |
static QString | defaultDevice (const QString &setting, const QString &label, const char *hardCodedDefault) |
Protected Attributes | |
QRecursiveMutex | m_devicesLock |
QList< MythMediaDevice * > | m_devices |
QList< MythMediaDevice * > | m_removedDevices |
QMap< MythMediaDevice *, int > | m_useCount |
QStringList | m_ignoreList |
bool volatile | m_active {false} |
Was MonitorThread started? More... | |
QWaitCondition | m_wait |
MonitorThread * | m_thread {nullptr} |
unsigned long | m_monitorPollingInterval |
bool | m_allowEject |
QMap< QString, MHData > | m_handlerMap |
Registered Media Handlers. More... | |
Static Protected Attributes | |
static MediaMonitor * | s_monitor = nullptr |
Friends | |
class | MonitorThread |
class | MonitorThreadDarwin |
Definition at line 49 of file mythmediamonitor.h.
|
protected |
Lookup some settings, and do OS-specific stuff in sub-classes.
Definition at line 333 of file mythmediamonitor.cpp.
|
overrideprotecteddefault |
|
virtual |
Reimplemented in MediaMonitorUnix.
Definition at line 371 of file mythmediamonitor.cpp.
Referenced by MediaMonitorUnix::deleteLater(), and main().
|
inline |
Definition at line 57 of file mythmediamonitor.h.
Referenced by Ripper::Ripper().
|
virtual |
Start the monitoring thread if needed.
Reimplemented in MediaMonitorDarwin.
Definition at line 446 of file mythmediamonitor.cpp.
Referenced by main(), and Ripper::~Ripper().
void MediaMonitor::StopMonitoring | ( | void | ) |
Stop the monitoring thread if needed.
Definition at line 469 of file mythmediamonitor.cpp.
Referenced by deleteLater(), and Ripper::Ripper().
void MediaMonitor::ChooseAndEjectMedia | ( | void | ) |
Unmounts and ejects removable media devices.
If no media devices are known to the MediaMonitor this function does nothing. If a single device is known, it is unmounted and ejected if possible. If multiple devices are known, a popup box is display so the user can choose which device to eject.
Definition at line 246 of file mythmediamonitor.cpp.
Referenced by ejectOpticalDisc().
void MediaMonitor::EjectMedia | ( | const QString & | path | ) |
Definition at line 265 of file mythmediamonitor.cpp.
Referenced by Device::Close().
|
static |
Definition at line 75 of file mythmediamonitor.cpp.
Referenced by Device::Close(), defaultDevice(), ImageManagerFe::DetectLocalDevices(), ImageManagerFe::DeviceEvent(), Ripper::ejectCD(), ejectOpticalDisc(), main(), REG_MEDIA_HANDLER(), Ripper::Ripper(), SetCDSpeed(), and Ripper::~Ripper().
|
static |
If the device is being monitored, return its mountpoint.
A convenience function for plugins. (Only currently needed for Mac OS X, which mounts Audio CDs)
Definition at line 556 of file mythmediamonitor.cpp.
|
static |
Definition at line 91 of file mythmediamonitor.cpp.
Referenced by MythDVDBuffer::SetDVDSpeed().
bool MediaMonitor::ValidateAndLock | ( | MythMediaDevice * | pMedia | ) |
Validates the MythMediaDevice and increments its reference count.
Returns true if pMedia device is valid, otherwise returns false. If this function returns false the caller should gracefully recover.
NOTE: This function can block.
Definition at line 492 of file mythmediamonitor.cpp.
Referenced by defaultDevice(), ImageManagerFe::DetectLocalDevices(), ImageManagerFe::DeviceEvent(), Ripper::ejectCD(), GetMountPath(), and SetCDSpeed().
void MediaMonitor::Unlock | ( | MythMediaDevice * | pMedia | ) |
decrements the MythMediaDevices reference count
Definition at line 509 of file mythmediamonitor.cpp.
Referenced by Device::Close(), defaultDevice(), ImageManagerFe::DetectLocalDevices(), ImageManagerFe::DeviceEvent(), Ripper::ejectCD(), GetMountPath(), and SetCDSpeed().
QList< MythMediaDevice * > MediaMonitor::GetRemovable | ( | bool | showMounted = false , |
bool | showUsable = false |
||
) |
Generate a list of removable drives.
Has to iterate through all devices to check if any are suitable.
Definition at line 145 of file mythmediamonitor.cpp.
Referenced by selectDrivePopup().
QList< MythMediaDevice * > MediaMonitor::GetMedias | ( | unsigned | mediatypes | ) |
Ask for available media. Must be locked with ValidateAndLock().
This method returns a list of MythMediaDevice pointers which match the given mediatype.
It is potentially unsafe to use the pointers returned by this function. The devices may be removed and their associated MythMediaDevice objects destroyed. It is the responsibility of the caller to ensure that the pointers are validated and the reference count is incremented by calling MediaMonitor::ValidateAndLock() before the the returned pointer is dereferenced and MediaMonitor::Unlock() when done.
Definition at line 603 of file mythmediamonitor.cpp.
Referenced by ImageManagerFe::DetectLocalDevices().
MythMediaDevice * MediaMonitor::GetMedia | ( | const QString & | path | ) |
Get media device by pathname. Must be locked with ValidateAndLock().
Definition at line 532 of file mythmediamonitor.cpp.
Referenced by Ripper::ejectCD(), EjectMedia(), GetMountPath(), and SetCDSpeed().
void MediaMonitor::RegisterMediaHandler | ( | const QString & | destination, |
const QString & | description, | ||
void(*)(MythMediaDevice *) | callback, | ||
int | mediaType, | ||
const QString & | extensions | ||
) |
Register a handler for media related events.
This method registers a callback function for when media related events occur. The call must specify the type of media supported by the handler, and (if needed) a list of media file extensions that are supported.
destination | A name for this callback function. For example: "MythDVD DVD Media Handler". This argument must be unique as it is also used as the key for creating the map of handler. |
description | Unused. |
callback | The function to call when an event occurs. |
mediaType | The type of media supported by this callback. The value must be an enum of type MythMediaType. |
extensions | A list of file name extensions supported by this callback. |
Definition at line 642 of file mythmediamonitor.cpp.
Referenced by REG_MEDIA_HANDLER().
void MediaMonitor::JumpToMediaHandler | ( | MythMediaDevice * | pMedia | ) |
Find a relevant jump point for this type of media.
If there's more than one we should show a popup to allow the user to select which one to use, but for now, we're going to just use the first one.
Definition at line 680 of file mythmediamonitor.cpp.
Referenced by eventFilter().
|
static |
CDDevice, user-selected drive, or /dev/cdrom.
Definition at line 890 of file mythmediamonitor.cpp.
|
static |
VCDDeviceLocation, user-selected drive, or /dev/cdrom.
Definition at line 898 of file mythmediamonitor.cpp.
|
static |
DVDDeviceLocation, user-selected drive, or /dev/dvd.
Definition at line 907 of file mythmediamonitor.cpp.
Referenced by playDisc().
|
static |
CDWriterDeviceLocation, user-selected drive, or /dev/cdrom.
Definition at line 916 of file mythmediamonitor.cpp.
|
static |
MythArchiveDVDLocation, user-selected drive, or /dev/dvd.
This should also look for drives with blanks or RWs in them, but Nigel hasn't worked out how to do this tidily (yet).
Definition at line 928 of file mythmediamonitor.cpp.
|
static |
Eject a disk, unmount a drive, open a tray.
If the Media Monitor is enabled, we use its fully-featured routine. Otherwise, we guess a drive and use a primitive OS-specific command
Definition at line 971 of file mythmediamonitor.cpp.
Referenced by eject_cb().
|
pure virtual |
Implemented in MediaMonitorUnix, MediaMonitorDarwin, and MediaMonitorWindows.
|
slot |
Slot which is called when the device status changes and posts a media event to the mainwindow.
Definition at line 715 of file mythmediamonitor.cpp.
Referenced by MediaMonitorWindows::AddDevice(), MediaMonitorDarwin::AddDevice(), and MediaMonitorUnix::AddDevice().
|
staticprotected |
Definition at line 273 of file mythmediamonitor.cpp.
Referenced by ChooseAndEjectMedia(), and EjectMedia().
|
protected |
Poll the devices in our list.
Definition at line 426 of file mythmediamonitor.cpp.
|
inlineprotectedvirtual |
Reimplemented in MediaMonitorUnix.
Definition at line 106 of file mythmediamonitor.h.
Referenced by CheckDevices().
|
protectedpure virtual |
Implemented in MediaMonitorUnix, MediaMonitorDarwin, and MediaMonitorWindows.
|
protected |
Remove a device from the media monitor.
This function is usually called after a hotpluggable device is unplugged.
dev | path to device special file to remove. |
Definition at line 390 of file mythmediamonitor.cpp.
Referenced by MediaMonitorUnix::CheckDeviceNotifications().
|
protected |
Check user preferences to see if this device should be monitored.
Definition at line 762 of file mythmediamonitor.cpp.
Referenced by MediaMonitorDarwin::AddDevice(), and MediaMonitorUnix::AddDevice().
|
overrideprotected |
Installed into the main window's event chain, so that the main thread can safely jump to plugin code.
Definition at line 790 of file mythmediamonitor.cpp.
|
protected |
A string summarising the current devices, for debugging.
Definition at line 940 of file mythmediamonitor.cpp.
Referenced by MediaMonitorUnix::MediaMonitorUnix(), and MediaMonitorWindows::MediaMonitorWindows().
|
staticprotected |
Definition at line 846 of file mythmediamonitor.cpp.
Referenced by defaultCDdevice(), defaultCDWriter(), defaultDVDdevice(), defaultDVDWriter(), and defaultVCDdevice().
|
protected |
List removable drives, let the user select one.
prevent drawing a list if there is only one drive, et cetera
Definition at line 173 of file mythmediamonitor.cpp.
Referenced by ChooseAndEjectMedia(), and defaultDevice().
|
friend |
Definition at line 52 of file mythmediamonitor.h.
Referenced by StartMonitoring().
|
friend |
Definition at line 53 of file mythmediamonitor.h.
Referenced by MediaMonitorDarwin::StartMonitoring().
|
protected |
Definition at line 125 of file mythmediamonitor.h.
Referenced by MediaMonitorWindows::AddDevice(), MediaMonitorUnix::AddDevice(), CheckDevices(), GetMedia(), GetMedias(), GetRemovable(), RemoveDevice(), Unlock(), and ValidateAndLock().
|
protected |
Definition at line 127 of file mythmediamonitor.h.
Referenced by MediaMonitorWindows::AddDevice(), MediaMonitorDarwin::AddDevice(), MediaMonitorUnix::AddDevice(), CheckDevices(), MediaMonitorUnix::CheckFileSystemTable(), GetMedia(), GetMedias(), GetRemovable(), listDevices(), RemoveDevice(), MediaMonitorDarwin::StartMonitoring(), and ValidateAndLock().
|
protected |
Definition at line 128 of file mythmediamonitor.h.
Referenced by RemoveDevice(), and Unlock().
|
protected |
Definition at line 129 of file mythmediamonitor.h.
Referenced by MediaMonitorWindows::AddDevice(), MediaMonitorDarwin::AddDevice(), MediaMonitorUnix::AddDevice(), RemoveDevice(), Unlock(), and ValidateAndLock().
|
protected |
Definition at line 132 of file mythmediamonitor.h.
Referenced by MediaMonitor(), and shouldIgnore().
Was MonitorThread started?
Definition at line 134 of file mythmediamonitor.h.
Referenced by mediaStatusChanged(), MediaMonitorDarwin::StartMonitoring(), StartMonitoring(), and StopMonitoring().
|
protected |
Definition at line 135 of file mythmediamonitor.h.
Referenced by StopMonitoring().
|
protected |
Definition at line 136 of file mythmediamonitor.h.
Referenced by deleteLater(), MediaMonitorDarwin::StartMonitoring(), StartMonitoring(), and StopMonitoring().
|
protected |
Definition at line 137 of file mythmediamonitor.h.
Referenced by MediaMonitorDarwin::StartMonitoring(), and StartMonitoring().
|
protected |
Definition at line 138 of file mythmediamonitor.h.
Referenced by MediaMonitorUnix::AddDevice(), MediaMonitorUnix::CheckMountable(), and MediaMonitorUnix::FindPartitions().
|
protected |
Registered Media Handlers.
Definition at line 140 of file mythmediamonitor.h.
Referenced by eventFilter(), JumpToMediaHandler(), and RegisterMediaHandler().
|
staticprotected |
Definition at line 142 of file mythmediamonitor.h.
Referenced by defaultDevice(), GetMediaMonitor(), and GetMountPath().