]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9748: [Locking contention with mod_shout playing conference moh]
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Nov 2016 02:08:56 +0000 (20:08 -0600)
committerMike Jerris <mike@jerris.com>
Fri, 18 Nov 2016 15:37:30 +0000 (09:37 -0600)
src/mod/applications/mod_conference/mod_conference.c
src/mod/applications/mod_conference/mod_conference.h
src/mod/formats/mod_shout/mod_shout.c

index eae77037e01dfe7fec73e473eda569f8866c3455..d8e99848007429b49d5ecf14e47b95d712193f60 100644 (file)
@@ -237,6 +237,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
                uint32_t conference_energy = 0;
                int nomoh = 0;
                conference_member_t *floor_holder;
+               switch_status_t moh_status = SWITCH_STATUS_SUCCESS;
 
                /* Sync the conference to a single timing source */
                if (switch_core_timer_next(&timer) != SWITCH_STATUS_SUCCESS) {
@@ -324,13 +325,21 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
                        conference_member_set_floor_holder(conference, floor_holder);
                }
 
-               if (conference->perpetual_sound && !conference->async_fnode) {
-                       conference_file_play(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
-               } else if (conference->moh_sound && ((nomoh == 0 && conference->count == 1)
-                                                                                        || conference_utils_test_flag(conference, CFLAG_WAIT_MOD)) && !conference->async_fnode && !conference->fnode) {
-                       conference_file_play(conference, conference->moh_sound, CONF_DEFAULT_LEADIN, NULL, 1);
+               if (conference->moh_wait > 0) {
+                       conference->moh_wait--;
+               } else {
+                       if (conference->perpetual_sound && !conference->async_fnode) {
+                               moh_status = conference_file_play(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
+                       } else if (conference->moh_sound && ((nomoh == 0 && conference->count == 1)
+                                                                                                || conference_utils_test_flag(conference, CFLAG_WAIT_MOD)) &&
+                                          !conference->async_fnode && !conference->fnode) {
+                               moh_status = conference_file_play(conference, conference->moh_sound, CONF_DEFAULT_LEADIN, NULL, 1);
+                       }
                }
 
+               if (!conference->moh_wait && moh_status != SWITCH_STATUS_SUCCESS) {
+                       conference->moh_wait = 2000 / conference->interval;
+               }
 
                /* Find if no one talked for more than x number of second */
                if (conference->terminate_on_silence && conference->count > 1) {
index 42bba3574bd28b363c517c2bc697c507c3a0fec5..14d209c94b9a7c66ec12538bcf7b595379ea8e22 100644 (file)
@@ -681,6 +681,7 @@ typedef struct conference_obj {
        int scale_h264_canvas_height;
        int scale_h264_canvas_fps_divisor;
        char *scale_h264_canvas_bandwidth;
+       uint32_t moh_wait;
 } conference_obj_t;
 
 /* Relationship with another member */
index 8372a03b7fb3f16812b2cb43ff65af814e92f44c..f326116a5b1f9c50994bf3b76b14389d776ea780 100644 (file)
@@ -717,7 +717,7 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char
                if (handle->handler) {
                        int sanity = 1000;
 
-                       while(--sanity > 0 && !switch_buffer_inuse(context->audio_buffer)) {
+                       while(--sanity > 0 && !switch_buffer_inuse(context->audio_buffer) && !context->eof && !context->err) {
                                switch_yield(20000);
                        }