[xiph-cvs] cvs commit: vorbis-tools/ogg123 Makefile.am ao_interface.c buffer.h ogg123.1 ogg123.c ogg123.h

Stan Seibert volsung at xiph.org
Mon Aug 6 14:35:42 PDT 2001



volsung     01/08/06 14:35:41

  Modified:    ogg123   Tag: kcarnold_work Makefile.am ao_interface.c
                        buffer.h ogg123.1 ogg123.c ogg123.h
  Log:
  Merge mainline changes back into branch.

Revision  Changes    Path
No                   revision

No                   revision

1.14.2.1  +1 -1      vorbis-tools/ogg123/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Makefile.am,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- Makefile.am	2001/03/25 15:59:31	1.14
+++ Makefile.am	2001/08/06 21:35:40	1.14.2.1
@@ -5,7 +5,7 @@
 bin_PROGRAMS = ogg123
 docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION)
 doc_DATA = ogg123rc-example
-mandir = $(datadir)/man
+mandir = @MANDIR@
 man_MANS = ogg123.1
 
 INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ @AO_CFLAGS@

1.5.2.1   +4 -3      vorbis-tools/ogg123/ao_interface.c

Index: ao_interface.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ao_interface.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- ao_interface.c	2001/04/08 02:33:30	1.5
+++ ao_interface.c	2001/08/06 21:35:40	1.5.2.1
@@ -5,7 +5,7 @@
 #include "ogg123.h"
 
 devices_t *append_device(devices_t * devices_list, int driver_id,
-			 ao_option_t * options)
+			 ao_option * options, char *filename)
 {
     devices_t *head = devices_list;
 
@@ -19,6 +19,7 @@
     }
     devices_list->driver_id = driver_id;
     devices_list->options = options;
+    devices_list->filename = filename;
     devices_list->device = NULL;
     devices_list->next_device = NULL;
 
@@ -33,7 +34,7 @@
     }
 }
 
-int add_option(ao_option_t ** op_h, const char *optstring)
+int add_option(ao_option ** op_h, const char *optstring)
 {
     char *key, *value;
     int result;
@@ -93,7 +94,7 @@
     }
     
     if (device)
-      return ao_get_driver_id(device);
+      return ao_driver_id(device);
     
     return -1;
 }

1.2.2.4   +4 -2      vorbis-tools/ogg123/buffer.h

Index: buffer.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.h,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -r1.2.2.3 -r1.2.2.4
--- buffer.h	2001/06/24 01:24:56	1.2.2.3
+++ buffer.h	2001/08/06 21:35:40	1.2.2.4
@@ -4,13 +4,15 @@
 #define __BUFFER_H
 
 #include "ogg123.h"
-
 #include <sys/types.h>
 
+/* 4096 is the chunk size we request from libvorbis. */
+#define BUFFER_CHUNK_SIZE 4096
+
 typedef struct chunk_s
 {
   long len; /* Length of the chunk (for if we only got partial data) */
-  char data[4096]; /* Data. 4096 is the chunk size we request from libvorbis. */
+  char data[BUFFER_CHUNK_SIZE]; 
 } chunk_t;
 
 typedef struct buf_s

1.6.2.1   +289 -248  vorbis-tools/ogg123/ogg123.1

