[mod_conference] Fix regression made by previous commit when fixing memory consumption.

This commit is contained in:
Andrey Volk 2022-03-18 00:54:46 +03:00
parent a40584b465
commit d01c427c0b
2 changed files with 23 additions and 16 deletions

View File

@ -1286,15 +1286,19 @@ void conference_loop_launch_input(conference_member_t *member, switch_memory_poo
{
switch_threadattr_t *thd_attr = NULL;
if (member == NULL || member->input_thread)
return;
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
conference_utils_member_set_flag_locked(member, MFLAG_ITHREAD);
if (switch_thread_create(&member->input_thread, thd_attr, conference_loop_input, member, pool) != SWITCH_STATUS_SUCCESS) {
conference_utils_member_clear_flag_locked(member, MFLAG_ITHREAD);
switch_mutex_lock(member->flag_mutex);
if (member != NULL && !conference_utils_member_test_flag(member, MFLAG_ITHREAD)) {
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
conference_utils_member_set_flag_locked(member, MFLAG_ITHREAD);
if (switch_thread_create(&member->input_thread, thd_attr, conference_loop_input, member, pool) != SWITCH_STATUS_SUCCESS) {
conference_utils_member_clear_flag_locked(member, MFLAG_ITHREAD);
}
}
switch_mutex_unlock(member->flag_mutex);
}
/* marshall frames from the conference (or file or tts output) to the call leg */
@ -1314,7 +1318,6 @@ void conference_loop_output(conference_member_t *member)
call_list_t *call_list, *cp;
switch_codec_implementation_t read_impl = { 0 }, real_read_impl = { 0 };
int sanity;
switch_status_t st;
switch_core_session_get_read_impl(member->session, &read_impl);
switch_core_session_get_real_read_impl(member->session, &real_read_impl);
@ -1654,12 +1657,6 @@ void conference_loop_output(conference_member_t *member)
if (!member->loop_loop) {
conference_utils_member_clear_flag_locked(member, MFLAG_RUNNING);
/* Wait for the input thread to end */
if (member->input_thread) {
switch_thread_join(&st, member->input_thread);
member->input_thread = NULL;
}
}
switch_core_timer_destroy(&timer);

View File

@ -2482,7 +2482,7 @@ SWITCH_STANDARD_APP(conference_function)
if (switch_channel_test_flag(channel, CF_AUDIO) && (audio_flow == SWITCH_MEDIA_FLOW_SENDRECV || audio_flow == SWITCH_MEDIA_FLOW_SENDONLY)) {
conference_loop_output(&member);
} else {
if (!member.input_thread) {
if (!conference_utils_member_test_flag(&member, MFLAG_ITHREAD)) {
conference_loop_launch_input(&member, switch_core_session_get_pool(member.session));
}
@ -2495,6 +2495,16 @@ SWITCH_STANDARD_APP(conference_function)
}
} while (member.loop_loop);
conference_utils_member_clear_flag_locked(&member, MFLAG_RUNNING);
/* Wait for the input thread to end */
if (member.input_thread) {
switch_status_t st;
switch_thread_join(&st, member.input_thread);
member.input_thread = NULL;
}
switch_core_session_video_reset(session);
switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);