]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
move media reset code a little deeper so it does not interrupt media when there is...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 13 Nov 2013 23:18:59 +0000 (04:18 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 13 Nov 2013 23:18:59 +0000 (04:18 +0500)
src/switch_core_media.c

index eee0affc86df128df168ba20f00321160997c235..b03b90aae8e3db0b8a0b50fe9bbcf40c00ed6f4c 100644 (file)
@@ -1469,29 +1469,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
                                                engine->read_impl.samples_per_packet;
                                }
                        }
-
                        
-                       if (session->read_resampler) {
-                               switch_mutex_lock(session->resample_mutex);
-                               switch_resample_destroy(&session->read_resampler);
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
-                               switch_mutex_unlock(session->resample_mutex);
-                       }
-
-                       if (session->write_resampler) {
-                               switch_mutex_lock(session->resample_mutex);
-                               switch_resample_destroy(&session->write_resampler);
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating write resampler\n");
-                               switch_mutex_unlock(session->resample_mutex);
-                       }
-
-                       switch_core_session_reset(session, 0, 0);
-
-
                        engine->check_frames = 0;
                        engine->last_ts = 0;
 
-                       switch_channel_audio_sync(session->channel);
                        do_cng = 1;
                }
 
@@ -1995,6 +1976,22 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_
                        (uint32_t) a_engine->read_impl.microseconds_per_packet / 1000 != a_engine->cur_payload_map->codec_ms ||
                        a_engine->read_impl.samples_per_second != a_engine->cur_payload_map->rm_rate ) {
                        
+                       if (session->read_resampler) {
+                               switch_mutex_lock(session->resample_mutex);
+                               switch_resample_destroy(&session->read_resampler);
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating read resampler\n");
+                               switch_mutex_unlock(session->resample_mutex);
+                       }
+
+                       if (session->write_resampler) {
+                               switch_mutex_lock(session->resample_mutex);
+                               switch_resample_destroy(&session->write_resampler);
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Deactivating write resampler\n");
+                               switch_mutex_unlock(session->resample_mutex);
+                       }
+
+                       switch_core_session_reset(session, 0, 0);
+                       switch_channel_audio_sync(session->channel);
 
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, 
                                                          "Changing Codec from %s@%dms@%dhz to %s@%dms@%luhz\n",