Skip to content

Commit

Permalink
libmyth: mediamonitor-windows add removeable media handling
Browse files Browse the repository at this point in the history
This patch adds handling for USB/removable drives to the Win32
media monitor.  Currently it's restricted to CDs only.

Fixes #10295

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Gavin Hurlbut <ghurlbut@mythtv.org>
  • Loading branch information
Lawrence Rust authored and Beirdo committed Jul 5, 2012
1 parent 992cba7 commit 42e5084
Showing 1 changed file with 49 additions and 21 deletions.
70 changes: 49 additions & 21 deletions mythtv/libs/libmyth/mediamonitor-windows.cpp
Expand Up @@ -26,39 +26,67 @@ MediaMonitorWindows::MediaMonitorWindows(QObject* par,
{
char strDrives[128];
if (!::GetLogicalDriveStrings(sizeof(strDrives), strDrives))
{
LOG(VB_GENERAL, LOG_ERR,
"Error. MediaMonitorWindows failed at GetLogicalDriveStrings.");
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)
UINT type = ::GetDriveType(driveName);
switch (type)
{
case DRIVE_CDROM:
LOG(VB_MEDIA, LOG_DEBUG,
QString("MediaMonitorWindows found cdrom '%1'").arg(driveName));
media = MythCDROM::get(this, driveName, false, allowEject);
else
break;
case DRIVE_REMOVABLE:
LOG(VB_MEDIA, LOG_DEBUG,
QString("MediaMonitorWindows found removeable '%1'")
.arg(driveName));
media = MythHDD::Get(this, driveName, false, allowEject);

if (!media)
{
LOG(VB_GENERAL, LOG_ALERT,
"Error. Couldn't create MythMediaDevice.");
return;
break;
case DRIVE_UNKNOWN:
LOG(VB_MEDIA, LOG_DEBUG,
QString("MediaMonitorWindows found unknown '%1'")
.arg(driveName));
media = MythCDROM::get(this, driveName, false, allowEject);
break;
case DRIVE_NO_ROOT_DIR:
LOG(VB_MEDIA, LOG_DEBUG,
QString("MediaMonitorWindows found '%1' with no root dir")
.arg(driveName));
media = MythCDROM::get(this, driveName, false, allowEject);
break;
default:
LOG(VB_MEDIA, LOG_INFO, QString("MediaMonitorWindows found '%1' type %2")
.arg(driveName).arg(type));
case DRIVE_FIXED:
case DRIVE_REMOTE:
case DRIVE_RAMDISK:
continue;
}

// 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))
if (media)
{
media->setVolumeID(volumeName);
// 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);
}

AddDevice(media);
else
LOG(VB_GENERAL, LOG_ALERT,
"Error. Couldn't create MythMediaDevice.");
}

LOG(VB_MEDIA, LOG_INFO, "Initial device list: " + listDevices());
Expand Down

0 comments on commit 42e5084

Please sign in to comment.