Esempio n. 1
0
/**
 * \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));
}
Esempio n. 2
0
/**
 * \brief Create a MythMedia instance and insert in MythMediaMonitor list
 *
 * We are a friend class of MythMediaMonitor,
 * so that we can add or remove from its list of media objects.
 */
void MonitorThreadDarwin::diskInsert(const char *devName,
                                     const char *volName,
                                     QString model, bool isCDorDVD)
{
    MythMediaDevice  *media;
    QString           msg = "MonitorThreadDarwin::diskInsert";

    LOG(VB_MEDIA, LOG_DEBUG, msg + QString("(%1,%2,'%3',%4)")
                      .arg(devName).arg(volName).arg(model).arg(isCDorDVD));

    if (isCDorDVD)
        media = MythCDROM::get(NULL, devName, true, m_Monitor->m_AllowEject);
    else
        media = MythHDD::Get(NULL, devName, true, false);

    if (!media)
    {
        LOG(VB_GENERAL, LOG_ALERT, msg + "Couldn't create MythMediaDevice.");
        return;
    }

    // We store the volume name for user activities like ChooseAndEjectMedia().
    media->setVolumeID(volName);
    media->setDeviceModel(model.toLatin1());  // Same for the Manufacturer and model

    // Mac OS X devices are pre-mounted here:
    QString mnt = "/Volumes/"; mnt += volName;
    media->setMountPath(mnt.toLatin1());

    int  attempts = 0;
    QDir d(mnt);
    while (!d.exists())
    {
        LOG(VB_MEDIA, LOG_WARNING,
            (msg + "() - Waiting for mount '%1' to become stable.").arg(mnt));
        usleep(120000);
        if ( ++attempts > 4 )
            usleep(200000);
        if ( attempts > 8 )
        {
            delete media;
            LOG(VB_MEDIA, LOG_ALERT, msg + "() - Giving up");
            return;
        }
    }

    media->setStatus(MEDIASTAT_MOUNTED);

    // This is checked in AddDevice(), but checking earlier means
    // we can avoid scanning all the files to determine its type
    if (m_Monitor->shouldIgnore(media))
        return;

    // We want to use MythMedia's code to work out the mediaType.
    // media->onDeviceMounted() is protected,
    // so to call it indirectly, we pretend to mount it here.
    media->mount();

    m_Monitor->AddDevice(media);
}
Esempio n. 3
0
void MonitorThreadDarwin::diskRemove(QString devName)
{
    LOG(VB_MEDIA, LOG_DEBUG,
            QString("MonitorThreadDarwin::diskRemove(%1)").arg(devName));

    if (m_Monitor->m_SendEvent)
    {
        MythMediaDevice *pDevice = m_Monitor->GetMedia(devName);

        if (pDevice)  // Probably should ValidateAndLock() here?
            pDevice->setStatus(MEDIASTAT_NODISK);
        else
            LOG(VB_MEDIA, LOG_INFO,
                     "Couldn't find MythMediaDevice: " + devName);
    }

    m_Monitor->RemoveDevice(devName);
}