]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7173 #comment please test
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 23 Jan 2015 17:03:33 +0000 (11:03 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 23 Jan 2015 23:03:30 +0000 (17:03 -0600)
src/switch_core_codec.c
src/switch_ivr_async.c

index 63e33ec2b6104305ed421be43c8a0ea4d616c864..ef22e7714ffcc76ac7a6fbba58bc4dc5c5b51745 100644 (file)
@@ -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;
index 792dba257b09f2a64d7b5ed87f8c39dd03227ae7..60de27c73edb52c7660e88e2328ce5ece536bd37 100644 (file)
@@ -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);