MediaMonitor Class Reference

#include <mythmediamonitor.h>

Inheritance diagram for MediaMonitor:
MediaMonitorDarwin MediaMonitorUnix MediaMonitorWindows

List of all members.

Public Slots

void mediaStatusChanged (MythMediaStatus oldStatus, MythMediaDevice *pMedia)
 Slot which is called when the device status changes and posts a media event to the mainwindow.

Public Member Functions

virtual void deleteLater (void)
bool IsActive (void) const
virtual void StartMonitoring (void)
 Start the monitoring thread if needed.
void StopMonitoring (void)
 Stop the monitoring thread if needed.
void ChooseAndEjectMedia (void)
 Unmounts and ejects removable media devices.
bool ValidateAndLock (MythMediaDevice *pMedia)
 Validates the MythMediaDevice and increments its reference count.
void Unlock (MythMediaDevice *pMedia)
 decrements the MythMediaDevices reference count
QList< MythMediaDevice * > GetRemovable (bool mounted=false)
 Generate a list of removable drives.
QList< MythMediaDevice * > GetMedias (MythMediaType mediatype)
 Ask for available media.
MythMediaDeviceGetMedia (const QString &path)
 Get media device by pathname.
void MonitorRegisterExtensions (uint mediaType, const QString &extensions)
 Register the extension list on all known devices.
void RegisterMediaHandler (const QString &destination, const QString &description, const QString &key, void(*callback)(MythMediaDevice *), int mediaType, const QString &extensions)
void JumpToMediaHandler (MythMediaDevice *pMedia)
 Find a relevant jump point for this type of media.
virtual QStringList GetCDROMBlockDevices (void)=0

Static Public Member Functions

static MediaMonitorGetMediaMonitor (void)
static QString GetMountPath (const QString &devPath)
 If the device is being monitored, return its mountpoint.
static void SetCDSpeed (const char *device, int speed)
static QString defaultCDdevice ()
 CDDevice, user-selected drive, or /dev/cdrom.
static QString defaultVCDdevice ()
 VCDDeviceLocation, user-selected drive, or /dev/cdrom.
static QString defaultDVDdevice ()
 DVDDeviceLocation, user-selected drive, or /dev/dvd.
static QString defaultCDWriter ()
 CDWriterDeviceLocation, user-selected drive, or /dev/cdrom.
static QString defaultDVDWriter ()
 MythArchiveDVDLocation, user-selected drive, or /dev/dvd.
static void ejectOpticalDisc (void)
 Eject a disk, unmount a drive, open a tray.

Protected Member Functions

 MediaMonitor (QObject *par, unsigned long interval, bool allowEject)
 Lookup some settings, and do OS-specific stuff in sub-classes.
virtual ~MediaMonitor ()
void AttemptEject (MythMediaDevice *device)
void CheckDevices (void)
 Poll the devices in our list.
virtual void CheckDeviceNotifications (void)
virtual bool AddDevice (MythMediaDevice *pDevice)=0
bool RemoveDevice (const QString &dev)
 Remove a device from the media monitor.
bool shouldIgnore (const MythMediaDevice *device)
 Check user preferences to see if this device should be monitored.
bool eventFilter (QObject *obj, QEvent *event)
 Installed into the main window's event chain, so that the main thread can safely jump to plugin code.
const QString listDevices (void)
 A string summarising the current devices, for debugging.
MythMediaDeviceselectDrivePopup (const QString label, bool mounted=false)
 List removable drives, let the user select one.

Static Protected Member Functions

static QString defaultDevice (const QString setting, const QString label, const char *hardCodedDefault)

Protected Attributes

QMutex m_DevicesLock
QList< MythMediaDevice * > m_Devices
QList< MythMediaDevice * > m_RemovedDevices
QMap< MythMediaDevice *, int > m_UseCount
QStringList m_IgnoreList
bool m_Active
 Was MonitorThread started?
bool m_SendEvent
 Send MediaEvent to plugins?
bool m_StartThread
 Should we actually monitor?
MonitorThreadm_Thread
unsigned long m_MonitorPollingInterval
bool m_AllowEject
QMap< QString, MHDatam_handlerMap
 Registered Media Handlers.

Static Protected Attributes

static MediaMonitorc_monitor = NULL

Friends

class MonitorThread
class MonitorThreadDarwin

Detailed Description

Definition at line 36 of file mythmediamonitor.h.


Constructor & Destructor Documentation

MediaMonitor::MediaMonitor ( QObject *  par,
unsigned long  interval,
bool  allowEject 
) [protected]

Lookup some settings, and do OS-specific stuff in sub-classes.

Bug:
If the user changes the MonitorDrives or IgnoreDevices settings, it will have no effect until the frontend is restarted.

Definition at line 294 of file mythmediamonitor.cpp.

virtual MediaMonitor::~MediaMonitor (  )  [inline, protected, virtual]

Definition at line 89 of file mythmediamonitor.h.


Member Function Documentation

void MediaMonitor::deleteLater ( void   )  [virtual]

Reimplemented in MediaMonitorUnix.

Definition at line 345 of file mythmediamonitor.cpp.

Referenced by main().

bool MediaMonitor::IsActive ( void   )  const [inline]

Definition at line 44 of file mythmediamonitor.h.

Referenced by Ripper::Ripper().

void MediaMonitor::StartMonitoring ( void   )  [virtual]

Start the monitoring thread if needed.

Reimplemented in MediaMonitorDarwin.

Definition at line 416 of file mythmediamonitor.cpp.

Referenced by main(), and Ripper::~Ripper().

void MediaMonitor::StopMonitoring ( void   ) 

Stop the monitoring thread if needed.

Definition at line 438 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 216 of file mythmediamonitor.cpp.

Referenced by ejectOpticalDisc().

MediaMonitor * MediaMonitor::GetMediaMonitor ( void   )  [static]
QString MediaMonitor::GetMountPath ( const QString &  devPath  )  [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 524 of file mythmediamonitor.cpp.

Referenced by chooseCD().

void MediaMonitor::SetCDSpeed ( const char *  device,
int  speed 
) [static]

Definition at line 81 of file mythmediamonitor.cpp.

Referenced by DVDRingBuffer::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.

See also:
Unlock(MythMediaDevice *pMedia), GetMedias(MythMediaType mediatype)

Definition at line 459 of file mythmediamonitor.cpp.

Referenced by defaultDevice(), Ripper::ejectCD(), GetMountPath(), and SetCDSpeed().

void MediaMonitor::Unlock ( MythMediaDevice pMedia  ) 

decrements the MythMediaDevices reference count

See also:
ValidateAndLock(MythMediaDevice *pMedia), GetMedias(MythMediaType mediatype)

Definition at line 476 of file mythmediamonitor.cpp.

Referenced by defaultDevice(), Ripper::ejectCD(), GetMountPath(), and SetCDSpeed().

QList< MythMediaDevice * > MediaMonitor::GetRemovable ( bool  showMounted = false  ) 

Generate a list of removable drives.

Has to iterate through all devices to check if any are suitable.

Definition at line 135 of file mythmediamonitor.cpp.

Referenced by selectDrivePopup().

QList< MythMediaDevice * > MediaMonitor::GetMedias ( MythMediaType  mediatype  ) 

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.

See also:
ValidateAndLock(MythMediaDevice *pMedia)
Unlock(MythMediaDevice *pMedia)

Definition at line 571 of file mythmediamonitor.cpp.

MythMediaDevice * MediaMonitor::GetMedia ( const QString &  path  ) 

Get media device by pathname.

Must be locked with ValidateAndLock().

See also:
ValidateAndLock(MythMediaDevice *pMedia)
Unlock(MythMediaDevice *pMedia)

Definition at line 499 of file mythmediamonitor.cpp.

Referenced by Ripper::ejectCD(), GetMountPath(), and SetCDSpeed().

void MediaMonitor::MonitorRegisterExtensions ( uint  mediaType,
const QString &  extensions 
)

Register the extension list on all known devices.

Definition at line 595 of file mythmediamonitor.cpp.

Referenced by RegisterMediaHandler().

void MediaMonitor::RegisterMediaHandler ( const QString &  destination,
const QString &  description,
const QString &  key,
void(*)(MythMediaDevice *)  callback,
int  mediaType,
const QString &  extensions 
)

Definition at line 610 of file mythmediamonitor.cpp.

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 649 of file mythmediamonitor.cpp.

Referenced by eventFilter().

QString MediaMonitor::defaultCDdevice (  )  [static]

CDDevice, user-selected drive, or /dev/cdrom.

Definition at line 846 of file mythmediamonitor.cpp.

Referenced by chooseCD().

QString MediaMonitor::defaultVCDdevice (  )  [static]

VCDDeviceLocation, user-selected drive, or /dev/cdrom.

Definition at line 854 of file mythmediamonitor.cpp.

QString MediaMonitor::defaultDVDdevice (  )  [static]

DVDDeviceLocation, user-selected drive, or /dev/dvd.

Definition at line 863 of file mythmediamonitor.cpp.

Referenced by playDisc().

QString MediaMonitor::defaultCDWriter (  )  [static]

CDWriterDeviceLocation, user-selected drive, or /dev/cdrom.

Definition at line 872 of file mythmediamonitor.cpp.

Referenced by Playlist::CreateCDMP3().

QString MediaMonitor::defaultDVDWriter (  )  [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 884 of file mythmediamonitor.cpp.

void MediaMonitor::ejectOpticalDisc ( void   )  [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 928 of file mythmediamonitor.cpp.

Referenced by eject_cb().

virtual QStringList MediaMonitor::GetCDROMBlockDevices ( void   )  [pure virtual]
void MediaMonitor::mediaStatusChanged ( MythMediaStatus  oldStatus,
MythMediaDevice pMedia 
) [slot]

Slot which is called when the device status changes and posts a media event to the mainwindow.

Definition at line 684 of file mythmediamonitor.cpp.

Referenced by MediaMonitorWindows::AddDevice(), MediaMonitorUnix::AddDevice(), and MediaMonitorDarwin::AddDevice().

void MediaMonitor::AttemptEject ( MythMediaDevice device  )  [protected]

Definition at line 237 of file mythmediamonitor.cpp.

Referenced by ChooseAndEjectMedia().

void MediaMonitor::CheckDevices ( void   )  [protected]

Poll the devices in our list.

Definition at line 397 of file mythmediamonitor.cpp.

virtual void MediaMonitor::CheckDeviceNotifications ( void   )  [inline, protected, virtual]

Reimplemented in MediaMonitorUnix.

Definition at line 93 of file mythmediamonitor.h.

Referenced by CheckDevices().

virtual bool MediaMonitor::AddDevice ( MythMediaDevice pDevice  )  [protected, pure virtual]
bool MediaMonitor::RemoveDevice ( const QString &  dev  )  [protected]

Remove a device from the media monitor.

This function is usually called after a hotpluggable device is unplugged.

Parameters:
dev path to device special file to remove.
Returns:
true if device is removed from the Media Monitor.

Definition at line 364 of file mythmediamonitor.cpp.

Referenced by MediaMonitorUnix::CheckDeviceNotifications(), and MediaMonitorUnix::deviceRemoved().

bool MediaMonitor::shouldIgnore ( const MythMediaDevice device  )  [protected]

Check user preferences to see if this device should be monitored.

Definition at line 729 of file mythmediamonitor.cpp.

Referenced by MediaMonitorUnix::AddDevice(), and MediaMonitorDarwin::AddDevice().

bool MediaMonitor::eventFilter ( QObject *  obj,
QEvent *  event 
) [protected]

Installed into the main window's event chain, so that the main thread can safely jump to plugin code.

Definition at line 757 of file mythmediamonitor.cpp.

const QString MediaMonitor::listDevices ( void   )  [protected]

A string summarising the current devices, for debugging.

Definition at line 896 of file mythmediamonitor.cpp.

Referenced by MediaMonitorUnix::MediaMonitorUnix(), and MediaMonitorWindows::MediaMonitorWindows().

QString MediaMonitor::defaultDevice ( const QString  setting,
const QString  label,
const char *  hardCodedDefault 
) [static, protected]
MythMediaDevice * MediaMonitor::selectDrivePopup ( const QString  label,
bool  showMounted = false 
) [protected]

List removable drives, let the user select one.

prevent drawing a list if there is only one drive, et cetera

Definition at line 159 of file mythmediamonitor.cpp.

Referenced by ChooseAndEjectMedia(), and defaultDevice().


Friends And Related Function Documentation

friend class MonitorThread [friend]

Definition at line 39 of file mythmediamonitor.h.

Referenced by StartMonitoring().

friend class MonitorThreadDarwin [friend]

Definition at line 40 of file mythmediamonitor.h.

Referenced by MediaMonitorDarwin::StartMonitoring().


Member Data Documentation

QMutex MediaMonitor::m_DevicesLock [protected]

Definition at line 109 of file mythmediamonitor.h.

Referenced by RemoveDevice(), and Unlock().

QMap<MythMediaDevice*, int> MediaMonitor::m_UseCount [protected]
QStringList MediaMonitor::m_IgnoreList [protected]

Definition at line 113 of file mythmediamonitor.h.

Referenced by MediaMonitor(), and shouldIgnore().

Send MediaEvent to plugins?

Definition at line 116 of file mythmediamonitor.h.

Referenced by MediaMonitorDarwin::AddDevice().

Should we actually monitor?

Definition at line 117 of file mythmediamonitor.h.

Referenced by MediaMonitor(), selectDrivePopup(), StartMonitoring(), and MediaMonitorDarwin::StartMonitoring().

unsigned long MediaMonitor::m_MonitorPollingInterval [protected]

Definition at line 120 of file mythmediamonitor.h.

Referenced by StartMonitoring(), and MediaMonitorDarwin::StartMonitoring().

QMap<QString, MHData> MediaMonitor::m_handlerMap [protected]

Registered Media Handlers.

Definition at line 123 of file mythmediamonitor.h.

Referenced by eventFilter(), JumpToMediaHandler(), and RegisterMediaHandler().

MediaMonitor * MediaMonitor::c_monitor = NULL [static, protected]

Definition at line 125 of file mythmediamonitor.h.

Referenced by defaultDevice(), GetMediaMonitor(), and GetMountPath().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Mon May 28 06:42:09 2012 for MythTV by  doxygen 1.6.3