;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; $Id: patch-sra-ripper,v 1.1 2005/10/31 09:35:23 sra Exp $ ;; ;; Patch to add a [ -r ripper ] argument to autocd. ;; See FreeBSD ports: ;; ;; audio/abcde (2.1.19) ;; audio/autocd (3.02.12b) ;; ;; If you apply this patch to autocd and give autocd the ;; name of a program as the argument to -r, autocd will ;; invoke that program with the name of the cd device ;; as an argument. ;; ;; I find this a handy way to run abcde automatically, ;; YMMV. Remember to use -N with abcde.... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Index: auto_cd.c --- auto_cd.c.~1~ Fri Apr 16 11:46:42 2004 +++ auto_cd.c Mon Oct 31 03:25:13 2005 @@ -66,7 +66,7 @@ typedef struct { void *next; void *prev; - char *device, *mnt_point, *mnt_fstype, *mnt_opts; + char *device, *mnt_point, *mnt_fstype, *mnt_opts, *ripper; int dev, ejected, disabled; #ifdef HAVE_SYS_CDRIO_H int locked_speed; @@ -478,6 +478,24 @@ } int +autocd_set_ripper(const char *ripper) +{ + device_t *d; + + if(!(d = (device_t *) mq_gettail(devices))) { + logger("Strange call autocd_set_ripper()\n"); + return -1; + } + + if(d->ripper) + free(d->ripper); + + d->ripper = strdup(ripper); + + return 0; +} + +int autocd_initsocket() { struct sockaddr_un unix_addr; @@ -620,6 +638,8 @@ void autocd_doinsert(device_t *device) { + int is_data; + device->read_toc_entry.data_len = (device->toc_header.ending_track + 1) * sizeof(struct cd_toc_entry); @@ -638,14 +658,16 @@ (device->first_audio_track < device->last_audio_track); device->last_audio_track--); - if(device->toc_entry[device->first_audio_track - 1].control & 4) { - if(device->mnt_point) { + is_data = device->toc_entry[device->first_audio_track - 1].control & 4; + + if(is_data ? device->mnt_point : device->ripper) { int status; autocd_closedev(device); switch(fork()) { case 0: + if(is_data) { execl(MOUNT, MOUNT, "-o", device->mnt_opts, "-t", device->mnt_fstype, device->device, device->mnt_point, NULL); @@ -649,10 +671,11 @@ execl(MOUNT, MOUNT, "-o", device->mnt_opts, "-t", device->mnt_fstype, device->device, device->mnt_point, NULL); - - logger("Can't run "MOUNT": %s\n", strerror(errno)); - + } else { + execl(device->ripper, device->ripper, device->device, NULL); + logger("Can't run %s: %s\n", device->ripper, strerror(errno)); + } exit(EX_OSERR); case -1: @@ -664,13 +687,12 @@ } autocd_opendev(device); - } - } else { - if(device->sub_channel_info.header.audio_status != + } else if(!is_data && + device->sub_channel_info.header.audio_status != CD_AS_PLAY_IN_PROGRESS) { autocd_playtracks(device, - device->first_audio_track, device->last_audio_track); - } + device->first_audio_track, + device->last_audio_track); } device->cdid = dbprog_discid(device); Index: auto_cd.h --- auto_cd.h.~1~ Fri Apr 16 11:46:42 2004 +++ auto_cd.h Mon Oct 31 02:10:02 2005 @@ -34,6 +34,7 @@ extern int autocd_set_mnt_point(const char *); extern int autocd_set_mnt_fstype(const char *); extern int autocd_set_mnt_opts(const char *); +extern int autocd_set_ripper(const char *); extern void autocd_setsocketpath(const char *); extern int autocd_setsocketowner(const char *); Index: autocd.c --- autocd.c.~1~ Fri Apr 16 11:46:42 2004 +++ autocd.c Mon Oct 31 02:31:03 2005 @@ -44,13 +44,14 @@ { logger("%s\n\ Usage: %s [-hc] [-d device] [-p mountpoint] [-f fstype] [-o options]\n\ -\t[-s socket] [-u user] [-g group] [-m mode]\n\ +\t[-s socket] [-u user] [-g group] [-m mode] [-r ripper]\n\ -h\t\t- this help\n\ -c\t\t- don't close devices while playing is in progress\n\ -d device\t- device for monitoring by autocd\n\ -p mountpoint\t- mount point for device\n\ -f fstype\t- file system type for device\n\ -o options\t- mount options for device\n\ + -r ripper\t- ripper for device\n\ -s socket\t- path to a control socket\n\ -u user\t- socket owner\n\ -g group\t- socket group\n\ @@ -67,7 +68,7 @@ autocd_init(); - while((ch = getopt(argc, argv, "hcd:p:f:o:s:u:g:m:")) != -1) { + while((ch = getopt(argc, argv, "hcd:p:f:o:s:u:g:m:r:")) != -1) { switch(ch) { case 'c': autocd_noclose(); @@ -85,6 +86,7 @@ case 'p': case 'f': case 'o': + case 'r': if(devices_selected) { if(!last_device) { logger("Last device is not usable. -%c ignored\n", ch); @@ -109,6 +111,10 @@ case 'o': autocd_set_mnt_opts(optarg); + break; + + case 'r': + autocd_set_ripper(optarg); break; }