diff options
author | Maarten Bosmans <mkbosmans@gmail.com> | 2011-06-27 01:19:07 +0200 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2011-06-27 09:59:56 +0100 |
commit | aa7bc322e25a461a14e922f71103a7ca607482f8 (patch) | |
tree | 20e186c6486d72271679d0b51038a6e167b776e1 /src/utils | |
parent | ad1e0431fb42086351ccc25b3af47e84604895a1 (diff) |
parecord: Automatically detect file format from extension
And fix a small bug in pa_sndfile_format_from_string.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/pacat.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 749593ea..323f071b 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -926,8 +926,6 @@ int main(int argc, char *argv[]) { break; case ARG_FILE_FORMAT: - raw = FALSE; - if (optarg) { if ((file_format = pa_sndfile_format_from_string(optarg)) < 0) { pa_log(_("Unknown file format %s."), optarg); @@ -986,13 +984,19 @@ int main(int argc, char *argv[]) { goto quit; } - /* Transparently upgrade classic .wav to wavex for multichannel audio */ if (file_format <= 0) { - if ((sample_spec.channels == 2 && (!channel_map_set || (channel_map.map[0] == PA_CHANNEL_POSITION_LEFT && - channel_map.map[1] == PA_CHANNEL_POSITION_RIGHT))) || - (sample_spec.channels == 1 && (!channel_map_set || (channel_map.map[0] == PA_CHANNEL_POSITION_MONO)))) + char *extension; + if (filename && (extension = strrchr(filename, '.'))) + file_format = pa_sndfile_format_from_string(extension+1); + if (file_format <= 0) file_format = SF_FORMAT_WAV; - else + /* Transparently upgrade classic .wav to wavex for multichannel audio */ + if (file_format == SF_FORMAT_WAV && + (sample_spec.channels > 2 || + (channel_map_set && + !(sample_spec.channels == 1 && channel_map.map[0] == PA_CHANNEL_POSITION_MONO) && + !(sample_spec.channels == 2 && channel_map.map[0] == PA_CHANNEL_POSITION_LEFT + && channel_map.map[1] == PA_CHANNEL_POSITION_RIGHT)))) file_format = SF_FORMAT_WAVEX; } |