Whenever there are bytes from the network we queue them to GStreamer. The pipeline is set to not have a limit so the queue can grow indefinitely. Limit the queue stopping reading if is already too large. Currently fixed to 64 MByte. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- src/channel-display-gst.c | 9 +++++++++ 1 file changed, 9 insertions(+) Maybe a better formula to understand when to wait? Maybe taking into account also frames pending? Which is the best test for this? Tried with Valgrind, helps surely to limit the queue but is too slow. diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c index 7ba8cd0..281a936 100644 --- a/src/channel-display-gst.c +++ b/src/channel-display-gst.c @@ -505,6 +505,12 @@ static void spice_gst_decoder_destroy(VideoDecoder *video_decoder) */ } +static gboolean wait_push(gpointer data) +{ + SpiceGstDecoder *decoder = data; + + return gst_app_src_get_current_level_bytes(decoder->appsrc) < 64*1024*1024; +} /* spice_gst_decoder_queue_frame() queues the SpiceFrame for decoding and * displaying. The steps it goes through are as follows: @@ -531,6 +537,7 @@ static void spice_gst_decoder_destroy(VideoDecoder *video_decoder) * 9) display_frame() then frees the SpiceGstFrame, which frees the SpiceFrame * and decompressed frame with it. */ +/* coroutine context */ static gboolean spice_gst_decoder_queue_frame(VideoDecoder *video_decoder, SpiceFrame *frame, int latency) { @@ -584,6 +591,8 @@ static gboolean spice_gst_decoder_queue_frame(VideoDecoder *video_decoder, GST_BUFFER_DTS(buffer) = GST_CLOCK_TIME_NONE; GST_BUFFER_PTS(buffer) = gst_clock_get_time(decoder->clock) - gst_element_get_base_time(decoder->pipeline) + ((uint64_t)MAX(0, latency)) * 1000 * 1000; + g_coroutine_condition_wait(g_coroutine_self(), wait_push, decoder); + SpiceGstFrame *gst_frame = create_gst_frame(buffer, frame); g_mutex_lock(&decoder->queues_mutex); g_queue_push_tail(decoder->decoding_queue, gst_frame); -- 2.14.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel