diff options
author | Francois Gouget <fgouget@codeweavers.com> | 2016-12-23 16:07:49 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2017-01-19 15:28:59 +0100 |
commit | 0517c9d6c4da58d5e8b76cef7fada58141859443 (patch) | |
tree | fbf752cb00a2c04ccc2adf42ba067a246feedeef | |
parent | 97bd84313597d7c37c637c29e75f8862fcab1940 (diff) |
streaming: Fix a race condition in the GStreamer frame display queue
When a frame is late we schedule its display right away with
g_timeout_add(0, ...). This scheduling is done in one of the GStreamer
thread, and the display_frame() callback will be called from the main
thread. This can result in display_frame() being called before
g_timeout_add() returns. This would cause the timer_id being reset
before schedule_frame() had set it so that it would then never be reset.
So from that point schedule_frame() would always think a frame was being
displayed and thus would not schedule any more frames resulting in a
video freeze.
display_frame() now takes the queues mutex before resetting timer_id
eliminating the race.
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
-rw-r--r-- | src/channel-display-gst.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c index 9786342..5f4d321 100644 --- a/src/channel-display-gst.c +++ b/src/channel-display-gst.c @@ -127,9 +127,8 @@ static gboolean display_frame(gpointer video_decoder) GstBuffer *buffer; GstMapInfo mapinfo; - decoder->timer_id = 0; - g_mutex_lock(&decoder->queues_mutex); + decoder->timer_id = 0; frame = g_queue_pop_head(decoder->display_queue); g_mutex_unlock(&decoder->queues_mutex); /* If the queue is empty we don't even need to reschedule */ |