MythTV  master
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
MythCDROMLinux Class Reference

Use Linux-specific ioctl()s to detect Audio-CDs, changed media, open trays and blank writable media. More...

Inheritance diagram for MythCDROMLinux:
Inheritance graph
[legend]
Collaboration diagram for MythCDROMLinux:
Collaboration graph
[legend]

Public Member Functions

 MythCDROMLinux (QObject *par, const char *DevicePath, bool SuperMount, bool AllowEject)
 
MythMediaError testMedia (void) override
 
bool mediaChanged (void) override
 
bool checkOK (void) override
 
MythMediaStatus checkMedia (void) override
 
MythMediaError eject (bool open_close=true) override
 
void setDeviceSpeed (const char *device, int speed) override
 
bool isSameDevice (const QString &path) override
 
MythMediaError lock (void) override
 
MythMediaError unlock (void) override
 
- Public Member Functions inherited from MythCDROM
virtual ~MythCDROM ()=default
 
MythMediaStatus checkMedia (void) override
 
void setDeviceSpeed (const char *devicePath, int speed) override
 
- Public Member Functions inherited from MythMediaDevice
 MythMediaDevice (QObject *par, const char *DevicePath, bool SuperMount, bool AllowEject)
 
const QString & getMountPath () const
 
void setMountPath (const char *path)
 
const QString & getDevicePath () const
 
const QString & getRealDevice () const
 
const QString & getDeviceModel () const
 
void setDeviceModel (const char *model)
 
MythMediaStatus getStatus () const
 
const QString & getVolumeID () const
 
void setVolumeID (const char *vol)
 
const QString & getKeyID () const
 
bool getAllowEject () const
 
bool getLocked () const
 
bool isDeviceOpen () const
 
bool isUsable () const
 Is this device "ready", for a plugin to access? More...
 
MythMediaType getMediaType () const
 
bool isSuperMount () const
 
virtual bool openDevice ()
 
virtual bool closeDevice ()
 
virtual void setSpeed (int speed)
 
virtual bool performMountCmd (bool DoMount)
 
bool mount ()
 
bool unmount ()
 
bool isMounted (bool bVerify=true)
 Tells us if m_DevicePath is a mounted device. More...
 
bool findMountPath ()
 Try to find a mount of m_DevicePath in the mounts file. More...
 
void clearData ()
 
QString MediaTypeString ()
 

Protected Member Functions

MythMediaError ejectCDROM (bool open_close)
 
MythMediaError ejectSCSI ()
 
- Protected Member Functions inherited from MythCDROM
 MythCDROM (QObject *par, const char *DevicePath, bool SuperMount, bool AllowEject)
 
void onDeviceMounted () override
 Override this to perform any post mount logic. More...
 
- Protected Member Functions inherited from MythMediaDevice
virtual ~MythMediaDevice ()=default
 
virtual void onDeviceUnmounted ()
 Override this to perform any post unmount logic. More...
 
MythMediaType DetectMediaType (void)
 Returns guessed media type based on file extensions. More...
 
bool ScanMediaType (const QString &directory, ext_cnt_t &counts)
 Recursively scan directories and create an associative array with the number of times we've seen each extension. More...
 
MythMediaStatus setStatus (MythMediaStatus newStat, bool CloseIt=false)
 

Private Member Functions

int driveStatus (void)
 Exhaustively determine the status. More...
 
bool hasWritableMedia (void)
 Is there blank or eraseable media in the drive? More...
 
int SCSIstatus (void)
 Use a SCSI query packet to see if the drive is really open. More...
 

Additional Inherited Members

- Public Types inherited from MythCDROM
enum  ImageType { kUnknown, kBluray, kDVD }
 
- Signals inherited from MythMediaDevice
void statusChanged (MythMediaStatus oldStatus, MythMediaDevice *pMedia)
 
- Static Public Member Functions inherited from MythCDROM
static MythCDROMget (QObject *par, const char *devicePath, bool SuperMount, bool AllowEject)
 
static ImageType inspectImage (const QString &path)
 
- Static Public Member Functions inherited from MythMediaDevice
static void RegisterMediaExtensions (uint mediatype, const QString &extensions)
 Used to register media types with extensions. More...
 
static QString MediaTypeString (uint type)
 
- Static Public Attributes inherited from MythMediaDevice
static const char * MediaStatusStrings []
 
static const char * MediaErrorStrings []
 
- Protected Attributes inherited from MythMediaDevice
QString m_DeviceModel
 The device Manufacturer/Model. Read/write. More...
 
QString m_DevicePath
 The path to this media's device. More...
 
QString m_KeyID
 KeyID of the media. More...
 
QString m_MountPath
 The path to this media's mount point. More...
 
