MediaMonitor Class Reference

#include <mythmediamonitor.h>

Inheritance diagram for MediaMonitor:

MediaMonitorDarwin MediaMonitorUnix MediaMonitorWindows

List of all members.


Detailed Description

Definition at line 41 of file mythmediamonitor.h.


Public Slots

void mediaStatusChanged (MediaStatus oldStatus, MythMediaDevice *pMedia)

Public Member Functions

 ~MediaMonitor ()
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
QValueList< MythMediaDevice * > GetMedias (MediaType 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.
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.

Protected Member Functions

 MediaMonitor (QObject *par, unsigned long interval, bool allowEject)
 Lookup some settings, and do OS-specific stuff in sub-classes.
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 (MythMediaDevice *device)
 Check user preferences to see if this device should be monitored.
const QString listDevices (void)
 A string summarising the current devices, for debugging.
MythMediaDeviceselectDrivePopup (const QString label, bool mounted=false)
 Popup a dialog box for the user to select one drive.

Static Protected Member Functions

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

Protected Attributes

QMutex m_DevicesLock
QValueList< MythMediaDevice * > m_Devices
QValueList< 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

Static Protected Attributes

static MediaMonitorc_monitor = NULL

Friends

class MonitorThread
class MonitorThreadDarwin

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

MediaMonitor::~MediaMonitor (  ) 

Definition at line 318 of file mythmediamonitor.cpp.


Member Function Documentation

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

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

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

void MediaMonitor::StopMonitoring ( void   ) 

Stop the monitoring thread if needed.

Definition at line 403 of file mythmediamonitor.cpp.

Referenced by main(), 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 190 of file mythmediamonitor.cpp.

Referenced by myth_eject().

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

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

Definition at line 75 of file mythmediamonitor.cpp.

Referenced by CdDecoder::setCDSpeed(), and DVDRingBufferPriv::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(MediaType mediatype)

Definition at line 424 of file mythmediamonitor.cpp.

Referenced by VideoListImp::buildFsysList(), MythMainWindow::customEvent(), Ripper::ejectCD(), GetMountPath(), IconView::HandleMediaDeviceSelect(), IconView::HandleMediaEscape(), IconView::HandleShowDevices(), SetCDSpeed(), and IconView::SetupMediaMonitor().

void MediaMonitor::Unlock ( MythMediaDevice pMedia  ) 

QValueList< MythMediaDevice * > MediaMonitor::GetMedias ( MediaType  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 524 of file mythmediamonitor.cpp.

Referenced by VideoListImp::buildFsysList(), IconView::HandleMediaEscape(), and IconView::HandleShowDevices().

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

QString MediaMonitor::defaultCDdevice (  )  [static]

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

Definition at line 682 of file mythmediamonitor.cpp.

Referenced by chooseCD().

QString MediaMonitor::defaultVCDdevice (  )  [static]

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

Definition at line 690 of file mythmediamonitor.cpp.

Referenced by playVCD().

QString MediaMonitor::defaultDVDdevice (  )  [static]

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

Definition at line 699 of file mythmediamonitor.cpp.

Referenced by DVDRipBox::DVDRipBox(), playDVD(), startDVDRipper(), and TitleDialog::viewTitle().

QString MediaMonitor::defaultCDWriter (  )  [static]

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

Definition at line 708 of file mythmediamonitor.cpp.

Referenced by DatabaseBox::BlankCDRW(), and 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 720 of file mythmediamonitor.cpp.

virtual QStringList MediaMonitor::GetCDROMBlockDevices ( void   )  [pure virtual]

void MediaMonitor::mediaStatusChanged ( MediaStatus  oldStatus,
MythMediaDevice pMedia 
) [slot]

void MediaMonitor::CheckDevices ( void   )  [protected]

Poll the devices in our list.

Reimplemented in MediaMonitorUnix.

Definition at line 364 of file mythmediamonitor.cpp.

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

Reimplemented in MediaMonitorUnix.

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

Referenced by MediaMonitorUnix::CheckDeviceNotifications().

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

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

Definition at line 604 of file mythmediamonitor.cpp.

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

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

A string summarising the current devices, for debugging.

Definition at line 732 of file mythmediamonitor.cpp.

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

QString MediaMonitor::defaultDevice ( const QString  setting,
const QString  label,
char *  hardCodedDefault 
) [static, protected]

MythMediaDevice * MediaMonitor::selectDrivePopup ( const QString  label,
bool  showMounted = false 
) [protected]

Popup a dialog box for the user to select one drive.

Has to iterate through all devices to check if any are suitable, prevent drawing a list if there is only one drive, et cetera

Definition at line 128 of file mythmediamonitor.cpp.

Referenced by ChooseAndEjectMedia(), and defaultDevice().


Friends And Related Function Documentation

friend class MonitorThread [friend]

Definition at line 44 of file mythmediamonitor.h.

Referenced by StartMonitoring().

friend class MonitorThreadDarwin [friend]

Definition at line 45 of file mythmediamonitor.h.

Referenced by MediaMonitorDarwin::StartMonitoring().


Member Data Documentation

QMutex MediaMonitor::m_DevicesLock [protected]

QValueList<MythMediaDevice*> MediaMonitor::m_Devices [protected]

Definition at line 102 of file mythmediamonitor.h.

Referenced by RemoveDevice(), and Unlock().

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

QStringList MediaMonitor::m_IgnoreList [protected]

Definition at line 106 of file mythmediamonitor.h.

Referenced by MediaMonitor(), and shouldIgnore().

Send MediaEvent to plugins?

Definition at line 109 of file mythmediamonitor.h.

Referenced by MediaMonitorDarwin::AddDevice(), MediaMonitor(), and mediaStatusChanged().

Should we actually monitor?

Definition at line 110 of file mythmediamonitor.h.

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

unsigned long MediaMonitor::m_MonitorPollingInterval [protected]

Definition at line 113 of file mythmediamonitor.h.

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

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

Definition at line 116 of file mythmediamonitor.h.

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


The documentation for this class was generated from the following files:

Generated on Sat Sep 4 05:16:04 2010 for MythTV by  doxygen 1.5.5