[xiph-cvs] cvs commit: vorbis-tools/ogg123 ao_interface.c ogg123.c ogg123.h
Stan Seibert
volsung at xiph.org
Sun Jul 22 14:25:22 PDT 2001
volsung 01/07/22 14:25:22
Modified: ogg123 Tag: volsung_20010721 ao_interface.c ogg123.c
ogg123.h
Log:
Initial patch to ogg123 to use the volsung_20010721 branch libao.
Revision Changes Path
No revision
No revision
1.5.4.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.4.1
diff -u -r1.5 -r1.5.4.1
--- ao_interface.c 2001/04/08 02:33:30 1.5
+++ ao_interface.c 2001/07/22 21:25:21 1.5.4.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.40.2.1 +40 -17 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.40.2.1
diff -u -r1.40 -r1.40.2.1
--- ogg123.c 2001/07/06 22:11:37 1.40
+++ ogg123.c 2001/07/22 21:25:21 1.40.2.1
@@ -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.40.2.1 2001/07/22 21:25:21 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'},
@@ -109,11 +110,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 +128,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 +139,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 = ¤t->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 +200,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 +559,8 @@
{
static int prevrate=0, prevchan=0;
devices_t *current;
-
+ ao_sample_format format;
+
if(prevrate == rate && prevchan == channels)
return 0;
@@ -561,13 +577,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,8 +594,13 @@
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");
return -1;
1.7.4.1 +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.7.4.1
diff -u -r1.7 -r1.7.4.1
--- ogg123.h 2001/06/19 17:15:32 1.7
+++ ogg123.h 2001/07/22 21:25:21 1.7.4.1
@@ -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