simpleaudio: do not crash on stereo input file

Complain about non-mono input audio files instead of crashing.
Thanks goblin@github for the report.

GitHub: fixes kamalmostafa/minimodem#1
This commit is contained in:
Kamal Mostafa 2014-03-18 15:01:05 -07:00
parent 3c227b516a
commit 3c5ac8819d
1 changed files with 7 additions and 0 deletions

View File

@ -111,6 +111,13 @@ simpleaudio_open_stream(
backend_device, sa_stream_direction, sa_format,
rate, channels, app_name, stream_name);
if ( sa->channels != channels ) {
fprintf(stderr, "%s: input stream must be %u-channel (not %u)\n",
stream_name, channels, sa->channels);
simpleaudio_close(sa);
return 0;
}
if ( ok ) {
assert( sa->backend_framesize == sa->channels * sa->samplesize );
return sa;