QString m_RealDevice
 If m_DevicePath is a symlink, its target. More...
 
QString m_VolumeID
 The volume ID of the media. Read/write. More...
 
MythMediaStatus m_Status
 The status of the media as of the. More...
 
MythMediaType m_MediaType
 last call to checkMedia. Read only More...
 
bool m_AllowEject
 Allow the user to eject the media?. Read only. More...
 
bool m_Locked
 Is this media locked?. Read only. More...
 
bool m_SuperMount
 Is this a supermount device?. More...
 
int m_DeviceHandle
 A file handle for opening and closing the device, ioctls(), et c. More...
 

Detailed Description

Use Linux-specific ioctl()s to detect Audio-CDs, changed media, open trays and blank writable media.

Definition at line 126 of file mythcdrom-linux.cpp.

Constructor & Destructor Documentation

◆ MythCDROMLinux()

MythCDROMLinux::MythCDROMLinux ( QObject *  par,
const char *  DevicePath,
bool  SuperMount,
bool  AllowEject 
)
inline

Definition at line 129 of file mythcdrom-linux.cpp.

Member Function Documentation

◆ testMedia()

MythMediaError MythCDROMLinux::testMedia ( void  )
overridevirtual

Reimplemented from MythMediaDevice.

Definition at line 426 of file mythcdrom-linux.cpp.

◆ mediaChanged()

bool MythCDROMLinux::mediaChanged ( void  )
overridevirtual

Reimplemented from MythCDROM.

Definition at line 414 of file mythcdrom-linux.cpp.

Referenced by checkMedia().

◆ checkOK()

bool MythCDROMLinux::checkOK ( void  )
overridevirtual

Reimplemented from MythCDROM.

Definition at line 419 of file mythcdrom-linux.cpp.

◆ checkMedia()

MythMediaStatus MythCDROMLinux::checkMedia ( void  )
overridevirtual

Implements MythMediaDevice.

Definition at line 463 of file mythcdrom-linux.cpp.

◆ eject()

MythMediaError MythCDROMLinux::eject ( bool  open_close = true)
overridevirtual

Reimplemented from MythMediaDevice.

Definition at line 291 of file mythcdrom-linux.cpp.

◆ setDeviceSpeed()

void MythCDROMLinux::setDeviceSpeed ( const char *  device,
int  speed 
)
overridevirtual

Reimplemented from MythMediaDevice.

◆ isSameDevice()

bool MythCDROMLinux::isSameDevice ( const QString &  path)
overridevirtual

Reimplemented from MythMediaDevice.

Definition at line 741 of file mythcdrom-linux.cpp.

◆ lock()

MythMediaError MythCDROMLinux::lock ( void  )
overridevirtual

Reimplemented from MythMediaDevice.

Definition at line 707 of file mythcdrom-linux.cpp.

Referenced by checkMedia().

◆ unlock()

MythMediaError MythCDROMLinux::unlock ( void  )
overridevirtual

Reimplemented from MythMediaDevice.

Definition at line 722 of file mythcdrom-linux.cpp.

Referenced by checkMedia().

◆ ejectCDROM()

MythMediaError MythCDROMLinux::ejectCDROM ( bool  open_close)
protected

Definition at line 306 of file mythcdrom-linux.cpp.

Referenced by eject().

◆ ejectSCSI()

MythMediaError MythCDROMLinux::ejectSCSI ( )
protected

Definition at line 337 of file mythcdrom-linux.cpp.

Referenced by eject().

◆ driveStatus()

int MythCDROMLinux::driveStatus ( void  )
private

Exhaustively determine the status.

If the CDROM is managed by the SCSI driver, then CDROM_DRIVE_STATUS as reported by ioctl will always return CDS_TRAY_OPEN if the tray is closed with no media. To determine the actual drive status we need to ask the drive directly by sending a SCSI packet to the drive.

Definition at line 169 of file mythcdrom-linux.cpp.

Referenced by checkMedia(), ejectCDROM(), and testMedia().

◆ hasWritableMedia()

bool MythCDROMLinux::hasWritableMedia ( void  )
private

Is there blank or eraseable media in the drive?

Definition at line 188 of file mythcdrom-linux.cpp.

Referenced by checkMedia().

◆ SCSIstatus()

int MythCDROMLinux::SCSIstatus ( void  )
private

Use a SCSI query packet to see if the drive is really open.

Note that in recent kernels, whether you have an IDE/ATA/SATA or SCSI CDROM, the drive is managed by the SCSI driver and therefore needs this workaround. This code is based on the routine cdrom_get_media_event in cdrom.c of the linux kernel

Definition at line 241 of file mythcdrom-linux.cpp.

Referenced by driveStatus().


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