From 3c5ac8819d7dd123f4d71afa3061018a0b2da114 Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Tue, 18 Mar 2014 15:01:05 -0700 Subject: [PATCH] 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 --- src/simpleaudio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/simpleaudio.c b/src/simpleaudio.c index ccbfc78..fe7c8b4 100644 --- a/src/simpleaudio.c +++ b/src/simpleaudio.c @@ -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;