]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FSCORE-517
authorBrian West <brian@freeswitch.org>
Fri, 18 Dec 2009 23:19:53 +0000 (23:19 +0000)
committerBrian West <brian@freeswitch.org>
Fri, 18 Dec 2009 23:19:53 +0000 (23:19 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16003 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_module_interfaces.h
src/switch_core_codec.c
src/switch_ivr_play_say.c

index 5b2d2baab42c5d2c3d73ae4ab0bf7ce9d9d49caa..aa3cde37e65a575ce73cd8243053a5dc0cc8e763 100644 (file)
@@ -583,6 +583,7 @@ struct switch_codec {
        void *private_info;
        switch_payload_t agreed_pt;
        switch_mutex_t *mutex;
+       struct switch_codec *next;
 };
 
 /*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
index 5efac5b8176de0fbf6f91106ccddcec692e9142c..b17dcd28fa28cffca90d8e2270f43e7709a3e8a8 100644 (file)
@@ -97,7 +97,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
        switch_channel_t *channel = switch_core_session_get_channel(session);
        char tmp[30];
        switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+       
        switch_mutex_lock(session->codec_read_mutex);
 
        if (codec && (!codec->implementation || !switch_core_codec_ready(codec))) {
@@ -109,6 +109,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
                        session->read_codec = session->real_read_codec = codec;
                        session->read_impl = *codec->implementation;
                } else {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Push codec %s:%d\n",
+                                                         switch_channel_get_name(session->channel), codec->implementation->iananame, codec->implementation->ianacode);
+                       codec->next = session->read_codec;
                        session->read_codec = codec;
                        session->read_impl = *codec->implementation;
                }
@@ -116,7 +119,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
                if (session->read_codec == session->real_read_codec) {
                        goto end;
                }
-               if (session->real_read_codec) {
+               
+               if (session->read_codec->next) {
+                       switch_codec_t *old = session->read_codec;
+                       session->read_codec = session->read_codec->next;
+                       session->read_impl = *session->read_codec->implementation;
+                       old->next = NULL;
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Restore previous codec %s:%d.\n",
+                                                         switch_channel_get_name(session->channel), 
+                                                         session->read_codec->implementation->iananame, session->read_codec->implementation->ianacode);
+                       
+               } else if (session->real_read_codec) {
                        session->read_codec = session->real_read_codec;
                        session->read_impl = *session->real_read_codec->implementation;
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Restore original codec.\n");
index c08fe92a32aa1803b5b2beb8c9afc859774cc6c4..a22821a95a3e12f857abea179e1fcf099f8c80a5 100644 (file)
@@ -1081,7 +1081,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                                                                  read_impl.number_of_channels,
                                                                  read_impl.actual_samples_per_second,
                                                                  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
-                       switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+                       switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
                        status = SWITCH_STATUS_NOTFOUND;
                        continue;
                }
@@ -1159,7 +1159,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
                                                                          "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
                                        switch_core_file_close(fh);
-                                       switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+                                       switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
                                        status = SWITCH_STATUS_GENERR;
                                        continue;
                                }
@@ -1179,7 +1179,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Setup timer failed!\n");
                                switch_core_codec_destroy(&codec);
                                switch_core_file_close(fh);
-                               switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+                               switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
                                status = SWITCH_STATUS_GENERR;
                                continue;
                        }
@@ -1476,7 +1476,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 
        switch_safe_free(abuf);
 
-       switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
+       switch_core_session_reset(session, SWITCH_FALSE, SWITCH_FALSE);
        return status;
 }
 
@@ -1513,7 +1513,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_
                                                                  read_impl.number_of_channels,
                                                                  read_impl.actual_samples_per_second,
                                                                  SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
-                       switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+                       switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
                        return SWITCH_STATUS_NOTFOUND;
                }
                switch_zmalloc(abuf, SWITCH_RECOMMENDED_BUFFER_SIZE);
@@ -2100,7 +2100,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
 
        timer_name = switch_channel_get_variable(channel, "timer_name");
 
-       switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
+       switch_core_session_reset(session, SWITCH_FALSE, SWITCH_FALSE);
        read_codec = switch_core_session_get_read_codec(session);
 
        rate = read_impl.actual_samples_per_second;