]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
limit size of input buffer in conference
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 12 Feb 2014 22:17:53 +0000 (03:17 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 12 Feb 2014 22:19:54 +0000 (03:19 +0500)
Conflicts:
src/mod/applications/mod_conference/mod_conference.c

src/mod/applications/mod_conference/mod_conference.c

index 322fef0808c9838cf52ad99d89a8471d00c7f01e..763ec3adcdf892c33ca9cbc465fb87e884e1ed0b 100644 (file)
@@ -3136,7 +3136,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
        switch_frame_t *read_frame = NULL;
        uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, diff_level = 400;
        switch_core_session_t *session = member->session;
-
+       uint32_t flush_len;
 
        if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
                goto end;
@@ -3150,6 +3150,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
 
        switch_core_session_get_read_impl(session, &member->read_impl);
 
+       switch_channel_audio_sync(channel);
+       flush_len = switch_samples_per_packet(member->read_impl.actual_samples_per_second, (member->read_impl.microseconds_per_packet / 1000)) * 6;
+
        /* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it 
           and mux it with any audio from other channels. */
 
@@ -3410,6 +3413,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
 
                                /* Write the audio into the input buffer */
                                switch_mutex_lock(member->audio_in_mutex);
+                               if (switch_buffer_inuse(member->audio_buffer) > flush_len) {
+                                       switch_buffer_zero(member->audio_buffer);
+                                       switch_channel_audio_sync(channel);
+                               }
                                ok = switch_buffer_write(member->audio_buffer, data, datalen);
                                switch_mutex_unlock(member->audio_in_mutex);
                                if (!ok) {