Ticket #1299: mtd_verbose_wipe_ioctl.patch

File mtd_verbose_wipe_ioctl.patch, 14.4 KB (added by Anduin Withers <awithers@…>, 18 years ago)
  • mythdvd/mtd/jobthread.cpp

     
    4646
    4747void JobThread::run()
    4848{
    49     cerr << "jobthread.o: Somebody ran an actual (base class) JobThread. I don't think that's supposed to happen." << endl;
     49    VERBOSE(VB_IMPORTANT, "Somebody ran an actual (base class) JobThread. I"
     50            " don't think that's supposed to happen.");
    5051}
    5152
    5253bool JobThread::keepGoing()
     
    217218        {
    218219            if (!(m_mutex && m_mutex->locked()))
    219220            {
    220                 cerr << __FILE__ << ": Invalid mutext passed to MutexUnlocker"
    221                         << endl;
     221                VERBOSE(VB_IMPORTANT,
     222                        QString("%1: Invalid mutext passed to MutexUnlocker")
     223                        .arg(__FILE__));
    222224            }
    223225        }
    224226
     
    284286
    285287void DVDThread::run()
    286288{
    287     cerr << "jobthread.o: Somebody ran an actual (base class) DVDThread. I don't think that's supposed to happen." << endl;
     289    VERBOSE(VB_IMPORTANT, "Somebody ran an actual (base class) DVDThread. I"
     290            " don't think that's supposed to happen.");
    288291}
    289292
    290293
     
    476479                                    &video_data[0]);
    477480            if( len != 1)
    478481            {
    479                 problem(QString("DVDPerfectThread read failed for block %1").arg(cur_pack));
     482                problem(QString("DVDPerfectThread read failed for block %1")
     483                        .arg(cur_pack));
    480484                return false;
    481485            }
    482486           
  • mythdvd/mtd/dvdprobe.cpp

     
    289289    else
    290290    {
    291291        fr_code = 0;
    292         cerr << "dvdprobe.o: Could not find a frame rate code given a frame rate of " << fr << endl ;
     292        VERBOSE(VB_IMPORTANT,
     293                QString("dvdprobe.o: Could not find a frame rate code given a"
     294                        " frame rate of %1").arg(fr));
    293295    }
    294296   
    295297   
     
    401403    }
    402404    else
    403405    {
    404         cerr << "dvdprobe.o: You have a title on your dvd in a format myth doesn't understand." << endl;
    405         cerr << "dvdprobe.o: Either that, or you haven't installed the dvdinput table." << endl;
    406         cerr << "dvdprobe.o: You probably want to report this to a mailing list or something: " << endl;
    407         cerr << "                  height = " << hsize << endl;
    408         cerr << "                   width = " << vsize << endl;
    409         cerr << "            aspect ratio = " << aspect_ratio << " (" << ar_numerator << "/"<< ar_denominator << ")" << endl;
    410         cerr << "              frame rate = " << frame_rate << endl;
    411         cerr << "                 fr_code = " << fr_code << endl;
    412         if(letterbox)
    413         {
    414             cerr << "             letterboxed = true " << endl;
    415         }
    416         else
    417         {
    418             cerr << "             letterboxed = false " << endl;
    419         }
    420         cerr << "                  format = " << video_format << endl;
     406        QString msg =
     407                QString("You have a title on your dvd in a format myth doesn't"
     408                    " understand.\n"
     409                    "Either that, or you haven't installed the dvdinput"
     410                    " table.\n"
     411                    "You probably want to report this to a mailing list or"
     412                    " something:\n"
     413                    "                  height = %1\n"
     414                    "                   width = %2\n"
     415                    "            aspect ratio = %3 (%4/%5)\n"
     416                    "              frame rate = %6\n"
     417                    "                 fr_code = %7\n"
     418                    "             letterboxed = %8\n"
     419                    "                  format = %9")
     420                .arg(hsize).arg(vsize)
     421                .arg(aspect_ratio).arg(ar_numerator).arg(ar_denominator)
     422                .arg(frame_rate).arg(fr_code).arg(letterbox).arg(video_format);
     423        VERBOSE(VB_IMPORTANT, msg);
    421424    }   
    422425}
    423426
     
    442445    device = dvd_device;
    443446    dvd = NULL;
    444447    titles.setAutoDelete(true);
    445     titles.clear();
    446     volume_name = QObject::tr("Unknown");
    447     first_time = true;
     448    wipeClean();
    448449}
    449450
    450451void DVDProbe::wipeClean()
    451452{
     453    first_time = true;
    452454    titles.clear();
    453455    volume_name = QObject::tr("Unknown");
    454456}
     
    481483    //
    482484
    483485    int drive_handle = open(device, O_RDONLY | O_NONBLOCK);
    484     int status = ioctl(drive_handle, CDROM_DRIVE_STATUS, NULL);
     486
     487    if (drive_handle == -1)
     488    {
     489        wipeClean();
     490        return false;
     491    }
     492
     493    // Sometimes the first result following an open is a lie. Often the
     494    // first call will return 4, however an immediate second call will
     495    // return 2. Anecdotally the first result after an open has only
     496    // a 1 in 8 chance of detecting changes from 4 to 2, while a second call
     497    // (in an admittedly small test number) seems to make it much more
     498    // accurate (with only a 1 in 6 chance that the first result was more
     499    // accurate than the second).
     500    ioctl(drive_handle, CDROM_DRIVE_STATUS, CDSL_CURRENT);
     501    int status = ioctl(drive_handle, CDROM_DRIVE_STATUS, CDSL_CURRENT);
    485502    if(status < 4)
    486503    {
    487504        //
     
    529546    //  could be a path, file, whatever).
    530547    //
    531548   
     549    wipeClean();
    532550    first_time = false;
    533     wipeClean();
    534551    dvd = DVDOpen(device);
    535552    if(dvd)
    536553    {
     
    548565        }
    549566        else
    550567        {
    551             cerr << "dvdprobe.o: Error getting volume name, setting to \"Unknown\"" << endl;
     568            VERBOSE(VB_IMPORTANT, "Error getting volume name, setting to"
     569                    "\"Unknown\"");
    552570        }
    553571       
    554572        ifo_handle_t *ifo_file = ifoOpen(dvd, 0);
     
    574592                video_transport_file = ifoOpen(dvd, title_info->title[i].title_set_nr);
    575593                if(!video_transport_file)
    576594                {
    577                     cerr << "dvdprobe.o: Can't get video transport for track " << i+1 << endl;
     595                    VERBOSE(VB_IMPORTANT,
     596                            QString("Can't get video transport for track %1")
     597                            .arg(i+1));
    578598                }
    579599                else
    580600                {
     
    603623                            framerate = 24000/1001.0;  // NTSC_FILM
    604624                            break;
    605625                        default:
    606                             cerr << "dvdprobe.o: For some odd reason (!), I couldn't get a video frame rate" << endl;
     626                            VERBOSE(VB_IMPORTANT,
     627                                    "For some odd reason (!), I couldn't get a"
     628                                    " video frame rate");
    607629                            break;
    608630                    }
    609631                   
     
    688710                                new_title->setAR(16, 9, "16:9");
    689711                                break;
    690712                            default:
    691                                 cerr << "dvdprobe.o: couldn't get aspect ratio for a title" << endl;
     713                                VERBOSE(VB_IMPORTANT, "couldn't get aspect"
     714                                        " ratio for a title");
    692715                        }
    693716                       
    694717                        switch(video_attributes->video_format)
     
    700723                                new_title->setVFormat("pal");
    701724                                break;
    702725                            default:
    703                                 cerr << "dvdprobe.o: Could not get video format for a title" << endl;
     726                                VERBOSE(VB_IMPORTANT, "Could not get video"
     727                                        " format for a title");
    704728                        }
    705729                       
    706730                        if(video_attributes->letterboxed)
     
    728752                                new_title->setSize(352, c_height / 2);
    729753                                break;
    730754                            default:
    731                                 cerr << "dvdprobe.o: Could not determine for video size for a title." << endl ;
     755                                VERBOSE(VB_IMPORTANT, "Could not determine for"
     756                                        " video size for a title.");
    732757                        }
    733758                        ifoClose(video_transport_file);
    734759                    }
    735760                    else
    736761                    {
    737                         cerr << "Couldn't find any audio or video information for track " << i+1 << endl;
     762                        VERBOSE(VB_IMPORTANT,
     763                                QString("Couldn't find any audio or video"
     764                                        " information for track %1").arg(i+1));
    738765                    }           
    739766                }
    740767               
     
    803830    }
    804831    wipeClean();
    805832}
    806 
  • mythdvd/mtd/fileobs.cpp

     
    5959        QDir stupid_qdir("this_is_stupid");
    6060        if(!stupid_qdir.rename(active_file->name(), new_name))
    6161        {
    62             cerr << "fileobs.o: Couldn't rename a ripped file on close ... that sucks." << endl;
    63             cerr << "   old name: \"" << active_file->name() << "\"" << endl;
    64             cerr << "   new name: \"" << new_name << "\"" << endl;
     62            VERBOSE(VB_IMPORTANT,
     63                    QString("Couldn't rename a ripped file on close ... "
     64                            " that sucks.\n"
     65                            "   old name: \"%1\"\n"
     66                            "   new name: \"%1\"")
     67                    .arg(active_file->name()).arg(new_name));
    6568        }
    6669        else
    6770        {
     
    7477        QFile *iter;
    7578        for(iter = files.first(); iter; iter = files.next())
    7679        {
    77             QString new_name = iter->name() + QString("%1").arg(files.count()) + extension;
     80            QString new_name = iter->name() + QString("%1").arg(files.count()) +
     81                    extension;
    7882            if(!stupid_qdir.rename(iter->name(), new_name))
    7983            {
    80                 cerr << "fileobs.o: Couldn't rename \"" << iter->name() << "\" to \"" << new_name << "\"" << endl;
     84                VERBOSE(VB_IMPORTANT, QString("Couldn't rename '%1' to '%2'")
     85                        .arg(iter->name()).arg(new_name));
    8186            }
    8287            else
    8388            {
     
    124129        files.append(new_file);
    125130        if(!active_file->open(access_mode))
    126131        {
    127             cerr << "fileobs.o: couldn't open another file in a set of rip files." << endl;
     132            VERBOSE(VB_IMPORTANT,
     133                    "couldn't open another file in a set of rip files.");
    128134            return false;               
    129135        }
    130136        bytes_written = 0;
     
    132138    int result = write(active_file->handle(), the_data, how_much);
    133139    if(result < 0)
    134140    {
    135         cerr << "fileobs.o: Got a negative result while writing blocks. World may end shortly." << endl;
     141        VERBOSE(VB_IMPORTANT, "Got a negative result while writing blocks."
     142                " World may end shortly.");
    136143        return false;
    137144    }
    138145    if(result == 0)
    139146    {
    140147        if(how_much == 0)
    141148        {
    142             cerr << "fileobs.o: Ripfile wrote 0 bytes, but that's all it was asked to. Unlikely coincidence?" << endl;
     149            VERBOSE(VB_IMPORTANT, "Ripfile wrote 0 bytes, but that's all it"
     150                    " was asked to. Unlikely coincidence?");
    143151        }
    144152        else
    145153        {
    146             cerr << "fileobs.o: Ripfile writing 0 bytes of data. That's probably not a good sign." << endl;
     154            VERBOSE(VB_IMPORTANT, "Ripfile writing 0 bytes of data. That's"
     155                    " probably not a good sign.");
    147156            return false;
    148157        }
    149158    }
    150159    if(result != how_much)
    151160    {
    152         cerr << "fileobs.o: Ripfile tried to write " << how_much << " bytes, but only managed to write " << result << endl ;
     161        VERBOSE(VB_IMPORTANT, QString("Ripfile tried to write %1 bytes, but"
     162                                      " only managed to write %2")
     163                                      .arg(how_much).arg(result));
    153164        return false;
    154165    }
    155166    bytes_written += result;
  • mythdvd/mtd/main.cpp

     
    7070                return FRONTEND_EXIT_INVALID_CMDLINE;
    7171            }
    7272        }
     73        else if (!strcmp(a.argv()[argpos],"-v"))
     74        {
     75            if (++argpos >= argc) {
     76                cerr << "Error: -v requires parameters (try -v help)" <<
     77                        std::endl;
     78                return GENERIC_EXIT_INVALID_CMDLINE;
     79            }
     80
     81            int err;
     82            if ((err = parse_verbose_arg(a.argv()[argpos])) !=
     83                GENERIC_EXIT_OK)
     84            {
     85                return err;
     86            }
     87        }
    7388        else
    7489        {
    7590            cerr << "Invalid argument: " << a.argv()[argpos] << endl <<
  • mythdvd/mtd/logging.cpp

     
    2525    QString logfile_name = gContext->GetSetting("DVDRipLocation");
    2626    if(logfile_name.length() < 1)
    2727    {
    28         cerr << "MTDLogger.o: You do not have a DVD rip directory set. Run Setup." << endl;
     28        VERBOSE(VB_IMPORTANT, "You do not have a DVD rip directory set."
     29                  " Run Setup.");
    2930        exit(0);
    3031    }   
    3132    logfile_name.append("/mtd.log");
     
    3435        logging_file.setName(logfile_name);
    3536        if(!logging_file.open(IO_WriteOnly))
    3637        {
    37             cerr << "MTDLogger.o: Problem opening logfile. Does this look openable to you: " << logfile_name << endl;
     38            VERBOSE(VB_IMPORTANT, QString("Problem opening logfile. Does this"
     39                                          "look openable to you: %1")
     40                                          .arg(logfile_name));
    3841            exit(0);
    3942        }
    4043    }
  • configure

     
    347347    fi
    348348fi
    349349
    350 # vcd support detection rutine does here
     350# vcd support detection routine does here
    351351
    352352if test "$exif" != "no" ; then
    353353    exif="no"