Index: ogg123.1
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.1,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- ogg123.1	2001/06/19 17:26:52	1.6
+++ ogg123.1	2001/08/06 21:35:40	1.6.2.1
@@ -1,248 +1,289 @@
-.\" Process this file with
-.\" groff -man -Tascii ogg123.1
-.\"
-.TH ogg123 1 "June 19, 2001" "" "Vorbis Tools"
-
-.SH NAME
-ogg123 \- plays Ogg Vorbis files
-
-.SH SYNOPSIS
-.B ogg123 
-[
-.B -vqzVh
-] [
-.B -k seconds 
-] [
-.B -d
-.I driver 
-[
-.B -o
-.I option:value
-] ]
-.I file
-.B ...
-|
-.I URL
-.B ...
-
-.SH DESCRIPTION
-.B ogg123
-reads Ogg Vorbis audio files and decodes them to the devices specified
-on the command line.  By default,
-.B ogg123
-writes to the standard sound device, but output can be sent to any
-number of devices.  Files can be read from the file system, or URLs
-can be streamed via HTTP.
-
-.SH OPTIONS
-.IP "-b n, --buffer n"
-Use a buffer of 'n' chunks (4096 bytes)
-.IP "-d device, --device device"
-Specify output device.  See
-.B DEVICES
-section for a list of devices.  Any number of devices may be specified.
-.IP "-h, --help"
-Show command help.
-.IP "-k n, --skip n"
-Skip the first 'n' seconds
-.IP "-o option:value, --device-option option:value"
-Assigns the option
-.I option
-to 
-.I value
-for the preceding device.  See
-.B DEVICES
-for a list of valid options for each device.  
-.IP "-q, --quiet"
-Quiet mode.  No messages are displayed.
-.IP "-V, --version"
-Display version information.
-.IP "-v, --verbose"
-Increase verbosity.
-.IP "-z, --shuffle"
-Play files in pseudo-random order.
-
-.SH DEVICES
-
-.B ogg123
-supports a variety of audio output devices through libao.  Only those
-devices supported by the target platform will be compiled in.
-
-.IP null
-Null driver.  All audio data is discarded.  (Note: Audio data is not
-written to 
-.B /dev/null
-!)  You could use this driver to test raw decoding speed without
-output overhead. 
-
-.IP oss
-Open Sound System driver for Linux and {Net,Free,Open}BSD.
-.RS
-Options:
-.RS 
-.IP dsp
-DSP device for soundcard.  Defaults to  
-.B /dev/dsp.
-.RE
-.RE
-
-.IP alsa
-Advanced Linux Sound Architecture.
-.RS
-Options:
-.RS
-.IP card
-Sound card number.  (Default = 0)
-.IP dev
-Device number on the sound card.  (Default = 0)
-.IP buf_size
-Override the default buffer size (in bytes).
-.RE
-.RE
-
-.IP esd
-Enlightened Sound Daemon.
-.RS
-Options:
-.RS
-.IP host
-The hostname where esd is running.  This can include a port number
-after a colon, as in "whizbang.com:555".  (Default = localhost)
-.RE
-.RE
-
-.IP solaris
-Solaris audio driver.  Note that this driver has
-.B not 
-been tested!
-
-.IP irix
-IRIX audio driver.  Note that this driver has
-.B not 
-been tested!
-
-.IP wav
-WAV file output.  Writes the sound data to disk in uncompressed form.
-If multiple files are played, all of them will be concatenated into
-the same WAV file.
-.RS
-Options:
-.RS
-.IP file
-Sets the output WAV file.  (Default = "output.wav")
-.RE
-.RE
-
-.SH EXAMPLES
-
-The
-.B ogg123
-command line is fairly flexible, perhaps confusingly so.  Here are
-some sample command lines and an explanation of what they do.
-.PP
-
-Play on the default soundcard:
-.RS
-.B ogg123 test.ogg
-.RE
-.PP
-
-Play using the OSS driver:
-.RS
-.B ogg123 -d oss test.ogg
-.RE
-.PP
-
-Pass the "dsp" option to the OSS driver: 
-.RS
-.B ogg123 -d oss -o dsp:/dev/mydsp 
-.RE
-.PP
-
-Use the ESD driver
-.RS
-.B ogg123 -d esd test.ogg
-.RE
-.PP
-
-Use the WAV driver with the default output file, "output.wav":
-.RS
-.B ogg123 -d wav test.ogg
-.RE
-.PP
-
-Listen to a file while you write it to a WAV file:
-.RS
-.B ogg123 -d oss -d wav -o file:test.wav test.ogg
-.RE
-.PP
-
-Note that options apply to the device declared to the left:
-.RS
-.B ogg123 -d oss -o dsp:/dev/mydsp -d wav -o file:test2.wav test.ogg
-.RE
-.PP
-
-Stress test your harddrive:
-.RS
-.B ogg123 -d oss -d wav -o file:1.wav -d wav -o file:2.wav -d wav -o file:3.wav -d wav -o file:4.wav -d wav -o file:5.wav  test.ogg
-.RE
-.PP
-
-Create an echo effect with esd and a slow computer:
-.RS
-.B ogg123 -d esd -d esd test.ogg
-.RE
-.PP
-
-.SH INTERRUPT
-You can abort
-.B ogg123
-at any time by pressing Ctrl-C.  If you are playing multiple
-files, this will stop the current file and begin playing the
-next one.  If you want to abort playing immediately instead
-of skipping to the next file, press Ctrl-C within the first
-second of the playback of a new file.
-.P
-Note that the result of pressing Ctrl-C might not be audible
-immediately, due to audio data buffering in the audio device.
-This delay is system dependent, but it is usually not more
-than one or two seconds.
-
-
-.SH FILES
-
-.TP
-/etc/ogg123rc
-Can be used to set the default output device for 
-.B ogg123.
-See the included file
-.B ogg123rc-example
-for an example.
-
-.TP
-~/.ogg123rc
-Per-user config file to override the system wide output device settings.
-.PP
-
-.SH BUGS
-
-The WAV driver does not interpret the file "-" as stdout. Note that
-there are issues with streaming WAV-format audio, so there is no way
-to fix this properly. Use the raw output driver if you need to use
-ogg123 in a pipe.
-
-.SH AUTHORS
-
-.TP
-Program Authors:
-.br
-Kenneth Arnold <kcarnold at yahoo.com>
-.br
-Stan Seibert <indigo at aztec.asu.edu>
-.br
-
-.TP
-Manpage Author:
-.br
-Stan Seibert <indigo at aztec.asu.edu>
+.\" Process this file with
+.\" groff -man -Tascii ogg123.1
+.\"
+.TH ogg123 1 "July 22, 2001" "" "Vorbis Tools"
+
+.SH NAME
+ogg123 \- plays Ogg Vorbis files
+
+.SH SYNOPSIS
+.B ogg123 
+[
+.B -vqzVh
+] [
+.B -k
+.I seconds 
+] [
+.B -b
+.I buffer_size 
+] [
+.B -d
+.I driver 
+[
+.B -o
+.I option:value
+] 
+[
+.B -f
+.I filename
+] ]
+.I file
+.B ...
+|
+.I URL
+.B ...
+
+.SH DESCRIPTION
+.B ogg123
+reads Ogg Vorbis audio files and decodes them to the devices specified
+on the command line.  By default,
+.B ogg123
+writes to the standard sound device, but output can be sent to any
+number of devices.  Files can be read from the file system, or URLs
+can be streamed via HTTP.
+
+.SH OPTIONS
+.IP "-b n, --buffer n"
+Use a buffer of approximately 'n' kilobytes.
+.IP "-d device, --device device"
+Specify output device.  See
+.B DEVICES
+section for a list of devices.  Any number of devices may be specified.
+.IP "-f filename, --file filename"
+Specify output file for file devices.  The filename "-" writes to standard
+out.  If the file already exists,
+.B ogg123
+will abort.
+.IP "-h, --help"
+Show command help.
+.IP "-k n, --skip n"
+Skip the first 'n' seconds
+.IP "-o option:value, --device-option option:value"
+Assigns the option
+.I option
+to 
+.I value
+for the preceding device.  See
+.B DEVICES
+for a list of valid options for each device.
+.IP "-q, --quiet"
+Quiet mode.  No messages are displayed.
+.IP "-V, --version"
+Display version information.
+.IP "-v, --verbose"
+Increase verbosity.
+.IP "-z, --shuffle"
+Play files in pseudo-random order.
+
+.SH DEVICES
+
+.B ogg123
+supports a variety of audio output devices through libao.  Only those
+devices supported by the target platform will be available.  The
+.B -f
+option may only be used with devices that write to files.
+
+.IP null
+Null driver.  All audio data is discarded.  (Note: Audio data is not
+written to 
+.B /dev/null
+!)  You could use this driver to test raw decoding speed without
+output overhead. 
+
+.IP oss
+Open Sound System driver for Linux and FreeBSD.
+.RS
+Options:
+.RS 
+.IP dsp
+DSP device for soundcard.  Defaults to  
+.B /dev/dsp.
+.RE
+.RE
+
+.IP sun
+Sun Audio driver for NetBSD, OpenBSD, and Solaris.
+.RS
+Options:
+.RS
+.IP dev
+Audio device for soundcard.  Defaults to  
+.B /dev/audio.
+.RE
+.RE
+
+.IP alsa
+Advanced Linux Sound Architecture.
+.RS
+Options:
+.RS
+.IP card
+Sound card number.  (Default = 0)
+.IP dev
+Device number on the sound card.  (Default = 0)
+.IP buf_size
+Override the default buffer size (in bytes).
+.RE
+.RE
+
+.IP irix
+IRIX audio driver.  Note that this driver has
+.B not 
+been tested!
+
+.IP arts
+aRts Sound Daemon.
+
+.IP esd
+Enlightened Sound Daemon.
+.RS
+Options:
+.RS
+.IP host
+The hostname where esd is running.  This can include a port number
+after a colon, as in "whizbang.com:555".  (Default = localhost)
+.RE
+.RE
+
+.IP au
+Sun audio file output.  Writes the audio samples in AU format.  The AU
+format supports writing to unseekable files, like standard out.  In
+such circumstances, the AU header will specify the sample format, but
+not the length of the recording.
+
+.IP raw
+Raw sample output.  Writes raw audio samples to a file.
+.RS
+Options:
+.RS
+.IP byteorder
+Choose big endian, little endian, or native byte order.  (Default = "native")
+.RE
+.RE
+
+.IP wav
+WAV file output.  Writes the sound data to disk in uncompressed form.
+If multiple files are played, all of them will be concatenated into
+the same WAV file.  WAV files cannot be written to unseekable files,
+such as standard out.  Use the AU format instead.
+
+
+.SH EXAMPLES
+
+The
+.B ogg123
+command line is fairly flexible, perhaps confusingly so.  Here are
+some sample command lines and an explanation of what they do.
+.PP
+
+Play on the default soundcard:
+.RS
+.B ogg123 test.ogg
+.RE
+.PP
+
+Play using the OSS driver:
+.RS
+.B ogg123 -d oss test.ogg
+.RE
+.PP
+
+Pass the "dsp" option to the OSS driver: 
+.RS
+.B ogg123 -d oss -o dsp:/dev/mydsp 
+.RE
+.PP
+
+Use the ESD driver
+.RS
+.B ogg123 -d esd test.ogg
+.RE
+.PP
+
+Use the WAV driver with the default output file, "output.wav":
+.RS
+.B ogg123 -d wav test.ogg
+.RE
+.PP
+
+Listen to a file while you write it to a WAV file:
+.RS
+.B ogg123 -d oss -d wav -f test.wav test.ogg
+.RE
+.PP
+
+Note that options apply to the device declared to the left:
+.RS
+.B ogg123 -d oss -o dsp:/dev/mydsp -d raw -f test2.raw -o byteorder:big test.ogg
+.RE
+.PP
+
+Stress test your harddrive:
+.RS
+.B ogg123 -d oss -d wav -f 1.wav -d wav -f 2.wav -d wav -f 3.wav -d wav -f 4.wav -d wav -f 5.wav  test.ogg
+.RE
+.PP
+
+Create an echo effect with esd and a slow computer:
+.RS
+.B ogg123 -d esd -d esd test.ogg
+.RE
+.PP
+
+.SH INTERRUPT
+You can abort
+.B ogg123
+at any time by pressing Ctrl-C.  If you are playing multiple
+files, this will stop the current file and begin playing the
+next one.  If you want to abort playing immediately instead
+of skipping to the next file, press Ctrl-C within the first
+second of the playback of a new file.
+.P
+Note that the result of pressing Ctrl-C might not be audible
+immediately, due to audio data buffering in the audio device.
+This delay is system dependent, but it is usually not more
+than one or two seconds.
+
+.SH NOTES
+
+The use of
+.B /etc/ogg123rc
+and
+.B ~/.ogg123rc
+has been deprecated in favor of the configuration system provided by
+libao.
+
+.SH FILES
+
+.TP
+/etc/libao.conf
+Can be used to set the default output device for all libao programs.
+
+.TP
+~/.libao
+Per-user config file to override the system wide output device settings.
+.PP
+
+.SH BUGS
+
+Note that there are issues with streaming WAV-format audio, so there
+is no way to fix this properly. Use the raw or au output driver if you
+need to use ogg123 in a pipe.
+
+.SH SEE ALSO
+.BR libao.conf(5)
+
+.SH AUTHORS
+
+.TP
+Program Authors:
+.br
+Kenneth Arnold <kcarnold at yahoo.com>
+.br
+Stan Seibert <indigo at aztec.asu.edu>
+.br
+
+.TP
+Manpage Author:
+.br
+Stan Seibert <indigo at aztec.asu.edu>

