Mercurial > oggdemo
changeset 1:03892700ff0d
Enabled file output drivers for format conversion.
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Tue, 22 Jul 2014 16:27:42 -0500 |
parents | 4d04dc4239b4 |
children | 3617357a1b90 |
files | playogg.c |
diffstat | 1 files changed, 29 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- a/playogg.c Tue Jul 22 14:42:26 2014 -0500 1.2 +++ b/playogg.c Tue Jul 22 16:27:42 2014 -0500 1.3 @@ -18,6 +18,7 @@ 1.4 char* device; 1.5 char **files; 1.6 int skip_next; 1.7 + char *outfile; 1.8 int ao_endian; 1.9 int ao_device_id; 1.10 ao_device *ao_device; 1.11 @@ -47,6 +48,9 @@ 1.12 } 1.13 ok = sound_play_file( *file ); 1.14 file++; 1.15 + if ( options.outfile ) { 1.16 + ok = 0; // Only convert one file 1.17 + } 1.18 } 1.19 1.20 exit( EXIT_SUCCESS ); 1.21 @@ -78,6 +82,7 @@ 1.22 options.list_devices = 0; 1.23 options.files = NULL; 1.24 options.skip_next = 0; 1.25 + options.outfile = NULL; 1.26 options.ao_endian = 1; 1.27 options.ao_device_id = -1; 1.28 options.ao_device = NULL; 1.29 @@ -107,13 +112,14 @@ 1.30 void 1.31 parse_command_line (int argc, char **argv ) { 1.32 1.33 - static const char *short_options = "hd:l"; 1.34 + static const char *short_options = "hd:lf:"; 1.35 static const struct option long_options[] = { 1.36 { "help", 0, 0, 'h' }, 1.37 { "verbose", 0, 0, 0 }, 1.38 { "debug", 0, 0, 0 }, 1.39 { "device", 1, 0, 'd' }, 1.40 { "list-devices", 0, 0, 'l' }, 1.41 + { "outfile" , 1, 0, 'f' }, 1.42 { NULL, 0, NULL, 0} 1.43 }; 1.44 1.45 @@ -145,13 +151,19 @@ 1.46 1.47 break; 1.48 1.49 + case 'f': 1.50 + options.outfile = strdup( optarg ); 1.51 + printf( "outfile is %s\n", options.outfile ); 1.52 + break; 1.53 + 1.54 case 'h': 1.55 show_help(); 1.56 exit( EXIT_SUCCESS ); 1.57 break; 1.58 1.59 case 'd': 1.60 - options.device = strdup(optarg); 1.61 + options.device = strdup( optarg ); 1.62 + printf( "device is %s\n", options.device ); 1.63 break; 1.64 1.65 case 'l': 1.66 @@ -200,6 +212,9 @@ 1.67 if ( options.device ) { 1.68 free( options.device ); 1.69 } 1.70 + if ( options.outfile ) { 1.71 + free( options.outfile ); 1.72 + } 1.73 } 1.74 1.75 /******************************************************************************/ 1.76 @@ -215,8 +230,9 @@ 1.77 "-h --help Show these instructions.\n" 1.78 " --verbose Print extra information.\n" 1.79 " --debug Print debugging information.\n" 1.80 - "-d --device Specify the output device to use.\n" 1.81 + "-d --device= Specify the output device to use.\n" 1.82 "-l --list-devices Print a list fo available output devices.\n" 1.83 + "-f --outfile= Specify the name of the output file when using a file output device for format conversion.\n" 1.84 "\n" 1.85 ); 1.86 } 1.87 @@ -281,8 +297,17 @@ 1.88 if ( AO_TYPE_LIVE == options.ao_driver_info->type ) { 1.89 options.ao_device = ao_open_live( options.ao_device_id, &options.ao_format, NULL ); 1.90 } 1.91 + else if ( AO_TYPE_FILE == options.ao_driver_info->type ) { 1.92 + if ( options.outfile ) { 1.93 + options.ao_device = ao_open_file( options.ao_device_id, options.outfile, 1, &options.ao_format, NULL ); 1.94 + } 1.95 + else { 1.96 + fprintf( stderr, "error: No output file name specified.\n" ); 1.97 + return 0; 1.98 + } 1.99 + } 1.100 else { 1.101 - fprintf( stderr, "error: Only live output devices are supported.\n" ); 1.102 + fprintf( stderr, "error: Unable to open output device.\n" ); 1.103 return 0; 1.104 } 1.105