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));
}
예제 #2
0
파일: cdrip.cpp 프로젝트: faginbagin/mythtv
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
0
파일: cdrip.cpp 프로젝트: DocOnDev/mythtv
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
    }
}
예제 #4
0
void IconView::HandleSettings(void)
{
    GallerySettings settings;
    settings.exec();
    gCoreContext->ClearSettingsCache();

    // reload settings
    m_showcaption = gCoreContext->GetNumSetting("GalleryOverlayCaption", 0);
    m_sortorder   = gCoreContext->GetNumSetting("GallerySortOrder", 0);
    m_useOpenGL   = gCoreContext->GetNumSetting("SlideshowUseOpenGL", 0);
    m_recurse     = gCoreContext->GetNumSetting("GalleryRecursiveSlideshow", 0);
    m_paths       = gCoreContext->GetSetting("GalleryImportDirs").split(":");
    m_allowImportScripts = gCoreContext->GetNumSetting("GalleryAllowImportScripts", 0);

    // reload directory
    MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
    if (m_currDevice && mon && mon->ValidateAndLock(m_currDevice))
    {
#ifdef _WIN32
        LoadDirectory(m_currDevice->getDevicePath());
#else
        LoadDirectory(m_currDevice->getMountPath());
#endif
        mon->Unlock(m_currDevice);
    }
    else
    {
        m_currDevice = NULL;
        LoadDirectory(m_galleryDir);
    }

    SetFocusWidget(m_imageList);
}
예제 #5
0
void IconView::SetupMediaMonitor(void)
{
#ifdef _WIN32
    if (m_currDevice)
        LoadDirectory(m_currDevice->getDevicePath());
#else
    MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
    if (m_currDevice && mon && mon->ValidateAndLock(m_currDevice))
    {
        bool mounted = m_currDevice->isMounted();
        if (!mounted)
            mounted = m_currDevice->mount();

        if (mounted)
        {
            connect(m_currDevice,
                SIGNAL(statusChanged(MythMediaStatus, MythMediaDevice*)),
                SLOT(mediaStatusChanged(MythMediaStatus, MythMediaDevice*)));

            LoadDirectory(m_currDevice->getMountPath());

            mon->Unlock(m_currDevice);
            return;
        }
        else
        {
//             DialogBox *dlg = new DialogBox(GetMythMainWindow(),
//                              tr("Failed to mount device: ") +
//                              m_currDevice->getDevicePath() + "\n\n" +
//                              tr("Showing the default MythGallery directory."));
//             dlg->AddButton(tr("OK"));
//             dlg->exec();
//             dlg->deleteLater();
            mon->Unlock(m_currDevice);
        }
    }
#endif // _WIN32
}
예제 #6
0
bool IconView::HandleMediaDeviceSelect(ThumbItem *item)
{
    MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
    if (mon && mon->ValidateAndLock(item->GetMediaDevice()))
    {
        m_currDevice = item->GetMediaDevice();

#ifdef _WIN32
        LoadDirectory(m_currDevice->getDevicePath());
#else
        if (!m_currDevice->isMounted(false))
            m_currDevice->mount();

        item->SetPath(m_currDevice->getMountPath(), true);

        connect(m_currDevice,
                SIGNAL(statusChanged(MythMediaStatus,
                                     MythMediaDevice*)),
                SLOT(mediaStatusChanged(MythMediaStatus,
                                        MythMediaDevice*)));

        LoadDirectory(m_currDevice->getMountPath());
#endif

        mon->Unlock(m_currDevice);
    }
    else
    {
        // device was removed
        QString msg = tr("Error") + '\n' +
                tr("The selected device is no longer available");
        ShowOkPopup(msg, this, SLOT(HandleShowDevices()));
    }

    return true;
}
예제 #7
0
void IconView::HandleShowDevices(void)
{
    MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
#ifndef _WIN32
    if (m_currDevice && mon && mon->ValidateAndLock(m_currDevice))
    {
        m_currDevice->disconnect(this);
        mon->Unlock(m_currDevice);
    }
    else
        m_currDir = m_galleryDir;
#endif

    m_currDevice = NULL;

    m_showDevices = true;

    while (!m_itemList.isEmpty())
        delete m_itemList.takeFirst();

    m_itemHash.clear();
    m_imageList->Reset();

    m_thumbGen->cancel();
    m_childCountThread->cancel();

    // add gallery directory
    ThumbItem *item = new ThumbItem("Gallery", m_galleryDir, true);
    m_itemList.append(item);
    m_itemHash.insert(item->GetName(), item);

    if (mon)
    {
        MythMediaType type = MythMediaType(MEDIATYPE_DATA | MEDIATYPE_MGALLERY | MEDIATYPE_MVIDEO);
        QList<MythMediaDevice*> removables = mon->GetMedias(type);
        QList<MythMediaDevice*>::Iterator it = removables.begin();
        for (; it != removables.end(); ++it)
        {
            if (mon->ValidateAndLock(*it))
            {
                item = new ThumbItem(
                    (*it)->getVolumeID().isEmpty() ?
                    (*it)->getDevicePath() : (*it)->getVolumeID(),
                    (*it)->getMountPath(), true, *it);

                m_itemList.append(item);
                m_itemHash.insert(item->GetName(), item);

                mon->Unlock(*it);
            }
        }
    }

    ThumbItem *thumbitem;
    for (int x = 0; x < m_itemList.size(); x++)
    {
        thumbitem = m_itemList.at(x);

        thumbitem->InitCaption(m_showcaption);
        MythUIButtonListItem* item =
            new MythUIButtonListItem(m_imageList, thumbitem->GetCaption(), 0,
                                     true, MythUIButtonListItem::NotChecked);
        item->SetData(qVariantFromValue(thumbitem));
    }

    // exit from menu on show devices action..
    SetFocusWidget(m_imageList);
}