1.39.2.6  +92 -25    vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.5
retrieving revision 1.39.2.6
diff -u -r1.39.2.5 -r1.39.2.6
--- ogg123.c	2001/06/24 01:24:56	1.39.2.5
+++ ogg123.c	2001/08/06 21:35:40	1.39.2.6
@@ -14,12 +14,13 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.39.2.5 2001/06/24 01:24:56 kcarnold Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.6 2001/08/06 21:35:40 volsung Exp $
 
  ********************************************************************/
 
 /* FIXME : That was a messy message. Fix it. */
 
+#include <sys/types.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -34,8 +35,9 @@
 
 #include "ogg123.h"
 
-char convbuffer[4096];		/* take 8k out of the data segment, not the stack */
-int convsize = 4096;
+/* take buffer out of the data segment, not the stack */
+char convbuffer[BUFFER_CHUNK_SIZE];
+int convsize = BUFFER_CHUNK_SIZE;
 buf_t * buffer = NULL;
 
 static char skipfile_requested;
@@ -63,6 +65,7 @@
     {"help", no_argument, 0, 'h'},
     {"version", no_argument, 0, 'V'},
     {"device", required_argument, 0, 'd'},
+    {"file", required_argument, 0, 'f'},
     {"skip", required_argument, 0, 'k'},
     {"device-option", required_argument, 0, 'o'},
     {"verbose", no_argument, 0, 'v'},
