提交 8f82979d authored 作者: Anthony Minessale's avatar Anthony Minessale

limit size of input buffer in conference

上级 5f5a9710
...@@ -3655,7 +3655,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v ...@@ -3655,7 +3655,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
switch_frame_t *read_frame = NULL; switch_frame_t *read_frame = NULL;
uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, diff_level = 400; uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, diff_level = 400;
switch_core_session_t *session = member->session; switch_core_session_t *session = member->session;
uint32_t flush_len;
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) { if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
goto end; goto end;
...@@ -3671,6 +3671,8 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v ...@@ -3671,6 +3671,8 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
switch_channel_audio_sync(channel); 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 /* 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. */ and mux it with any audio from other channels. */
...@@ -3944,6 +3946,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v ...@@ -3944,6 +3946,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
/* Write the audio into the input buffer */ /* Write the audio into the input buffer */
switch_mutex_lock(member->audio_in_mutex); 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); ok = switch_buffer_write(member->audio_buffer, data, datalen);
switch_mutex_unlock(member->audio_in_mutex); switch_mutex_unlock(member->audio_in_mutex);
if (!ok) { if (!ok) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论