This patch allows to reduce the time the client wait to display frames. It can make the lip sync not working but it allows to see the video latency introduced by this code. This patch is meant to be used mainly for debugging: - recently we are seeing some artifacts due to this delay and overlaying, removing the delay make easier to understand if the problem is related to this or other issues; - we are testing guest encoding and we are experiencing a big lag. This avoid this part of the lag helping understand where the other part of the delay happens. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- This patch is not intended to be merged as is but to be used to fix above problems or as a start for some better settings. --- src/channel-display-gst.c | 1 + src/channel-display-mjpeg.c | 14 ++++++++++++++ src/channel-display-priv.h | 3 +++ 3 files changed, 18 insertions(+) diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c index 9c62e67..379c935 100644 --- a/src/channel-display-gst.c +++ b/src/channel-display-gst.c @@ -184,6 +184,7 @@ static void schedule_frame(SpiceGstDecoder *decoder) SpiceStreamDataHeader *op = spice_msg_in_parsed(frame->msg); gint32 time_diff = compute_mm_time_diff(op->multi_media_time, now); + time_diff = MIN(time_diff, max_frame_delay_ms); if (time_diff >= 0) { decoder->timer_id = g_timeout_add(time_diff, display_frame, decoder); diff --git a/src/channel-display-mjpeg.c b/src/channel-display-mjpeg.c index 1b7373b..5c778a9 100644 --- a/src/channel-display-mjpeg.c +++ b/src/channel-display-mjpeg.c @@ -182,6 +182,19 @@ static gboolean mjpeg_decoder_decode_frame(gpointer video_decoder) /* ---------- VideoDecoder's queue scheduling ---------- */ +enum { MAX_DELAY_MS = 2000 }; +gint32 max_frame_delay_ms = MAX_DELAY_MS; + +SPICE_CONSTRUCTOR_FUNC(max_delay_init) +{ + const char *str_delay = g_getenv("SPICE_MAX_FRAME_DELAY"); + if (str_delay) { + int delay = atoi(str_delay); + if (delay >= 0 && delay <= MAX_DELAY_MS) + max_frame_delay_ms = delay; + } +} + static void mjpeg_decoder_schedule(MJpegDecoder *decoder) { SPICE_DEBUG("%s", __FUNCTION__); @@ -196,6 +209,7 @@ static void mjpeg_decoder_schedule(MJpegDecoder *decoder) if (frame_msg) { SpiceStreamDataHeader *op = spice_msg_in_parsed(frame_msg); gint32 time_diff = compute_mm_time_diff(op->multi_media_time, time); + time_diff = MIN(time_diff, max_frame_delay_ms); if (time_diff >= 0) { decoder->cur_frame_msg = frame_msg; decoder->timer_id = g_timeout_add(time_diff, mjpeg_decoder_decode_frame, decoder); diff --git a/src/channel-display-priv.h b/src/channel-display-priv.h index eced6af..2177065 100644 --- a/src/channel-display-priv.h +++ b/src/channel-display-priv.h @@ -161,6 +161,9 @@ static inline gint32 compute_mm_time_diff(guint32 time1, guint32 time2) return (gint32) (time1 - time2); } +/* maximum delay for frames */ +extern gint32 max_frame_delay_ms; + G_END_DECLS #endif // CHANNEL_DISPLAY_PRIV_H_ -- 2.9.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel