From: Eric B. <eri...@ya...> - 2004-04-05 04:02:27
|
This patch adds a "discid" command that prints the CDDB query string for the CD in the drive, and it adds --eject as an option to the "unlock" command. These are both pretty simple and I've been using them for over a year myself. It would be great if they get added to cdrdao's CVS mainline so other folks can use them, plus it would save me from having to apply them myself! cvs server: Diffing . cvs server: Diffing contrib cvs server: Diffing contrib/mp32dao cvs server: Diffing contrib/mp32dao/docs cvs server: Diffing contrib/psxcopy-0.2 cvs server: Diffing contrib/wav2dao cvs server: Diffing dao Index: dao/main.cc =================================================================== RCS file: /cvsroot/cdrdao/cdrdao/dao/main.cc,v retrieving revision 1.43 diff -c -r1.43 main.cc *** dao/main.cc 23 Mar 2004 18:46:07 -0000 1.43 --- dao/main.cc 5 Apr 2004 03:29:53 -0000 *************** *** 53,59 **** enum Command { UNKNOWN, SHOW_TOC, SHOW_DATA, READ_TEST, SIMULATE, WRITE, READ_TOC, DISK_INFO, READ_CD, TOC_INFO, TOC_SIZE, BLANK, ! SCAN_BUS, UNLOCK, COPY_CD, READ_CDDB, MSINFO, DRIVE_INFO }; static const char *PRGNAME = NULL; static const char *TOC_FILE = NULL; --- 53,60 ---- enum Command { UNKNOWN, SHOW_TOC, SHOW_DATA, READ_TEST, SIMULATE, WRITE, READ_TOC, DISK_INFO, READ_CD, TOC_INFO, TOC_SIZE, BLANK, ! SCAN_BUS, UNLOCK, COPY_CD, READ_CDDB, MSINFO, DRIVE_INFO, ! DISCID }; static const char *PRGNAME = NULL; static const char *TOC_FILE = NULL; *************** *** 189,194 **** --- 190,196 ---- " show-data - prints out audio data and exits\n" " read-test - reads all audio files and exits\n" " disk-info - shows information about inserted medium\n" + " discid - prints out CDDB query\n" " msinfo - shows multi session info, output is suited for scripts\n" " unlock - unlock drive after failed writing\n" " blank - blank a CD-RW\n" *************** *** 292,297 **** --- 294,310 ---- SCSI_DEVICE); break; + case DISCID: + message(0, "\nUsage: %s discid [options]", PRGNAME); + message(0, + "options:\n" + " --device [path:]<x,y,z> - sets SCSI device of CD-writer\n" + " (default: %s)\n" + " --driver <id> - force usage of specified driver\n" + " -v # - sets verbose level\n", + SCSI_DEVICE); + break; + case READ_CD: message(0, "\nUsage: %s read-cd [options] toc-file", PRGNAME); message(0, *************** *** 349,354 **** --- 362,368 ---- " (default: %s)\n" " --driver <id> - force usage of specified driver\n" " --reload - reload the disk if necessary for writing\n" + " --eject - ejects cd after unlocking\n" " -v # - sets verbose level\n", SCSI_DEVICE); break; *************** *** 481,487 **** } } ! if (cmd == BLANK || cmd == DISK_INFO || cmd == MSINFO || cmd == UNLOCK) { if ((sval = SETTINGS->getString(SET_WRITE_DRIVER)) != NULL) { DRIVER_ID = strdupCC(sval); } --- 495,502 ---- } } ! if (cmd == BLANK || cmd == DISK_INFO || cmd == MSINFO || cmd == UNLOCK || ! cmd == DISCID) { if ((sval = SETTINGS->getString(SET_WRITE_DRIVER)) != NULL) { DRIVER_ID = strdupCC(sval); } *************** *** 546,552 **** SETTINGS->set(SET_READ_PARANOIA_MODE, PARANOIA_MODE); } ! if (cmd == BLANK || cmd == DISK_INFO || cmd == MSINFO || cmd == UNLOCK) { if (DRIVER_ID != NULL) SETTINGS->set(SET_WRITE_DRIVER, DRIVER_ID); --- 561,568 ---- SETTINGS->set(SET_READ_PARANOIA_MODE, PARANOIA_MODE); } ! if (cmd == BLANK || cmd == DISK_INFO || cmd == MSINFO || cmd == UNLOCK || ! cmd == DISCID) { if (DRIVER_ID != NULL) SETTINGS->set(SET_WRITE_DRIVER, DRIVER_ID); *************** *** 597,602 **** --- 613,621 ---- else if (strcmp(*argv, "disk-info") == 0) { COMMAND = DISK_INFO; } + else if (strcmp(*argv, "discid") == 0) { + COMMAND = DISCID; + } else if (strcmp(*argv, "read-cd") == 0) { COMMAND = READ_CD; } *************** *** 963,968 **** --- 982,988 ---- if (COMMAND != DISK_INFO && COMMAND != BLANK && COMMAND != SCAN_BUS && COMMAND != UNLOCK && COMMAND != COPY_CD && COMMAND != MSINFO && + COMMAND != DISCID && COMMAND != DRIVE_INFO) { if (argc < 1) { message(-2, "Missing toc-file."); *************** *** 1018,1024 **** &options); // if no driver is selected, yet, try to select a read driver for // disk-info ! if (id == NULL && (cmd == DISK_INFO || cmd == MSINFO)) id = CdrDriver::selectDriver(0, scsiIf->vendor(), scsiIf->product(), &options); // Still no driver, try to autodetect one --- 1038,1044 ---- &options); // if no driver is selected, yet, try to select a read driver for // disk-info ! if (id == NULL && (cmd == DISK_INFO || cmd == MSINFO || cmd == DISCID)) id = CdrDriver::selectDriver(0, scsiIf->vendor(), scsiIf->product(), &options); // Still no driver, try to autodetect one *************** *** 1435,1440 **** --- 1455,1467 ---- return 2; } + static void printCddbQuery(Toc *toc) + { + Cddb cddb(toc); + + cddb.printDbQuery(); + } + static int readCddb(Toc *toc) { int err = 0; *************** *** 2012,2017 **** --- 2039,2045 ---- if (COMMAND != READ_TOC && COMMAND != DISK_INFO && COMMAND != READ_CD && COMMAND != BLANK && COMMAND != SCAN_BUS && COMMAND != UNLOCK && + COMMAND != DISCID && COMMAND != COPY_CD && COMMAND != MSINFO && COMMAND != DRIVE_INFO) { toc = Toc::read(TOC_FILE); *************** *** 2035,2046 **** if (COMMAND == SIMULATE || COMMAND == WRITE || COMMAND == READ_TOC || COMMAND == DISK_INFO || COMMAND == READ_CD || COMMAND == BLANK || COMMAND == UNLOCK || COMMAND == COPY_CD || COMMAND == MSINFO || COMMAND == DRIVE_INFO) { cdr = setupDevice(COMMAND, SCSI_DEVICE, DRIVER_ID, /* init device? */ (COMMAND == UNLOCK) ? 0 : 1, /* check for ready status? */ ! (COMMAND == BLANK || COMMAND == DRIVE_INFO) ? 0 : 1, /* reset status of medium if not empty? */ (COMMAND == SIMULATE || COMMAND == WRITE) ? 1 : 0, REMOTE_MODE, RELOAD); --- 2063,2076 ---- if (COMMAND == SIMULATE || COMMAND == WRITE || COMMAND == READ_TOC || COMMAND == DISK_INFO || COMMAND == READ_CD || COMMAND == BLANK || COMMAND == UNLOCK || COMMAND == COPY_CD || COMMAND == MSINFO || + COMMAND == DISCID || COMMAND == DRIVE_INFO) { cdr = setupDevice(COMMAND, SCSI_DEVICE, DRIVER_ID, /* init device? */ (COMMAND == UNLOCK) ? 0 : 1, /* check for ready status? */ ! (COMMAND == BLANK || COMMAND == DRIVE_INFO || ! COMMAND == DISCID) ? 0 : 1, /* reset status of medium if not empty? */ (COMMAND == SIMULATE || COMMAND == WRITE) ? 1 : 0, REMOTE_MODE, RELOAD); *************** *** 2140,2145 **** --- 2170,2202 ---- showDiskInfo(di); break; + case DISCID: + if (di->valid.empty && di->empty) { + message(-2, "Inserted disk is empty."); + exitCode = 1; goto fail; + } + cdr->subChanReadMode(READ_SUBCHAN_MODE); + cdr->rawDataReading(READ_RAW); + cdr->fastTocReading(1); + cdr->taoSource(TAO_SOURCE); + if (TAO_SOURCE_ADJUST >= 0) + cdr->taoSourceAdjust(TAO_SOURCE_ADJUST); + + cdr->force(FORCE); + + if ((toc = cdr->readDiskToc(SESSION, + (DATA_FILENAME == NULL) ? + "data.wav" : DATA_FILENAME)) == NULL) { + cdr->rezeroUnit(0); + exitCode = 1; goto fail; + } + else { + cdr->rezeroUnit(0); + + printCddbQuery(toc); + } + break; + case MSINFO: switch (showMultiSessionInfo(di)) { case 0: *************** *** 2496,2504 **** --- 2553,2565 ---- message(1, "Trying to unlock drive..."); cdr->abortDao(); + if (cdr->preventMediumRemoval(0) != 0) { exitCode = 1; goto fail; } + + if (EJECT) + cdr->loadUnload(1); break; case UNKNOWN: cvs server: Diffing paranoia cvs server: Diffing specs cvs server: Diffing testtocs cvs server: Diffing trackdb Index: trackdb/Cddb.cc =================================================================== RCS file: /cvsroot/cdrdao/cdrdao/trackdb/Cddb.cc,v retrieving revision 1.8 diff -c -r1.8 Cddb.cc *** trackdb/Cddb.cc 3 Sep 2001 17:37:42 -0000 1.8 --- trackdb/Cddb.cc 5 Apr 2004 03:29:55 -0000 *************** *** 553,558 **** --- 553,588 ---- return 0; } + /* Print query for current toc + */ + void Cddb::printDbQuery() + { + const char *cddbId; + int ntracks; + const Track *t; + Msf start, end; + long diskLength; + + ntracks = toc_->nofTracks(); + + cddbId = calcCddbId(); + + printf("%s ", cddbId); + + printf("%d ", ntracks); + + TrackIterator itr(toc_); + + for (t = itr.first(start, end); t != NULL; t = itr.next(start, end)) { + long trackStart = start.lba() + 150; + + printf("%ld ", trackStart); + } + + diskLength = toc_->length().min() * 60 + toc_->length().sec() + 2; + printf("%ld\n", diskLength); + } + /* Queries for entries that match the current 'toc_'. * 'results' will be filled with a list of matching diskIds/category/title * triples. 'results' will be NULL if no matching entry is found. Index: trackdb/Cddb.h =================================================================== RCS file: /cvsroot/cdrdao/cdrdao/trackdb/Cddb.h,v retrieving revision 1.2 diff -c -r1.2 Cddb.h *** trackdb/Cddb.h 6 Aug 2000 13:11:35 -0000 1.2 --- trackdb/Cddb.h 5 Apr 2004 03:29:55 -0000 *************** *** 61,66 **** --- 61,68 ---- int readDb(const char *category, const char *diskId, CddbEntry **); int addAsCdText(Toc *toc); + + void printDbQuery(); private: struct ServerList { cvs server: Diffing utils cvs server: Diffing xdao cvs server: Diffing xdao/glade cvs server: Diffing xdao/stock |
From: Denis L. <den...@ya...> - 2004-04-05 20:46:32
|
I had some trouble applying your HTML-ized patch, but i eventually had it all worked out. The only concern i have is that we're adding a brand new command, but all it does is print the CDDB query which will appear as something truly obscure for the uninitiated. How about actually doing the CDDB query and printing it out in human-readable form, with maybe printing the query string in verbose mode only, or what about modifying the existing 'read-cddb' command and make its toc-file argument optional (cddb result is printed to stdout) ? -denis --- Eric Benson <eri...@ya...> wrote: > This patch adds a "discid" command that prints the CDDB query string > for > the CD in the drive, and it adds --eject as an option to the "unlock" > > command. These are both pretty simple and I've been using them for > over > a year myself. It would be great if they get added to cdrdao's CVS > mainline so other folks can use them, plus it would save me from > having > to apply them myself! |
From: Eric B. <eri...@ya...> - 2004-04-05 21:26:07
|
Denis Leroy wrote: >I had some trouble applying your HTML-ized patch, but i eventually had >it all worked out. > > Sorry about that. I guess I should have used a text file attachment instead of just cutting and pasting. >The only concern i have is that we're adding a brand new command, but >all it does is print the CDDB query which will appear as something >truly obscure for the uninitiated. How about actually doing the CDDB >query and printing it out in human-readable form, with maybe printing >the query string in verbose mode only, or what about modifying the >existing 'read-cddb' command and make its toc-file argument optional >(cddb result is printed to stdout) ? > > Well, as you may have guessed, I only use this command in the context of a script where I pick up the output and submit it to a CDDB server. I wanted to keep it as simple as possible. The usage message says "prints out CDDB query". How about just changing it to "prints out CDDB query for audio CD and exits". If anyone tries the command, they will see an obscure sequence of numbers, but it is quite harmless. If they don't know what a CDDB query is, it isn't hard to find out. Even a Google search for "discid" or "cddb query" will reveal enough to explain it. The reason I added these commands to cdrdao was to simplify a CD ripping and cataloging application I wrote. Before, I had three programs that had to access the CD-ROM drive for different tasks: discid, cdrdao and eject. By absorbing discid and eject into cdrdao I was able to simplify maintenance and porting. >-denis > >--- Eric Benson <eri...@ya...> wrote: > > >>This patch adds a "discid" command that prints the CDDB query string >>for >>the CD in the drive, and it adds --eject as an option to the "unlock" >> >>command. These are both pretty simple and I've been using them for >>over >>a year myself. It would be great if they get added to cdrdao's CVS >>mainline so other folks can use them, plus it would save me from >>having >>to apply them myself! >> >> > > > |
From: Denis L. <den...@ya...> - 2004-04-07 06:46:02
|
I've checked in your patch, but i made the discid command actually do the CDDB query and print out the result. If you run it with the '--query' option, it does exactly what your version did and only prints the CDDB query. I thought this would be a good compromise. thanks for the patch, keep'em coming :-) -denis --- Eric Benson <eri...@ya...> wrote: > >>This patch adds a "discid" command that prints the CDDB query > string > >>for > >>the CD in the drive, and it adds --eject as an option to the > "unlock" > >> > >>command. These are both pretty simple and I've been using them for > >>over > >>a year myself. It would be great if they get added to cdrdao's CVS > >>mainline so other folks can use them, plus it would save me from > >>having to apply them myself! |
From: Eric B. <eri...@ya...> - 2004-04-07 17:04:55
|
That's fine, but I think --query is a confusing option name. Does --query mean "perform the query and print the result" or does it mean "don't perform the query, just print what you would have submitted"? It's the latter, but the option name doesn't convey that distinction. Also, this functionality overlaps closely with the "read-cddb" command. If you are going to actually query a CDDB server, this command should also have the --cddb-servers and --cddb-timeout options as well. Then it starts getting complicated. Perhaps it would make more sense to absorb this functionality into the "read-cddb" command, perhaps by using "-" as the --cddb-directory option to mean "print the result rather than write it to a file". Then perhaps "discid" should be renamed "cddb-query-string" and revert to its old simple behavior. Denis Leroy wrote: >I've checked in your patch, but i made the discid command actually do >the CDDB query and print out the result. If you run it with the >'--query' option, it does exactly what your version did and only prints >the CDDB query. I thought this would be a good compromise. > >thanks for the patch, keep'em coming :-) >-denis > >--- Eric Benson <eri...@ya...> wrote: > > >>>>This patch adds a "discid" command that prints the CDDB query >>>> >>>> >>string >> >> >>>>for >>>>the CD in the drive, and it adds --eject as an option to the >>>> >>>> >>"unlock" >> >> >>>>command. These are both pretty simple and I've been using them for >>>>over >>>>a year myself. It would be great if they get added to cdrdao's CVS >>>>mainline so other folks can use them, plus it would save me from >>>>having to apply them myself! >>>> >>>> > > > >------------------------------------------------------- >This SF.Net email is sponsored by: IBM Linux Tutorials >Free Linux tutorial presented by Daniel Robbins, President and CEO of >GenToo technologies. Learn everything from fundamentals to system >administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >_______________________________________________ >Cdrdao-devel mailing list >Cdr...@li... >https://lists.sourceforge.net/lists/listinfo/cdrdao-devel > > > |