# HG changeset patch # User Eris Caffee # Date 1406064462 18000 # Node ID 03892700ff0dde8320b2b967876ddfbbb62d3c76 # Parent 4d04dc4239b4b922719e380ab9151ae460fdaaa2 Enabled file output drivers for format conversion. diff -r 4d04dc4239b4 -r 03892700ff0d playogg.c --- a/playogg.c Tue Jul 22 14:42:26 2014 -0500 +++ b/playogg.c Tue Jul 22 16:27:42 2014 -0500 @@ -18,6 +18,7 @@ char* device; char **files; int skip_next; + char *outfile; int ao_endian; int ao_device_id; ao_device *ao_device; @@ -47,6 +48,9 @@ } ok = sound_play_file( *file ); file++; + if ( options.outfile ) { + ok = 0; // Only convert one file + } } exit( EXIT_SUCCESS ); @@ -78,6 +82,7 @@ options.list_devices = 0; options.files = NULL; options.skip_next = 0; + options.outfile = NULL; options.ao_endian = 1; options.ao_device_id = -1; options.ao_device = NULL; @@ -107,13 +112,14 @@ void parse_command_line (int argc, char **argv ) { - static const char *short_options = "hd:l"; + static const char *short_options = "hd:lf:"; static const struct option long_options[] = { { "help", 0, 0, 'h' }, { "verbose", 0, 0, 0 }, { "debug", 0, 0, 0 }, { "device", 1, 0, 'd' }, { "list-devices", 0, 0, 'l' }, + { "outfile" , 1, 0, 'f' }, { NULL, 0, NULL, 0} }; @@ -145,13 +151,19 @@ break; + case 'f': + options.outfile = strdup( optarg ); + printf( "outfile is %s\n", options.outfile ); + break; + case 'h': show_help(); exit( EXIT_SUCCESS ); break; case 'd': - options.device = strdup(optarg); + options.device = strdup( optarg ); + printf( "device is %s\n", options.device ); break; case 'l': @@ -200,6 +212,9 @@ if ( options.device ) { free( options.device ); } + if ( options.outfile ) { + free( options.outfile ); + } } /******************************************************************************/ @@ -215,8 +230,9 @@ "-h --help Show these instructions.\n" " --verbose Print extra information.\n" " --debug Print debugging information.\n" - "-d --device Specify the output device to use.\n" + "-d --device= Specify the output device to use.\n" "-l --list-devices Print a list fo available output devices.\n" + "-f --outfile= Specify the name of the output file when using a file output device for format conversion.\n" "\n" ); } @@ -281,8 +297,17 @@ if ( AO_TYPE_LIVE == options.ao_driver_info->type ) { options.ao_device = ao_open_live( options.ao_device_id, &options.ao_format, NULL ); } + else if ( AO_TYPE_FILE == options.ao_driver_info->type ) { + if ( options.outfile ) { + options.ao_device = ao_open_file( options.ao_device_id, options.outfile, 1, &options.ao_format, NULL ); + } + else { + fprintf( stderr, "error: No output file name specified.\n" ); + return 0; + } + } else { - fprintf( stderr, "error: Only live output devices are supported.\n" ); + fprintf( stderr, "error: Unable to open output device.\n" ); return 0; }