]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4115 --resolve this should fix it in all circumstances
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 23 Apr 2012 18:25:21 +0000 (13:25 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 23 Apr 2012 18:25:21 +0000 (13:25 -0500)
src/switch_core_media_bug.c
src/switch_core_session.c

index 52151b9681db872d56e156b297467d0271b0c3ba..f5d14137b70a950c6639b71c3fd4a5b7a156caff 100644 (file)
@@ -129,7 +129,6 @@ SWITCH_DECLARE(void) switch_core_media_bug_flush(switch_media_bug_t *bug)
 
        bug->record_frame_size = 0;
        bug->record_pre_buffer_count = 0;
-
 }
 
 SWITCH_DECLARE(void) switch_core_media_bug_inuse(switch_media_bug_t *bug, switch_size_t *readp, switch_size_t *writep)
@@ -207,7 +206,31 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
                bug->record_pre_buffer_count++;
                return SWITCH_STATUS_FALSE;
        }
-       
+
+       if (!bug->record_frame_size) {
+               if (do_read && do_write) {
+                       switch_size_t frame_size;
+                       switch_codec_implementation_t read_impl = { 0 };
+                       switch_codec_implementation_t other_read_impl = { 0 };
+                       switch_core_session_t *other_session;
+                       
+                       switch_core_session_get_read_impl(bug->session, &read_impl);
+                       frame_size = read_impl.decoded_bytes_per_packet;
+                       
+                       if (switch_core_session_get_partner(bug->session, &other_session) == SWITCH_STATUS_SUCCESS) {
+                               switch_core_session_get_read_impl(other_session, &other_read_impl);
+                               switch_core_session_rwunlock(other_session);
+                               
+                               if (read_impl.decoded_bytes_per_packet < other_read_impl.decoded_bytes_per_packet) {
+                                       frame_size = other_read_impl.decoded_bytes_per_packet;
+                               }
+                       }
+                       
+                       bug->record_frame_size = frame_size;
+               }
+       }
+
+
        if (bug->record_frame_size) {
                if ((do_read && do_read < bug->record_frame_size) || (do_write && do_write < bug->record_frame_size)) {
                        return SWITCH_STATUS_FALSE;
@@ -220,16 +243,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
                if (do_write && do_write > bug->record_frame_size) {
                        do_write = bug->record_frame_size;
                }
-       } else {
-               if (do_read && do_write) {
-                       if (do_read > do_write) {
-                               do_read = do_write;
-                       } else if (do_write > do_read) {
-                               do_write = do_read;
-                       }
-
-                       bug->record_frame_size = do_read;
-               }
        }
 
        fill_read = !do_read;
index f42104bdc3f6d46e2dd22ed719a2901e984fe6f3..6551158522188d426ad76ce95f7002f55d949f75 100644 (file)
@@ -724,11 +724,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(swit
                }
        }
 
+
        message->_file = NULL;
        message->_func = NULL;
        message->_line = 0;
 
        if (switch_channel_up_nosig(session->channel)) {
+               if (message->message_id == SWITCH_MESSAGE_INDICATE_BRIDGE || message->message_id == SWITCH_MESSAGE_INDICATE_UNBRIDGE) {
+                       switch_core_media_bug_flush_all(session);
+               }
+
                switch (message->message_id) {
                case SWITCH_MESSAGE_REDIRECT_AUDIO:
                case SWITCH_MESSAGE_INDICATE_ANSWER: