[Spice-devel] [spice-gtk v7 3/3] streaming: Stop streaming if GStreamer silently drops every frame

Christophe Fergeau cfergeau at redhat.com
Wed Nov 23 13:06:19 UTC 2016


From: Francois Gouget <fgouget at codeweavers.com>

This happened before the previous patch added code to detect GStreamer
errors. Now that we detect these errors, this probably cannot happen
anymore.

SPICE_GST_MAX_QUEUED_FRAMES value is arbitrary.

Frames may accumulate in the queue if the GStreamer pipeline is slow in
decoding them so setting this value too low may cause false positives.
So it should be large enough but not so large that the client takes ages
to realize something is wrong.

The server is currently sending a maximum of 30 fps (but the client does
not know that) so this is, at a minimum, a bit under 1 second worth of
frames queued up for decoding. That should really not happen.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
---

- added more details to the commit log from https://lists.freedesktop.org/archives/spice-devel/2016-November/033834.html
- added SPICE_GST_MAX_QUEUED_FRAMES constant
- added Acked-by: Christophe Fergeau <cfergeau at redhat.com>

 src/channel-display-gst.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 5fb0b77..92beefa 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -414,6 +414,9 @@ static void release_buffer_data(gpointer data)
     spice_msg_in_unref(frame_msg);
 }
 
+/* This corresponds to a bit less than 1 second */
+#define SPICE_GST_MAX_QUEUED_FRAMES 25
+
 static gboolean spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
                                               SpiceMsgIn *frame_msg,
                                               int32_t latency)
@@ -446,6 +449,13 @@ static gboolean spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
         return TRUE;
     }
 
+    /* Verify that the pipeline is decoding the frames as expected */
+    g_mutex_lock(&decoder->queues_mutex);
+    if (g_queue_get_length(decoder->decoding_queue) > SPICE_GST_MAX_QUEUED_FRAMES) {
+        spice_warning("GStreamer is not decoding the frames!");
+        free_pipeline(decoder);
+    }
+    g_mutex_unlock(&decoder->queues_mutex);
     if (decoder->pipeline == NULL) {
         /* An error occurred, causing the GStreamer pipeline to be freed */
         spice_warning("An error occurred, stopping the video stream");
-- 
2.9.3



More information about the Spice-devel mailing list