[Spice-devel] [PATCH spice-gtk 8/8] channel-display: trigger re-sync of audio playback latency when there are frequent video frame drops
Yonit Halperin
yhalperi at redhat.com
Tue Feb 26 10:04:58 PST 2013
This was added in order to respond more quickly when the audio and video playback are
not synchronized, and when the latency between the client and the server
is high (i.e., when the server response to the status is delayed).
---
gtk/channel-display-priv.h | 2 ++
gtk/channel-display.c | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/gtk/channel-display-priv.h b/gtk/channel-display-priv.h
index 49f82fe..09683be 100644
--- a/gtk/channel-display-priv.h
+++ b/gtk/channel-display-priv.h
@@ -88,6 +88,8 @@ typedef struct display_stream {
GArray *drops_seqs_stats_arr;
uint32_t num_drops_seqs;
+ uint32_t playback_sync_drops_seq_len;
+
/* playback quality report to server */
gboolean report_is_active;
uint32_t report_id;
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index efb9aec..8452a2a 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -1298,6 +1298,7 @@ static void display_update_stream_report(SpiceDisplayChannel *channel, uint32_t
}
}
+#define STREAM_PLAYBACK_SYNC_DROP_SEQ_LEN_LIMIT 5
/* coroutine context */
static void display_handle_stream_data(SpiceChannel *channel, SpiceMsgIn *in)
{
@@ -1334,11 +1335,14 @@ static void display_handle_stream_data(SpiceChannel *channel, SpiceMsgIn *in)
mmtime - op->multi_media_time, op->multi_media_time, mmtime);
st->arrive_late_time += mmtime - op->multi_media_time;
st->num_drops_on_arive++;
+
if (!st->cur_drops_seq_stats.len) {
st->cur_drops_seq_stats.start_mm_time = op->multi_media_time;
}
st->cur_drops_seq_stats.len++;
+ st->playback_sync_drops_seq_len++;
} else {
+ CHANNEL_DEBUG(channel, "video latency: %d", latency);
spice_msg_in_ref(in);
g_queue_push_tail(st->msgq, in);
display_stream_schedule(st);
@@ -1349,9 +1353,14 @@ static void display_handle_stream_data(SpiceChannel *channel, SpiceMsgIn *in)
memset(&st->cur_drops_seq_stats, 0, sizeof(st->cur_drops_seq_stats));
st->num_drops_seqs++;
}
+ st->playback_sync_drops_seq_len = 0;
}
display_update_stream_report(SPICE_DISPLAY_CHANNEL(channel), op->id,
op->multi_media_time, latency);
+ if (st->playback_sync_drops_seq_len >= STREAM_PLAYBACK_SYNC_DROP_SEQ_LEN_LIMIT) {
+ spice_session_sync_playback_latency(spice_channel_get_session(channel));
+ st->playback_sync_drops_seq_len = 0;
+ }
}
/* coroutine context */
--
1.8.1
More information about the Spice-devel
mailing list