Ticket #3077: mythmusic-cddevices.diff

File mythmusic-cddevices.diff, 6.3 KB (added by devel@…, 14 years ago)

Add default cd/dvd device selection to mythmusic

  • mythmusic/mythmusic/globalsettings.cpp

     
    1212#include <qprocess.h>
    1313#include <qapplication.h>
    1414#include <mythtv/util.h>
     15#include <mythtv/mythmediamonitor.h>
    1516
    1617// General Settings
    1718
     
    5354{
    5455    HostComboBox *gc = new HostComboBox("CDDevice", true);
    5556    gc->setLabel(QObject::tr("CD device"));
    56     QDir dev("/dev", "cdrom*", QDir::Name, QDir::System);
    57     gc->fillSelectionsFromDir(dev);
    58     dev.setNameFilter("scd*");
    59     gc->fillSelectionsFromDir(dev);
    60     dev.setNameFilter("hd*");
    61     gc->fillSelectionsFromDir(dev);
    62 
    63     dev.setNameFilter("cdrom*");
    64     dev.setPath("/dev/cdroms");
    65     gc->fillSelectionsFromDir(dev);
    66     gc->setHelpText(QObject::tr("CDRom device used for ripping/playback."));
     57    gc->addSelection(QObject::tr("default"), "default");
     58    MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
     59    QStringList cdroms = mon->GetCDROMBlockDevices();
     60    QStringList::iterator iter = cdroms.begin();
     61        for (; iter != cdroms.end(); iter++ )
     62            gc->addSelection("/dev/"+*iter);
     63    gc->setHelpText(QObject::tr("CDRom device used for ripping/playback. 'default' will use the device specified in MythTV"));
    6764    return gc;
    6865};
    6966
     
    388385
    389386static HostComboBox *CDWriterDevice()
    390387{
    391     HostComboBox *gc = new HostComboBox("CDWriterDevice");
    392 
    393     QString argadd[3]  = { "", "-dev=ATA", "-dev=ATAPI" };
    394     QString prepend[3] = { "", "ATA:", "ATAPI:" };
    395 
    396     for (int i = 0; i < 3; i++)
    397     {
    398         QStringList args;
    399         QStringList result;
    400 
    401         args = "cdrecord";
    402         args += "--scanbus";
    403 
    404         if (argadd[i].length() > 1)
    405             args += argadd[i];
    406 
    407         QProcess proc(args);
    408 
    409         MythTimer totaltimer;
    410    
    411         if (proc.start())
    412         {
    413             totaltimer.start();
    414 
    415             while (1)
    416             {
    417                 while (proc.canReadLineStdout())
    418                     result += proc.readLineStdout();
    419                 if (proc.isRunning())
    420                 {
    421                     qApp->processEvents();
    422                     usleep(10000);
    423                 }
    424                 else
    425                 {
    426                     if (!proc.normalExit())
    427                         cerr << "Failed to run 'cdrecord --scanbus'\n";
    428                     break;
    429                 }
    430 
    431                 if (totaltimer.elapsed() > 1500)
    432                     proc.kill();
    433             }
    434         }
    435         else
    436             cerr << "Failed to run 'cdrecord --scanbus'\n";
    437 
    438         while (proc.canReadLineStdout())
    439             result += proc.readLineStdout();
    440 
    441         for (QStringList::Iterator it = result.begin(); it != result.end();
    442              ++it)
    443         {
    444             QString line = *it;
    445             if (line.length() > 12)
    446             {
    447                 if (line[10] == ')' && line[12] != '*')
    448                 {
    449                     gc->addSelection(line.mid(24, 16), prepend[i] +
    450                                                        line.mid(1, 5));
    451 cout << "adding: " << prepend[i] + line.mid(1, 5) << " -- " << line.mid(24, 16) << endl;
    452                 }
    453             }
    454         }
    455     }
    456    
     388    HostComboBox *gc = new HostComboBox("CDWriterDevice", true);
    457389    gc->setLabel(QObject::tr("CD-Writer Device"));
    458     gc->setHelpText(QObject::tr("Select the SCSI or IDE Device for CD Writing."));
     390    gc->addSelection(QObject::tr("default"), "default");
     391    MediaMonitor *mon = MediaMonitor::GetMediaMonitor();
     392    QStringList cdroms = mon->GetCDROMBlockDevices();
     393    QStringList::iterator iter = cdroms.begin();
     394    for (; iter != cdroms.end(); iter++ )
     395        gc->addSelection("/dev/"+*iter);
     396    gc->setHelpText(QObject::tr("CD/DVD writer device for CD Writing. 'default' will use the device specified in MythTV"));
    459397    return gc;
    460398};
    461399
     
    463401{
    464402    HostComboBox *gc = new HostComboBox("CDDiskSize");
    465403    gc->setLabel(QObject::tr("Disk Size"));
    466     gc->addSelection(QObject::tr("650MB/75min"), "1");
     404    gc->addSelection(QObject::tr("650MB/74min"), "1");
    467405    gc->addSelection(QObject::tr("700MB/80min"), "2");
    468406    gc->setHelpText(QObject::tr("Default CD Capacity."));
    469407    return gc;
  • mythmusic/mythmusic/playlist.cpp

     
    15841584    }
    15851585
    15861586    QString scsidev = gContext->GetSetting("CDWriterDevice");
     1587    if (scsidev == "default")
     1588        scsidev = gContext->GetSetting("defaultCDDevice");
    15871589    if (scsidev.isEmpty() || scsidev.isNull())
    15881590    {
    15891591        cerr << "No CD Writer device defined.\n";
  • mythmusic/mythmusic/databasebox.cpp

     
    407407    }
    408408
    409409    QString scsidev = gContext->GetSetting("CDWriterDevice");
    410     if (scsidev.length()==0)
     410    if (scsidev == "default")
     411        scsidev = gContext->GetSetting("defaultCDDevice");
     412    if (scsidev.isEmpty() || scsidev.isNull())
    411413    {
    412         cerr << "playlist.o: We don't have SCSI devices" << endl ;
     414        cerr << "No CD Writer device defined.\n";
    413415        return;
    414416    }
     417
    415418    // Begin Blanking
    416419    MythProgressDialog *record_progress;
    417420    record_progress = new MythProgressDialog(tr("CD-RW Blanking Progress"), 10);
     
    836839    if (gContext->GetNumSetting("CDWriterEnabled"))
    837840    {
    838841        QString scsidev = gContext->GetSetting("CDWriterDevice");
     842        if (scsidev == "default")
     843            scsidev = gContext->GetSetting("defaultCDDevice");
     844
    839845        if (!scsidev.isEmpty() && !scsidev.isNull())
    840846            cdwriter = true;
    841847    }
  • mythmusic/mythmusic/cddecoder.cpp

     
    4141    settracknum = -1;
    4242
    4343    devicename = gContext->GetSetting("CDDevice");
     44    if (devicename == "default")
     45        devicename = gContext->GetSetting("defaultCDDevice");
    4446}
    4547
    4648CdDecoder::~CdDecoder(void)