mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
sndfile-convert.c : Add -override-sample-rate command line option.
This commit is contained in:
parent
c0c0e51abe
commit
319a7ffd59
@ -1,3 +1,8 @@
|
||||
2006-12-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* examples/sndfile-convert.c
|
||||
Add -override-sample-rate command line option.
|
||||
|
||||
2006-11-19 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* tests/misc_test.c
|
||||
|
@ -109,7 +109,12 @@ print_usage (char *progname)
|
||||
|
||||
int k ;
|
||||
|
||||
printf ("\nUsage : %s [encoding] <input file> <output file>\n", progname) ;
|
||||
printf ("\nUsage : %s [options] [encoding] <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" where [option] may be:\n\n"
|
||||
" -override-sample-rate=X : force sample rate of input to X\n\n"
|
||||
) ;
|
||||
|
||||
puts ("\n"
|
||||
" where [encoding] may be one of the following:\n\n"
|
||||
" -pcms8 : force the output to signed 8 bit pcm\n"
|
||||
@ -150,6 +155,7 @@ main (int argc, char * argv [])
|
||||
SNDFILE *infile = NULL, *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, outfilemajor, outfileminor = 0, infileminor ;
|
||||
int override_sample_rate = 0 ; /* assume no sample rate override. */
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
@ -238,6 +244,14 @@ main (int argc, char * argv [])
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (! strcmp (argv [k], "-override-sample-rate="))
|
||||
{ char *ptr ;
|
||||
|
||||
ptr = argv [k] + strlen ("-override-sample-rate=") ;
|
||||
override_sample_rate = atoi (ptr) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
printf ("Error : Not able to decode argunment '%s'.\n", argv [k]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
@ -248,6 +262,10 @@ main (int argc, char * argv [])
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Update sample rate if forced to something else. */
|
||||
if (override_sample_rate)
|
||||
sfinfo.samplerate=override_sample_rate ;
|
||||
|
||||
infileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user