Ticket #10295: 0001-libmyth-mediamonitor-windows-add-removeable-media-ha.patch

File 0001-libmyth-mediamonitor-windows-add-removeable-media-ha.patch, 3.9 KB (added by Lawrence Rust <lvr@…>, 9 years ago)
  • mythtv/libs/libmyth/mediamonitor-windows.cpp

    From 2dc2bdb3525d33347211b07c4c50221b217bd074 Mon Sep 17 00:00:00 2001
    From: Lawrence Rust <lvr@softsystem.co.uk>
    Date: Mon, 30 Jan 2012 20:45:29 +0100
    Subject: [PATCH 1/3] libmyth: mediamonitor-windows add removeable media handling
    
    This patch adds handling for USB/removable drives to the Win32
    media monitor.  Currently it's restricted to CDs only.
    
    Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
    ---
     mythtv/libs/libmyth/mediamonitor-windows.cpp |   70 ++++++++++++++++++--------
     1 files changed, 49 insertions(+), 21 deletions(-)
    
    diff --git a/mythtv/libs/libmyth/mediamonitor-windows.cpp b/mythtv/libs/libmyth/mediamonitor-windows.cpp
    index a52905d..7d7ffc5 100644
    a b MediaMonitorWindows::MediaMonitorWindows(QObject* par, 
    2626{
    2727    char strDrives[128];
    2828    if (!::GetLogicalDriveStrings(sizeof(strDrives), strDrives))
     29    {
     30        LOG(VB_GENERAL, LOG_ERR,
     31            "Error. MediaMonitorWindows failed at GetLogicalDriveStrings.");
    2932        return;
     33    }
    3034
    3135    for (char *driveName = strDrives; *driveName;
    3236         driveName += strlen(driveName) + 1)
    3337    {
    34         uint type = ::GetDriveType(driveName);
    35         if (type != DRIVE_REMOVABLE && type != DRIVE_CDROM)
    36             continue;
    37 
    3838        MythMediaDevice *media = NULL;
    39 
    40         if (type == DRIVE_CDROM)
     39        UINT type = ::GetDriveType(driveName);
     40        switch (type)
     41        {
     42        case DRIVE_CDROM:
     43            LOG(VB_MEDIA, LOG_DEBUG,
     44                QString("MediaMonitorWindows found cdrom '%1'").arg(driveName));
    4145            media = MythCDROM::get(this, driveName, false, allowEject);
    42         else
     46            break;
     47        case DRIVE_REMOVABLE:
     48            LOG(VB_MEDIA, LOG_DEBUG,
     49                QString("MediaMonitorWindows found removeable '%1'")
     50                    .arg(driveName));
    4351            media = MythHDD::Get(this, driveName, false, allowEject);
    44 
    45         if (!media)
    46         {
    47             LOG(VB_GENERAL, LOG_ALERT,
    48                     "Error. Couldn't create MythMediaDevice.");
    49             return;
     52            break;
     53        case DRIVE_UNKNOWN:
     54            LOG(VB_MEDIA, LOG_DEBUG,
     55                QString("MediaMonitorWindows found unknown '%1'")
     56                    .arg(driveName));
     57            media = MythCDROM::get(this, driveName, false, allowEject);
     58            break;
     59        case DRIVE_NO_ROOT_DIR:
     60            LOG(VB_MEDIA, LOG_DEBUG,
     61                QString("MediaMonitorWindows found '%1' with no root dir")
     62                    .arg(driveName));
     63            media = MythCDROM::get(this, driveName, false, allowEject);
     64            break;
     65        default:
     66            LOG(VB_MEDIA, LOG_INFO, QString("MediaMonitorWindows found '%1' type %2")
     67                .arg(driveName).arg(type));
     68        case DRIVE_FIXED:
     69        case DRIVE_REMOTE:
     70        case DRIVE_RAMDISK:
     71            continue;
    5072        }
    5173
    52         // We store the volume name to improve
    53         // user activities like ChooseAndEjectMedia().
    54         char volumeName[MAX_PATH];
    55         if (GetVolumeInformation(driveName, volumeName, MAX_PATH,
    56                                  NULL, NULL, NULL, NULL, NULL))
     74        if (media)
    5775        {
    58             media->setVolumeID(volumeName);
     76            // We store the volume name to improve
     77            // user activities like ChooseAndEjectMedia().
     78            char volumeName[MAX_PATH];
     79            if (GetVolumeInformation(driveName, volumeName, MAX_PATH,
     80                                     NULL, NULL, NULL, NULL, NULL))
     81            {
     82                media->setVolumeID(volumeName);
     83            }
     84
     85            AddDevice(media);
    5986        }
    60 
    61         AddDevice(media);
     87        else
     88            LOG(VB_GENERAL, LOG_ALERT,
     89                    "Error. Couldn't create MythMediaDevice.");
    6290    }
    6391
    6492    LOG(VB_MEDIA, LOG_INFO, "Initial device list: " + listDevices());