]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9586 #resolve [local_stream video queue stuck when not being read from] %backport=1.6
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 28 Sep 2016 15:38:15 +0000 (10:38 -0500)
committerBrian West <brian@freeswitch.org>
Wed, 28 Sep 2016 15:38:28 +0000 (10:38 -0500)
src/mod/formats/mod_local_stream/mod_local_stream.c

index 87be23842a846d0458c0886b982859ccf678cb4a..3dcb6bf65e8187f331977257a9779845d074e3ef 100644 (file)
@@ -71,6 +71,7 @@ struct local_stream_context {
        int newres;
        int serno;
        int pop_count;
+       int video_flushes;
        switch_size_t blank;
        switch_image_t *banner_img;
        switch_time_t banner_timeout;
@@ -635,7 +636,17 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
                                                switch_mutex_lock(source->mutex);
                                                if (source->context_list) {
                                                        if (source->total == 1) {
-                                                               switch_queue_push(source->context_list->video_q, img);
+                                                               if (switch_queue_trypush(source->context_list->video_q, img) != SWITCH_STATUS_SUCCESS) {
+                                                                       flush_video_queue(source->context_list->video_q);
+
+                                                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Flushing video queue\n");
+                                                                       if (++source->context_list->video_flushes > 1) {
+                                                                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Disconnecting file\n");
+                                                                               source->context_list->ready = 0;
+                                                                       }
+                                                               } else {
+                                                                       source->context_list->video_flushes = 0;
+                                                               }
                                                        } else {
                                                                for (cp = source->context_list; cp && RUNNING; cp = cp->next) {
 
@@ -649,6 +660,13 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
                                                                                if (imgcp) {
                                                                                        if (switch_queue_trypush(cp->video_q, imgcp) != SWITCH_STATUS_SUCCESS) {
                                                                                                flush_video_queue(cp->video_q);
+                                                                                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Flushing video queue\n");
+                                                                                               if (++cp->video_flushes > 1) {
+                                                                                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Disconnecting file\n");
+                                                                                                       cp->ready = 0;
+                                                                                               }
+                                                                                       } else {
+                                                                                               cp->video_flushes = 0;
                                                                                        }
                                                                                }
                                                                        }