@@ -78,8 +81,9 @@
 
 void usage(void)
 {
-    FILE *o;
-    o = stderr;
+    FILE *o = stderr;
+    int i, driver_count;
+    ao_info **devices = ao_driver_info_list(&driver_count);
 
     fprintf(o,
             "Ogg123 from " PACKAGE " " VERSION "\n"
@@ -88,14 +92,22 @@
             "  -h, --help     this help\n"
             "  -V, --version  display Ogg123 version\n"
             "  -d, --device=d uses 'd' as an output device\n"
-	    "      Possible devices are (some may not be compiled):\n"
-	    "      null (output nothing), oss (for Linux and *BSD),\n"
-	    "      irix, solaris, wav (write to a .WAV file)\n"
+	    "      Possible devices are:\n"
+	    "        ");
+
+    for(i = 0; i < driver_count; i++)
+      fprintf(o,"%s ",devices[i]->short_name);
+
+    fprintf(o,"\n");
+
+    fprintf(o,
+	    "  -f, --file=filename  Set the output filename for a previously\n"
+	    "      specified file device (with -d).\n"
             "  -k n, --skip n  Skip the first 'n' seconds\n"
             "  -o, --device-option=k:v passes special option k with value\n"
             "      v to previously specified device (with -d).  See\n"
             "      man page for more info.\n"
-	    "  -b n, --buffer n  use a buffer of 'n' chunks (4096 bytes)\n"
+	    "  -b n, --buffer n  use a buffer of approximately 'n' kilobytes\n"
             "  -v, --verbose  display progress and other useful stuff\n"
             "  -q, --quiet    don't display anything (no title)\n"
             "  -z, --shuffle  shuffle play\n"
@@ -110,12 +122,14 @@
     ogg123_options_t opt;
     int ret;
     int option_index = 1;
-    ao_option_t *temp_options = NULL;
-    ao_option_t ** current_options = &temp_options;
+    ao_option *temp_options = NULL;
+    ao_option ** current_options = &temp_options;
+    ao_info *info;
     int temp_driver_id = -1;
     devices_t *current;
 
     memset (&opt, 0, sizeof(opt));
+
     opt.delay = 1;
     opt.nth = 1;
     opt.ntimes = 1;
@@ -124,7 +138,7 @@
     signal (SIGINT, signal_quit);
     ao_initialize();
 
-    while (-1 != (ret = getopt_long(argc, argv, "b:d:hl:k:o:p:qvVx:y:z",
+    while (-1 != (ret = getopt_long(argc, argv, "b:d:f:hl:k:o:p:qvVx:y:z",
                                     long_options, &option_index))) {
         switch (ret) {
         case 0:
@@ -132,19 +146,31 @@
                     "Internal error: long option given when none expected.\n");
             exit(1);
         case 'b':
-	  opt.buffer_size = atoi (optarg);
+	  opt.buffer_size = atoi(optarg) / (BUFFER_CHUNK_SIZE / 1024);
           break;
         case 'd':
-	    temp_driver_id = ao_get_driver_id(optarg);
+	    temp_driver_id = ao_driver_id(optarg);
             if (temp_driver_id < 0) {
                 fprintf(stderr, "No such device %s.\n", optarg);
                 exit(1);
             }
-	    current = append_device(opt.outdevices, temp_driver_id, NULL);
+	    current = append_device(opt.outdevices, temp_driver_id, 
+				    NULL, NULL);
             if(opt.outdevices == NULL)
                     opt.outdevices = current;
             current_options = &current->options;
             break;
+	case 'f':
+	    info = ao_driver_info(temp_driver_id);
+	    if (info->type == AO_TYPE_FILE) {
+	        free(current->filename);
+		current->filename = strdup(optarg);
+	    } else {
+	        fprintf(stderr, "Driver %s is not a file output driver.\n",
+			info->short_name);
+	        exit(1);
+	    }
+	    break;
         case 'k':
             opt.seekpos = atof(optarg);
             break;
@@ -196,14 +222,15 @@
     if (temp_driver_id < 0) {
         temp_driver_id = get_default_device();
         if(temp_driver_id < 0) {
-		temp_driver_id = ao_get_driver_id(NULL);
+		temp_driver_id = ao_default_driver_id();
         }
         if (temp_driver_id < 0) {
             fprintf(stderr,
                     "Could not load default driver and no ~/.ogg123rc found. Exiting.\n");
             exit(1);
         }
-	opt.outdevices = append_device(opt.outdevices, temp_driver_id, temp_options);
+	opt.outdevices = append_device(opt.outdevices, temp_driver_id, 
+				       temp_options, NULL);
     }
 
     if (optind == argc) {
@@ -585,7 +612,8 @@
 {
   static int prevrate=0, prevchan=0;
   devices_t *current;
-  
+  ao_sample_format format;
+
   if(prevrate == rate && prevchan == channels)
     return 0;
   
@@ -602,13 +630,15 @@
             current = current->next_device;
           }
         }
-  
-  prevrate = rate;
-  prevchan = channels;
   
+  format.rate = prevrate = rate;
+  format.channels = prevchan = channels;
+  format.bits = 16;
+  format.byte_format = AO_FMT_NATIVE;
+
   current = opt->outdevices;
   while (current != NULL) {
-    ao_info_t *info = ao_get_driver_info(current->driver_id);
+    ao_info *info = ao_driver_info(current->driver_id);
     
     if (opt->verbose > 0) {
       fprintf(stderr, "Device:   %s\n", info->name);
@@ -617,10 +647,47 @@
       fprintf(stderr, "\n");	
     }
     
-    current->device = ao_open(current->driver_id, 16, rate, channels,
-			      current->options);
+    if (current->filename == NULL)
+      current->device = ao_open_live(current->driver_id, &format,
+				     current->options);
+    else
+      current->device = ao_open_file(current->driver_id, current->filename,
+				     0, &format, current->options);
+
     if (current->device == NULL) {
-      fprintf(stderr, "Error opening device.\n");
+      switch (errno) {
+      case AO_ENODRIVER:
+	fprintf(stderr, "Error: No device not available.\n");
+	break;
+      case AO_ENOTLIVE:
+	fprintf(stderr, "Error: %s requires an output filename to be specified with -f.\n", info->short_name);
+	break;
+      case AO_EBADOPTION:
+	fprintf(stderr, "Error: Unsupported option value to %s device.\n",
+		info->short_name);
+	break;
+      case AO_EOPENDEVICE:
+	fprintf(stderr, "Error: Cannot open device %s.\n",
+		info->short_name);
+	break;
+      case AO_EFAIL:
+	fprintf(stderr, "Error: Device failure.\n");
+	break;
+      case AO_ENOTFILE:
+	fprintf(stderr, "Error: An output file cannot be given for %s device.\n", info->short_name);
+	break;
+      case AO_EOPENFILE:
+	fprintf(stderr, "Error: Cannot open file %s for writing.\n",
+		current->filename);
+	break;
+      case AO_EFILEEXISTS:
+	fprintf(stderr, "Error: File %s already exists.\n", current->filename);
+	break;
+      default:
+	fprintf(stderr, "Error: This error should never happen.  Panic!\n");
+	break;
+      }
+	
       return -1;
     }
     current = current->next_device;

1.7.2.6   +5 -4      vorbis-tools/ogg123/ogg123.h

Index: ogg123.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.h,v
retrieving revision 1.7.2.5
retrieving revision 1.7.2.6
diff -u -r1.7.2.5 -r1.7.2.6
--- ogg123.h	2001/06/24 01:24:56	1.7.2.5
+++ ogg123.h	2001/08/06 21:35:40	1.7.2.6
@@ -16,8 +16,9 @@
 /* For facilitating output to multiple devices */
 typedef struct devices_s {
   int driver_id;
-  ao_device_t *device;
-  ao_option_t *options;
+  ao_device *device;
+  ao_option *options;
+  char *filename;
   struct devices_s *next_device;
 } devices_t;
 
@@ -42,10 +43,10 @@
 #include "buffer.h"
 
 devices_t *append_device(devices_t * devices_list, int driver_id,
-                         ao_option_t * options);
+                         ao_option * options, char *filename);
 void devices_write(void *ptr, size_t size, devices_t * d);
 void usage(void);
-int add_option(ao_option_t ** op_h, const char *optstring);
+int add_option(ao_option ** op_h, const char *optstring);
 int get_default_device(void);
 void play_file(ogg123_options_t opt);
 int get_tcp_socket(void); /* Will be going soon. */

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list