From fc93895624f6239cad7f207f7aa613d74863144a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 23 Jan 2015 11:03:33 -0600 Subject: [PATCH] FS-7173 #comment please test --- src/switch_core_codec.c | 15 +++++++++++++++ src/switch_ivr_async.c | 9 ++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/switch_core_codec.c b/src/switch_core_codec.c index 63e33ec2b6..ef22e7714f 100644 --- a/src/switch_core_codec.c +++ b/src/switch_core_codec.c @@ -319,6 +319,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_se if (session->read_impl.codec_id) { *impp = session->read_impl; return SWITCH_STATUS_SUCCESS; + } else { + memset(impp, 0, sizeof(*impp)); + impp->number_of_channels = 1; } return SWITCH_STATUS_FALSE; @@ -329,6 +332,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_co if (session->real_read_impl.codec_id) { *impp = session->real_read_impl; return SWITCH_STATUS_SUCCESS; + } else { + memset(impp, 0, sizeof(*impp)); + impp->number_of_channels = 1; } return SWITCH_STATUS_FALSE; @@ -339,6 +345,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_s if (session->write_impl.codec_id) { *impp = session->write_impl; return SWITCH_STATUS_SUCCESS; + } else { + memset(impp, 0, sizeof(*impp)); + impp->number_of_channels = 1; } return SWITCH_STATUS_FALSE; @@ -349,6 +358,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_c if (session->video_read_impl.codec_id) { *impp = session->video_read_impl; return SWITCH_STATUS_SUCCESS; + } else { + memset(impp, 0, sizeof(*impp)); + impp->number_of_channels = 1; } return SWITCH_STATUS_FALSE; @@ -359,6 +371,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_ if (session->video_write_impl.codec_id) { *impp = session->video_write_impl; return SWITCH_STATUS_SUCCESS; + } else { + memset(impp, 0, sizeof(*impp)); + impp->number_of_channels = 1; } return SWITCH_STATUS_FALSE; diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 792dba257b..60de27c73e 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1121,8 +1121,8 @@ static void *SWITCH_THREAD_FUNC recording_thread(switch_thread_t *thread, void * switch_channel_t *channel = switch_core_session_get_channel(session); struct record_helper *rh; switch_size_t bsize = SWITCH_RECOMMENDED_BUFFER_SIZE, samples = 0, inuse = 0; - unsigned char *data = switch_core_session_alloc(session, bsize); - int channels = switch_core_media_bug_test_flag(bug, SMBF_STEREO) ? 2 : rh->read_impl.number_of_channels; + unsigned char *data; + int channels = 1; if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) { return NULL; @@ -1132,6 +1132,9 @@ static void *SWITCH_THREAD_FUNC recording_thread(switch_thread_t *thread, void * switch_buffer_create_dynamic(&rh->thread_buffer, 1024 * 512, 1024 * 64, 0); rh->thread_ready = 1; + channels = switch_core_media_bug_test_flag(bug, SMBF_STEREO) ? 2 : rh->read_impl.number_of_channels; + data = switch_core_session_alloc(session, bsize); + while(switch_test_flag(rh->fh, SWITCH_FILE_OPEN)) { switch_mutex_lock(rh->buffer_mutex); inuse = switch_buffer_inuse(rh->thread_buffer); @@ -1144,7 +1147,7 @@ static void *SWITCH_THREAD_FUNC recording_thread(switch_thread_t *thread, void * switch_mutex_unlock(rh->buffer_mutex); break; } - + samples = switch_buffer_read(rh->thread_buffer, data, bsize) / 2 / channels; switch_mutex_unlock(rh->buffer_mutex);