Package: saytime Version: 1.0-20 Severity: wishlist I was having some trouble here with the alsa oss support (saytime was skipping/echoing), so I wrote up this *very* quick hack to add support for sox's alsa backend. This patch just adds a "-b BACKEND" option, i.e. -b oss, -b alsa, etc.
If you're interested, but you'd like me to change the patch somehow, just let me know, and if I have time, I'll rework it. Also, even if you aren't interested, you may want to consider adding the libsox-fmt-oss dependency. Without that, saytime had stopped working entirely on my system. Thanks diff --git a/debian/changelog b/debian/changelog index 38617fa..2d3aa7f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +saytime (1.0-21~) unstable; urgency=low + + * Add support for audio "backends", and add alsa support (in addition to + existing oss support). + + -- Rob Browning <[EMAIL PROTECTED]> Mon, 08 Oct 2007 23:25:19 -0700 + saytime (1.0-20) unstable; urgency=low * saytime.c: call sox with -q option to suppress text output (thanks to diff --git a/debian/control b/debian/control index ab9b245..7fa8efc 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.5.6 Package: saytime Architecture: any -Depends: ${shlibs:Depends}, sox (>= 12.17.9-1) +Depends: ${shlibs:Depends}, sox (>= 12.17.9-1), libsox-fmt-oss, libsox-fmt-alsa Description: speaks the current time through your sound card Say the current time through your sound card. Requires you have a sound output device available. diff --git a/debian/local/saytime.1 b/debian/local/saytime.1 index 18cc994..1149944 100644 --- a/debian/local/saytime.1 +++ b/debian/local/saytime.1 @@ -43,7 +43,10 @@ below). Display simple help. .TP .BI "\-o" " dev" -Output to alternate file (default /dev/audio). +Output to alternate file (default is /dev/audio). +.TP +.BI "\-b" " audio-backend" +Specify audio backend. Choose oss or alsa (default is oss). .SH FORMAT STRING A format string can be specified to control the time message. Valid format characters are: diff --git a/saytime.c b/saytime.c index d3bcb00..50ba9e9 100644 --- a/saytime.c +++ b/saytime.c @@ -93,6 +93,7 @@ It took about 10 minutes. #define PH_PM 36 int opt_to_stdout = 0; +char *opt_backend = "ossdsp"; char *opt_sound_device = NULL; char *opt_sound_dir = DEFAULT_SOUND_DIR; char *opt_time_format = NULL; @@ -114,9 +115,9 @@ char *argv[]; long clock; struct tm *t; #if defined TTEST - char *opt_string="v:r:co:d:f:h:H:N:C:"; + char *opt_string="v:b:r:co:d:f:h:H:N:C:"; #else - char *opt_string="v:r:co:d:f:h"; + char *opt_string="v:b:r:co:d:f:h"; #endif int op ; pid_t fpid; @@ -148,6 +149,8 @@ char *argv[]; break; case 'c' : opt_to_stdout = 1; break; + case 'b' : opt_backend = optarg; + break; case 'o' : opt_sound_device = optarg; break; case 'd' : opt_sound_dir = optarg; @@ -159,12 +162,18 @@ char *argv[]; } } + if ( strcmp("oss", opt_backend) == 0 ) + opt_backend = "ossdsp"; + else if ( ( strcmp("ossdsp", opt_backend) != 0 ) + && ( strcmp("alsa", opt_backend) != 0 )) { + printf("Specified unknown backend.\n"); + usage(); + } + if (opt_to_stdout && opt_sound_device != NULL) { printf("Specifying alternate device and stdout makes no sense.\n"); usage(); } - else if (opt_sound_device == NULL) - opt_sound_device = DEFAULT_SOUND_DEVICE; if (opt_time_format == NULL) opt_time_format = DEFAULT_TIME_FORMAT; @@ -234,6 +243,7 @@ usage( ) fprintf( stderr, " -h\tbrief help message\n" ); fprintf( stderr, " -o dev\tspecify audio device [%s]\n", DEFAULT_SOUND_DEVICE ); + fprintf( stderr, " -b backend\tspecify audio playback system [oss|alsa]\n", exit( 1 ); } @@ -683,10 +693,20 @@ sayfile( filename ) execl("/usr/bin/sox", "sox", "-q", "-v", opt_volume,"-t.ul", "-c", "1", pathname, "-t", "raw", "/dev/stdout", NULL); } - else + else if (strcmp("alsa", opt_backend) == 0) + { + if(opt_sound_device) + execl("/usr/bin/aplay", "aplay", "-q", "-f", "MU_LAW", pathname, + "-D", opt_sound_device, NULL); + else + execl("/usr/bin/aplay", "aplay", "-q", "-f", "MU_LAW", pathname, NULL); + } + else /* default to ossdsp */ { execl("/usr/bin/sox", "sox", "-q", "-v", opt_volume,"-t.ul", "-c", "1", - pathname, "-t", "ossdsp", opt_sound_device, NULL); + pathname, "-t", "ossdsp", + opt_sound_device ? opt_sound_device : DEFAULT_SOUND_DEVICE, + NULL); } fprintf(stderr, "execl failed\n"); exit(1); -- Rob Browning rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]