From 227af62a4a4edbc789e5ac645742d2c2bbea1483 Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Mon, 8 Apr 2013 09:51:14 -0400 Subject: [PATCH] FS-5280 --resolve bitch n bail --- .../endpoints/mod_portaudio/mod_portaudio.c | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 10685f3adf..115de3d616 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -2409,6 +2409,7 @@ static audio_stream_t *create_audio_stream(int indev, int outdev) return NULL; } } + inputParameters.device = indev; if (indev != -1) { inputParameters.channelCount = 1; @@ -2417,10 +2418,13 @@ static audio_stream_t *create_audio_stream(int indev, int outdev) inputParameters.hostApiSpecificStreamInfo = NULL; } outputParameters.device = outdev; - outputParameters.channelCount = 1; - outputParameters.sampleFormat = SAMPLE_TYPE; - outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; - outputParameters.hostApiSpecificStreamInfo = NULL; + + if (outdev != -1) { + outputParameters.channelCount = 1; + outputParameters.sampleFormat = SAMPLE_TYPE; + outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; + outputParameters.hostApiSpecificStreamInfo = NULL; + } err = open_audio_stream(&(stream->stream), &inputParameters, &outputParameters); if (err != paNoError) { @@ -2444,13 +2448,19 @@ static audio_stream_t *create_audio_stream(int indev, int outdev) audio_stream_t *get_audio_stream(int indev, int outdev) { - audio_stream_t *stream; + audio_stream_t *stream = NULL; if (outdev == -1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid output audio device\n"); + return NULL; + } + if (indev == -1) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid input audio device\n"); + return NULL; } if (create_codecs(0) != SWITCH_STATUS_SUCCESS) { return NULL; } + stream = find_audio_stream(indev, outdev, 0); if (stream != NULL) { return stream;