Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Patch to cdparanoia
diff --git a/interface/cdda_interface.h b/interface/cdda_interface.h
index 4731c82..912cf4d 100644
--- a/interface/cdda_interface.h
+++ b/interface/cdda_interface.h
@@ -80,7 +80,7 @@ typedef struct cdrom_drive{
/* functions specific to particular drives/interfaces */
int (*enable_cdda) (struct cdrom_drive *d, int onoff);
- int (*read_toc) (struct cdrom_drive *d);
+ int (*read_toc) (struct cdrom_drive *d, int quiet);
long (*read_audio) (struct cdrom_drive *d, void *p, long begin,
long sectors);
int (*set_speed) (struct cdrom_drive *d, int speed);
@@ -140,7 +140,7 @@ extern char *cdda_messages(cdrom_drive *d);
extern char *cdda_errors(cdrom_drive *d);
extern int cdda_close(cdrom_drive *d);
-extern int cdda_open(cdrom_drive *d);
+extern int cdda_open(cdrom_drive *d, int quiet);
extern long cdda_read(cdrom_drive *d, void *buffer,
long beginsector, long sectors);
extern long cdda_read_timed(cdrom_drive *d, void *buffer,
diff --git a/interface/interface.c b/interface/interface.c
index 3adaf6a..ba6d32e 100644
--- a/interface/interface.c
+++ b/interface/interface.c
@@ -54,7 +54,7 @@ int cdda_close(cdrom_drive *d){
}
/* finish initializing the drive! */
-int cdda_open(cdrom_drive *d){
+int cdda_open(cdrom_drive *d, int quiet){
int ret;
if(d->opened)return(0);
@@ -72,7 +72,7 @@ int cdda_open(cdrom_drive *d){
break;
#else
case IOKIT_INTERFACE:
- if((ret=osx_init_drive(d)))
+ if((ret=osx_init_drive(d,quiet)))
return(ret);
break;
#endif
diff --git a/interface/osx_interface.c b/interface/osx_interface.c
index f672316..d8b543f 100644
--- a/interface/osx_interface.c
+++ b/interface/osx_interface.c
@@ -105,7 +105,7 @@ io_object_t osx_default_device(cdrom_drive *d) {
return io;
}
-int osx_read_toc(cdrom_drive *d) {
+int osx_read_toc(cdrom_drive *d, int quiet) {
kern_return_t ret;
char *devname;
CFRange range;
@@ -163,10 +163,12 @@ int osx_read_toc(cdrom_drive *d) {
if (track_num == 0xa2) {
leadout = i;
}
- fprintf(stderr,
- "track_num = %d start sector %d msf: %d,%d,%d\n",
- track_num, start_sector,
- msf.minute, msf.second, msf.frame);
+ if (!quiet) {
+ fprintf(stderr,
+ "track_num = %d start sector %d msf: %d,%d,%d\n",
+ track_num, start_sector,
+ msf.minute, msf.second, msf.frame);
+ }
if (track_num > 99 || track_num < 1) {
// e.g.:
// track_num = 160 start sector 4350 msf: 1,0,0
@@ -189,7 +191,7 @@ int osx_read_toc(cdrom_drive *d) {
return d->tracks;
}
-int osx_init_drive(cdrom_drive *d) {
+int osx_init_drive(cdrom_drive *d, int quiet) {
d->io = osx_default_device(d);
d->enable_cdda = osx_enable_cdda;
@@ -211,7 +213,7 @@ int osx_init_drive(cdrom_drive *d) {
return -1;
}
- d->read_toc(d);
+ d->read_toc(d, quiet);
d->nsectors = 32;
d->opened = 1;
diff --git a/interface/osx_interface.h b/interface/osx_interface.h
index b4a18a4..955aefd 100644
--- a/interface/osx_interface.h
+++ b/interface/osx_interface.h
@@ -20,8 +20,8 @@ int osx_enumerate_devices(cdrom_drive *d,
int (*device_found)(cdrom_drive *, io_object_t, void *),
void *data);
io_object_t osx_default_device(cdrom_drive *d);
-int osx_read_toc(cdrom_drive *d);
-int osx_init_drive(cdrom_drive *d);
+int osx_read_toc(cdrom_drive *d, int quiet);
+int osx_init_drive(cdrom_drive *d, int quiet);
int osx_set_speed(cdrom_drive *d, int speed);
int osx_enable_cdda(cdrom_drive *d, int enable);
long osx_read_audio(cdrom_drive *d, void *buf, long begin, long sectors);
diff --git a/main.c b/main.c
index ebb2e82..5c4b701 100644
--- a/main.c
+++ b/main.c
@@ -211,6 +211,7 @@ VERSION"\n"
" read behavior. Implies -vQL\n\n"
" -v --verbose : extra verbose operation\n"
" -q --quiet : quiet operation\n"
+" -P --show-progress-bar : show progress bar (even when quiet)\n"
" -e --stderr-progress : force output of progress information to\n"
" stderr (for wrapper scripts)\n"
" -l --log-summary [<file>] : save result summary to file, default\n"
@@ -404,7 +405,7 @@ static void callback(long inpos, int function){
}
}
- if(!quiet){
+ if(progress_bar){
long test;
osector=inpos;
sector=inpos/CD_FRAMEWORDS;
@@ -604,7 +605,7 @@ static void callback(long inpos, int function){
memset(dispcache,' ',graph);
}
-const char *optstring = "escCn:o:O:d:g:k:S:prRwafvqVQhZz::YXWBi:Tt:l::L::A";
+const char *optstring = "escCn:o:O:d:g:k:S:PprRwafvqVQhZz::YXWBi:Tt:l::L::A";
struct option options [] = {
{"stderr-progress",no_argument,NULL,'e'},
@@ -629,6 +630,7 @@ struct option options [] = {
{"batch",no_argument,NULL,'B'},
{"verbose",no_argument,NULL,'v'},
{"quiet",no_argument,NULL,'q'},
+ {"show-progress-bar",no_argument,NULL,'P'},
{"version",no_argument,NULL,'V'},
{"query",no_argument,NULL,'Q'},
{"help",no_argument,NULL,'h'},
@@ -771,6 +773,7 @@ int main(int argc,char *argv[]){
case 'v':
verbose=CDDA_MESSAGE_PRINTIT;
quiet=0;
+ progress_bar=1;
break;
case 's':
search=1;
@@ -778,6 +781,10 @@ int main(int argc,char *argv[]){
case 'q':
verbose=CDDA_MESSAGE_FORGETIT;
quiet=1;
+ progress_bar=0;
+ break;
+ case 'P':
+ progress_bar=1;
break;
case 'e':
callscript=1;
@@ -1022,7 +1029,7 @@ int main(int argc,char *argv[]){
"ignoring autosense",force_cdrom_overlap);
}
- switch(cdda_open(d)){
+ switch(cdda_open(d, quiet)){
case -2:case -3:case -4:case -5:
report("\nUnable to open disc. Is there an audio CD in the drive?");
exit(1);
diff --git a/report.c b/report.c
index be07abe..48b012c 100644
--- a/report.c
+++ b/report.c
@@ -2,5 +2,6 @@
#include "interface/cdda_interface.h"
int quiet=0;
+int progress_bar=1;
int verbose=CDDA_MESSAGE_FORGETIT;
FILE *reportfile=NULL;
diff --git a/report.h b/report.h
index ab490b5..5ed207c 100644
--- a/report.h
+++ b/report.h
@@ -1,5 +1,6 @@
extern int verbose;
extern int quiet;
+extern int progress_bar;
extern FILE *reportfile;
#define report(...) {if(!quiet){fprintf(stderr, __VA_ARGS__);fputc('\n',stderr);} \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment