]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4925 FS-4918
authorAnthony Minessale <anthm@freeswitch.org>
Sun, 9 Dec 2012 20:01:28 +0000 (14:01 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Sun, 9 Dec 2012 20:01:33 +0000 (14:01 -0600)
src/switch_core_codec.c
src/switch_core_io.c

index 1a529501ad8c399873e68c8ea948f4807afd2d11..f2529af174972272231508fb97959725ddc42d32 100644 (file)
@@ -756,8 +756,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_decode(switch_codec_t *codec,
        switch_assert(decoded_data != NULL);
 
        if (!codec->implementation || !switch_core_codec_ready(codec)) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
-               abort();
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decode Codec is not initialized!\n");
                return SWITCH_STATUS_NOT_INITALIZED;
        }
 
index ba4874d81fd965cfd783760209a583eff410959b..72345d6a040756352ff8d4e463e07be7516aec7c 100644 (file)
@@ -351,12 +351,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
                                                goto done;
                                        }
 
-                                       if (!switch_core_codec_ready(&session->bug_codec)) {
+                                       if (!switch_core_codec_ready(&session->bug_codec) && switch_core_codec_ready(read_frame->codec)) {
                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting BUG Codec %s:%d\n",
-                                                       read_frame->codec->implementation->iananame, read_frame->codec->implementation->ianacode);
+                                                                                 read_frame->codec->implementation->iananame, read_frame->codec->implementation->ianacode);
                                                switch_core_codec_copy(read_frame->codec, &session->bug_codec, NULL);
+                                               if (!switch_core_codec_ready(&session->bug_codec)) {
+                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Error setting BUG codec %s!\n", 
+                                                                                         switch_core_session_get_name(session), read_frame->codec->implementation->iananame);
+                                               }
+                                       }
+
+                                       if (switch_core_codec_ready(&session->bug_codec)) {
+                                               use_codec = &session->bug_codec;
                                        }
-                                       use_codec = &session->bug_codec;
                                        switch_thread_rwlock_unlock(session->bug_rwlock);
 
                                        switch_thread_rwlock_wrlock(session->bug_rwlock);
@@ -373,7 +380,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
                                        memset(session->raw_read_frame.data, 255, session->raw_read_frame.datalen);
                                        status = SWITCH_STATUS_SUCCESS;
                                } else {
-                                       switch_codec_t *codec = use_codec->implementation?use_codec:read_frame->codec;
+                                       switch_codec_t *codec = use_codec;
+
+                                       if (!switch_core_codec_ready(codec)) {
+                                               codec = read_frame->codec;
+                                       }
+
                                        switch_thread_rwlock_rdlock(session->bug_rwlock);
                                        codec->cur_frame = read_frame;
                                        session->read_codec->cur_frame = read_frame;