Ticket #9169: autoplay-hdd.diff

File autoplay-hdd.diff, 1.3 KB (added by lvr@…, 10 years ago)

detect usb disk removal

  • mythtv/libs/libmyth/mythhdd.cpp

     
    4141        return setStatus(MEDIASTAT_MOUNTED);
    4242    }
    4343
     44    // Has device been removed?
     45    if (!isDeviceOpen())
     46    {
     47        if (!openDevice())
     48            return setStatus(MEDIASTAT_UNPLUGGED);
     49        closeDevice();
     50    }
     51
    4452    // device is not mounted
    45     if (m_Status == MEDIASTAT_UNPLUGGED)
     53    switch (m_Status)
    4654    {
     55    case MEDIASTAT_UNPLUGGED:
    4756        // a removable device was just plugged in try to mount it.
    4857        mount();
    4958        if (isMounted())
     
    5160            m_Status = MEDIASTAT_NOTMOUNTED;
    5261            return setStatus(MEDIASTAT_MOUNTED);
    5362        }
    54         else
    55             return setStatus(MEDIASTAT_NOTMOUNTED);
    56     }
    57     else if (m_Status == MEDIASTAT_MOUNTED)
    58     {
     63        return setStatus(MEDIASTAT_NOTMOUNTED);
     64    case MEDIASTAT_MOUNTED:
    5965        // device was mounted and someone unmounted it.
    60         return m_Status = setStatus(MEDIASTAT_NOTMOUNTED);
    61     }
    62     else
    63     {
     66        return setStatus(MEDIASTAT_NOTMOUNTED);
     67    default:
    6468        // leave device state as is
    6569        return m_Status;
    6670    }