本文整理汇总了C++中MythMediaDevice类的典型用法代码示例。如果您正苦于以下问题:C++ MythMediaDevice类的具体用法?C++ MythMediaDevice怎么用?C++ MythMediaDevice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MythMediaDevice类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOG
/**
* \brief Deal with the user, or another program, renaming a volume
*
* iTunes has a habit of renaming the disk volumes and track files
* after it looks up a disk on the GraceNote CDDB.
*/
void MonitorThreadDarwin::diskRename(const char *devName, const char *volName)
{
LOG(VB_MEDIA, LOG_DEBUG,
QString("MonitorThreadDarwin::diskRename(%1,%2)")
.arg(devName).arg(volName));
MythMediaDevice *pDevice = m_Monitor->GetMedia(devName);
if (m_Monitor->ValidateAndLock(pDevice))
{
// Send message to plugins to ignore this drive:
if (m_Monitor->m_SendEvent)
pDevice->setStatus(MEDIASTAT_NODISK);
pDevice->setVolumeID(volName);
pDevice->setMountPath((QString("/Volumes/") + volName).toLatin1());
// Plugins can now use it again:
if (m_Monitor->m_SendEvent)
pDevice->setStatus(MEDIASTAT_USEABLE);
m_Monitor->Unlock(pDevice);
}
else
LOG(VB_MEDIA, LOG_INFO,
QString("Couldn't find MythMediaDevice: %1").arg(devName));
}
示例2: LOG
void Ripper::ejectCD()
{
LOG(VB_MEDIA, LOG_INFO, __PRETTY_FUNCTION__);
bool bEjectCD = gCoreContext->GetNumSetting("EjectCDAfterRipping",1);
if (bEjectCD)
{
#ifdef HAVE_CDIO
LOG(VB_MEDIA, LOG_INFO, QString("Ripper::%1 '%2'").
arg(__func__).arg(m_CDdevice));
(void)cdio_eject_media_drive(m_CDdevice.toLatin1().constData());
#else
MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
if (mon)
{
QByteArray devname = m_CDdevice.toLatin1();
MythMediaDevice *pMedia = mon->GetMedia(devname.constData());
if (pMedia && mon->ValidateAndLock(pMedia))
{
pMedia->eject();
mon->Unlock(pMedia);
}
}
#endif // HAVE_CDIO
}
}
示例3: mediaEvent
/**
* \copydoc MythUIType::mediaEvent()
*/
void MythThemedMenu::mediaEvent(MythMediaEvent* event)
{
if (!event)
return;
MythMediaDevice *device = event->getDevice();
if (!device)
return;
MythMediaType type = device->getMediaType();
MythMediaStatus status = device->getStatus();
if ((status & ~MEDIASTAT_USEABLE) &&
(status & ~MEDIASTAT_MOUNTED))
return;
switch (type)
{
case MEDIATYPE_DVD :
// DVD Available
break;
case MEDIATYPE_BD :
// Blu-ray Available
break;
default :
return;
}
}
示例4: GetMediaMonitor
void MediaMonitor::SetCDSpeed(const char *device, int speed)
{
MediaMonitor *mon = GetMediaMonitor();
if (mon)
{
MythMediaDevice *pMedia = mon->GetMedia(device);
if (pMedia && mon->ValidateAndLock(pMedia))
{
pMedia->setSpeed(speed);
mon->Unlock(pMedia);
return;
}
}
MythCDROM *cd = MythCDROM::get(NULL, device, false, false);
if (cd)
{
cd->setDeviceSpeed(device, speed);
delete cd;
return;
}
LOG(VB_MEDIA, LOG_INFO,
QString("MediaMonitor::setSpeed(%1) - Cannot find/create CDROM?")
.arg(device));
}
示例5: GetMountPath
/**
* 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)
*/
QString MediaMonitor::GetMountPath(const QString& devPath)
{
QString mountPath;
if (c_monitor)
{
MythMediaDevice *pMedia = c_monitor->GetMedia(devPath);
if (pMedia && c_monitor->ValidateAndLock(pMedia))
{
mountPath = pMedia->getMountPath();
c_monitor->Unlock(pMedia);
}
// The media monitor could be inactive.
// Create a fake media device just to lookup mount map:
else
{
pMedia = MythCDROM::get(NULL, devPath.toLatin1(), true, false);
if (pMedia && pMedia->findMountPath())
mountPath = pMedia->getMountPath();
else
LOG(VB_MEDIA, LOG_INFO,
"MediaMonitor::GetMountPath() - failed");
// need some way to delete the media device.
}
}
return mountPath;
}
示例6: cd_init_device
void Ripper::ejectCD()
{
bool bEjectCD = gCoreContext->GetNumSetting("EjectCDAfterRipping",1);
if (bEjectCD)
{
#ifdef HAVE_CDAUDIO
QByteArray devname = m_CDdevice.toAscii();
int cdrom_fd = cd_init_device(const_cast<char*>(devname.constData()));
VERBOSE(VB_MEDIA, "Ripper::ejectCD() - dev " + m_CDdevice);
if (cdrom_fd != -1)
{
if (cd_eject(cdrom_fd) == -1)
perror("Failed on cd_eject");
cd_finish(cdrom_fd);
}
else
perror("Failed on cd_init_device");
#else
MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
if (mon)
{
QByteArray devname = m_CDdevice.toAscii();
MythMediaDevice *pMedia = mon->GetMedia(devname.constData());
if (pMedia && mon->ValidateAndLock(pMedia))
{
pMedia->eject();
mon->Unlock(pMedia);
}
}
#endif
}
}
示例7: eventFilter
/**
* Installed into the main window's event chain,
* so that the main thread can safely jump to plugin code.
*/
bool MediaMonitor::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == MythMediaEvent::kEventType)
{
MythMediaDevice *pDev = ((MythMediaEvent*)event)->getDevice();
if (!pDev)
{
VERBOSE(VB_IMPORTANT,
"MediaMonitor::eventFilter() got a bad media event?");
return true;
}
if (pDev->isUsable())
JumpToMediaHandler(pDev);
else
{
// We don't want to jump around in the menus, but should
// call each plugin's callback so it can track this change.
QMap<QString, MHData>::Iterator itr = m_handlerMap.begin();
while (itr != m_handlerMap.end())
{
if ((*itr).MythMediaType & (int)pDev->getMediaType())
(*itr).callback(pDev);
itr++;
}
}
return false; // Don't eat the event
}
// standard event processing
return QObject::eventFilter(obj, event);
}
示例8: CheckDeviceNotifications
/** \fn MediaMonitor::CheckDevices(void)
* \brief Poll the devices in our list.
*/
void MediaMonitor::CheckDevices(void)
{
/* check if new devices have been plugged in */
CheckDeviceNotifications();
QList<MythMediaDevice*>::iterator itr = m_Devices.begin();
MythMediaDevice* pDev;
while (itr != m_Devices.end())
{
pDev = *itr;
if (pDev)
pDev->checkMedia();
++itr;
}
}
示例9: MediaMonitor
/**
* \class MediaMonitorWindows
*
* I am assuming, for now, that everything on Windows uses drive letters
* (e.g. C:, D:). That is probably wrong, though. (other APIs?)
*/
MediaMonitorWindows::MediaMonitorWindows(QObject* par,
unsigned long interval,
bool allowEject)
: MediaMonitor(par, interval, allowEject)
{
char strDrives[128];
if (!::GetLogicalDriveStrings(sizeof(strDrives), strDrives))
return;
for (char *driveName = strDrives; *driveName;
driveName += strlen(driveName) + 1)
{
uint type = ::GetDriveType(driveName);
if (type != DRIVE_REMOVABLE && type != DRIVE_CDROM)
continue;
MythMediaDevice *media = NULL;
if (type == DRIVE_CDROM)
media = MythCDROM::get(this, driveName, false, allowEject);
else
media = MythHDD::Get(this, driveName, false, allowEject);
if (!media)
{
VERBOSE(VB_IMPORTANT,
"Error. Couldn't create MythMediaDevice.");
return;
}
// We store the volume name to improve
// user activities like ChooseAndEjectMedia().
char volumeName[MAX_PATH];
if (GetVolumeInformation(driveName, volumeName, MAX_PATH,
NULL, NULL, NULL, NULL, NULL))
{
media->setVolumeID(volumeName);
}
AddDevice(media);
}
VERBOSE(VB_MEDIA, "Initial device list: " + listDevices());
}
示例10: LOG
/*
* DBus UDisk AddDevice handler
*/
void MediaMonitorUnix::deviceAdded( QDBusObjectPath o)
{
LOG(VB_MEDIA, LOG_INFO, LOC + ":deviceAdded " + o.path());
// Don't add devices with partition tables, just the partitions
if (!DeviceProperty(o, "DeviceIsPartitionTable").toBool())
{
QString dev = DeviceProperty(o, "DeviceFile").toString();
MythMediaDevice* pDevice;
if (DeviceProperty(o, "DeviceIsRemovable").toBool())
pDevice = MythCDROM::get(this, dev.toLatin1(), false, m_AllowEject);
else
pDevice = MythHDD::Get(this, dev.toLatin1(), false, false);
if (pDevice && !AddDevice(pDevice))
pDevice->deleteLater();
}
}
示例11: LOG
QString MediaMonitor::defaultDevice(QString dbSetting,
QString label,
const char *hardCodedDefault)
{
QString device = gCoreContext->GetSetting(dbSetting);
LOG(VB_MEDIA, LOG_DEBUG,
QString("MediaMonitor::defaultDevice(%1,..,%2) dbSetting='%3'")
.arg(dbSetting).arg(hardCodedDefault).arg(device));
// No settings database defaults? Try to choose one:
if (device.isEmpty() || device == "default")
{
device = hardCodedDefault;
if (!c_monitor)
c_monitor = GetMediaMonitor();
if (c_monitor)
{
MythMediaDevice *d = c_monitor->selectDrivePopup(label, false, true);
if (d == (MythMediaDevice *) -1) // User cancelled
{
device.clear(); // If user has explicitly cancelled return empty string
d = NULL;
}
if (d && c_monitor->ValidateAndLock(d))
{
device = d->getDevicePath();
c_monitor->Unlock(d);
}
}
}
LOG(VB_MEDIA, LOG_DEBUG,
"MediaMonitor::defaultDevice() returning " + device);
return device;
}
示例12: VERBOSE
QString MediaMonitor::defaultDevice(QString dbSetting,
QString label,
const char *hardCodedDefault)
{
QString device = gCoreContext->GetSetting(dbSetting);
VERBOSE(VB_MEDIA+VB_EXTRA,
QString("MediaMonitor::defaultDevice(%1,..,%2) dbSetting='%3'")
.arg(dbSetting).arg(hardCodedDefault).arg(device));
// No settings database defaults? Try to choose one:
if (device.isEmpty() || device == "default")
{
device = hardCodedDefault;
if (!c_monitor)
c_monitor = GetMediaMonitor();
if (c_monitor)
{
MythMediaDevice *d = c_monitor->selectDrivePopup(label);
if (d == (MythMediaDevice *) -1) // User cancelled
d = NULL;
if (d && c_monitor->ValidateAndLock(d))
{
device = d->getDevicePath();
c_monitor->Unlock(d);
}
}
}
VERBOSE(VB_MEDIA+VB_EXTRA,
"MediaMonitor::defaultDevice() returning " + device);
return device;
}
示例13: iface
/**
* \brief Search /sys/block for valid removable media devices.
*
* This function creates MediaDevice instances for valid removable media
* devices found under the /sys/block filesystem in Linux. CD and DVD
* devices are created as MythCDROM instances. MythHDD instances will be
* created for each partition on removable hard disk devices, if they exist.
* Otherwise a single MythHDD instance will be created for the entire disc.
*
* NOTE: Floppy disks are ignored.
*/
bool MediaMonitorUnix::CheckMountable(void)
{
#if CONFIG_QTDBUS
for (int i = 0; i < 10; ++i, usleep(500000))
{
// Connect to UDisks. This can sometimes fail if mythfrontend
// is started during system init
QDBusInterface iface(UDISKS_SVC, UDISKS_PATH, UDISKS_IFACE,
QDBusConnection::systemBus() );
if (!iface.isValid())
{
LOG(VB_GENERAL, LOG_ALERT, LOC +
"CheckMountable: DBus interface error: " +
iface.lastError().message() );
continue;
}
// Enumerate devices
typedef QList<QDBusObjectPath> QDBusObjectPathList;
QDBusReply<QDBusObjectPathList> reply = iface.call("EnumerateDevices");
if (!reply.isValid())
{
LOG(VB_GENERAL, LOG_ALERT, LOC +
"CheckMountable DBus EnumerateDevices error: " +
reply.error().message() );
continue;
}
// Listen on DBus for UDisk add/remove device messages
(void)QDBusConnection::systemBus().connect(
UDISKS_SVC, UDISKS_PATH, UDISKS_IFACE, UDISKS_DEVADD, UDISKS_DEVSIG,
this, SLOT(deviceAdded(QDBusObjectPath)) );
(void)QDBusConnection::systemBus().connect(
UDISKS_SVC, UDISKS_PATH, UDISKS_IFACE, UDISKS_DEVRMV, UDISKS_DEVSIG,
this, SLOT(deviceRemoved(QDBusObjectPath)) );
// Parse the returned device array
const QDBusObjectPathList& list(reply.value());
for (QDBusObjectPathList::const_iterator it = list.begin();
it != list.end(); ++it)
{
if (!DeviceProperty(*it, "DeviceIsSystemInternal").toBool() &&
!DeviceProperty(*it, "DeviceIsPartitionTable").toBool() )
{
QString dev = DeviceProperty(*it, "DeviceFile").toString();
// ignore floppies, too slow
if (dev.startsWith("/dev/fd"))
continue;
MythMediaDevice* pDevice;
if (DeviceProperty(*it, "DeviceIsRemovable").toBool())
pDevice = MythCDROM::get(this, dev.toLatin1(), false, m_AllowEject);
else
pDevice = MythHDD::Get(this, dev.toLatin1(), false, false);
if (pDevice && !AddDevice(pDevice))
pDevice->deleteLater();
}
}
// Success
return true;
}
// Timed out
return false;
#elif defined linux
// NB needs script in /etc/udev/rules.d
mkfifo(kUDEV_FIFO, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
m_fifo = open(kUDEV_FIFO, O_RDONLY | O_NONBLOCK);
QDir sysfs("/sys/block");
sysfs.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
QStringList devices = sysfs.entryList();
for (QStringList::iterator it = devices.begin(); it != devices.end(); ++it)
{
// ignore floppies, too slow
if ((*it).startsWith("fd"))
continue;
sysfs.cd(*it);
QString path = sysfs.absolutePath();
if (CheckRemovable(path))
FindPartitions(path, true);
sysfs.cdUp();
//.........这里部分代码省略.........
示例14: devicePath
// Given a fstab entry to a media device determine what type of device it is
bool MediaMonitorUnix::AddDevice(struct fstab * mep)
{
if (!mep)
return false;
#ifndef Q_OS_ANDROID
QString devicePath( mep->fs_spec );
#if 0
LOG(VB_GENERAL, LOG_DEBUG, "AddDevice - " + devicePath);
#endif
MythMediaDevice* pDevice = NULL;
struct stat sbuf;
bool is_supermount = false;
bool is_cdrom = false;
if (stat(mep->fs_spec, &sbuf) < 0)
return false;
// Can it be mounted?
if ( ! ( ((strstr(mep->fs_mntops, "owner") &&
(sbuf.st_mode & S_IRUSR)) || strstr(mep->fs_mntops, "user")) &&
(strstr(mep->fs_vfstype, MNTTYPE_ISO9660) ||
strstr(mep->fs_vfstype, MNTTYPE_UDF) ||
strstr(mep->fs_vfstype, MNTTYPE_AUTO)) ) )
{
if (strstr(mep->fs_mntops, MNTTYPE_ISO9660) &&
strstr(mep->fs_vfstype, MNTTYPE_SUPERMOUNT))
{
is_supermount = true;
}
else
{
return false;
}
}
if (strstr(mep->fs_mntops, MNTTYPE_ISO9660) ||
strstr(mep->fs_vfstype, MNTTYPE_ISO9660) ||
strstr(mep->fs_vfstype, MNTTYPE_UDF) ||
strstr(mep->fs_vfstype, MNTTYPE_AUTO))
{
is_cdrom = true;
#if 0
LOG(VB_GENERAL, LOG_DEBUG, "Device is a CDROM");
#endif
}
if (!is_supermount)
{
if (is_cdrom)
pDevice = MythCDROM::get(this, mep->fs_spec,
is_supermount, m_AllowEject);
}
else
{
char *dev = 0;
int len = 0;
dev = strstr(mep->fs_mntops, SUPER_OPT_DEV);
if (dev == NULL)
return false;
dev += sizeof(SUPER_OPT_DEV)-1;
while (dev[len] != ',' && dev[len] != ' ' && dev[len] != 0)
len++;
if (dev[len] != 0)
{
char devstr[256];
strncpy(devstr, dev, len);
devstr[len] = 0;
if (is_cdrom)
pDevice = MythCDROM::get(this, devstr,
is_supermount, m_AllowEject);
}
else
return false;
}
if (pDevice)
{
pDevice->setMountPath(mep->fs_file);
if (pDevice->testMedia() == MEDIAERR_OK)
{
if (AddDevice(pDevice))
return true;
}
pDevice->deleteLater();
}
#endif
return false;
}