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

Stan Seibert volsung at xiph.org
Fri Aug 3 19:57:02 PDT 2001



volsung     01/08/03 19:57:02

  Modified:    ogg123   ao_interface.c ogg123.1 ogg123.c ogg123.h
  Log:
  Merged ogg123 branch to support new libao API.

Revision  Changes    Path
1.6       +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.6
diff -u -r1.5 -r1.6
--- ao_interface.c	2001/04/08 02:33:30	1.5
+++ ao_interface.c	2001/08/04 02:57:01	1.6
@@ -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.8       +43 -29    vorbis-tools/ogg123/ogg123.1

Index: ogg123.1
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.1,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ogg123.1	2001/07/06 22:11:37	1.7
+++ ogg123.1	2001/08/04 02:57:01	1.8
@@ -1,7 +1,7 @@
 .\" Process this file with
 .\" groff -man -Tascii ogg123.1
 .\"
-.TH ogg123 1 "June 19, 2001" "" "Vorbis Tools"
+.TH ogg123 1 "July 22, 2001" "" "Vorbis Tools"
 
 .SH NAME
 ogg123 \- plays Ogg Vorbis files
@@ -18,6 +18,10 @@
 [
 .B -o
 .I option:value
+] 
+[
+.B -f
+.I filename
 ] ]
 .I file
 .B ...
@@ -41,6 +45,11 @@
 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"
@@ -52,7 +61,7 @@
 .I value
 for the preceding device.  See
 .B DEVICES
-for a list of valid options for each device.  
+for a list of valid options for each device.
 .IP "-q, --quiet"
 Quiet mode.  No messages are displayed.
 .IP "-V, --version"
@@ -66,7 +75,9 @@
 
 .B ogg123
 supports a variety of audio output devices through libao.  Only those
-devices supported by the target platform will be compiled in.
+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
@@ -130,15 +141,17 @@
 .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 file
-Sets the output file.  (Default = "output.raw")
-.RE
-.RS
 .IP byteorder
 Choose big endian, little endian, or native byte order.  (Default = "native")
 .RE
@@ -147,15 +160,10 @@
 .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
+the same WAV file.  WAV files cannot be written to unseekable files,
+such as standard out.  Use the AU format instead.
 
+
 .SH EXAMPLES
 
 The
@@ -196,19 +204,19 @@
 
 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
+.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 wav -o file:test2.wav test.ogg
+.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 -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
+.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
 
@@ -232,28 +240,34 @@
 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/ogg123rc
-Can be used to set the default output device for 
-.B ogg123.
-See the included file
-.B ogg123rc-example
-for an example.
+/etc/libao.conf
+Can be used to set the default output device for all libao programs.
 
 .TP
-~/.ogg123rc
+~/.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.
 
-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 SEE ALSO
+.BR libao.conf(5)
 
 .SH AUTHORS
 

1.41      +87 -25    vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- ogg123.c	2001/07/06 22:11:37	1.40
+++ ogg123.c	2001/08/04 02:57:01	1.41
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.40 2001/07/06 22:11:37 volsung Exp $
+ last mod: $Id: ogg123.c,v 1.41 2001/08/04 02:57:01 volsung Exp $
 
  ********************************************************************/
 
@@ -63,6 +63,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'},
@@ -75,8 +76,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"
@@ -85,11 +87,17 @@
             "  -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 FreeBSD),\n"
-	    "      alsa (for Linux), sun (for NetBSD, OpenBSD, Solaris),\n"
-	    "      irix, arts (aRts sound daemon), esd (ESounD daemon),\n"
-	    "      raw (write to a file), 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"
@@ -109,11 +117,12 @@
     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;
-
+    devices_t *current;
+    
     opt.read_file = NULL;
     opt.shuffle = 0;
     opt.verbose = 0;
@@ -126,7 +135,7 @@
 
     ao_initialize();
 
-    while (-1 != (ret = getopt_long(argc, argv, "b:d:hl:k:o:qvVz",
+    while (-1 != (ret = getopt_long(argc, argv, "b:d:f:hl:k:o:qvVz",
                                     long_options, &option_index))) {
         switch (ret) {
         case 0:
@@ -137,16 +146,28 @@
           opt.buffer_size = atoi (optarg);
           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;
@@ -186,14 +207,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) {
@@ -544,7 +566,8 @@
 {
   static int prevrate=0, prevchan=0;
   devices_t *current;
-  
+  ao_sample_format format;
+
   if(prevrate == rate && prevchan == channels)
     return 0;
   
@@ -561,13 +584,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);
@@ -576,10 +601,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.8       +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
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ogg123.h	2001/06/19 17:15:32	1.7
+++ ogg123.h	2001/08/04 02:57:01	1.8
@@ -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;
 
@@ -38,10 +39,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