summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2013-02-19 12:07:14 -0500
committerYonit Halperin <yhalperi@redhat.com>2013-02-22 14:39:16 -0500
commita610f5a8c628995d1db08cc7db1be3336fa31673 (patch)
tree2dc76aa4fcb17dc5c7e448bfe9b5242ac48369de
parent350c58797e2c4e383a17bde3d2b322706e6a8978 (diff)
channel-display: trigger re-sync of audio playback latency when there are frequent video frame dropsvideo.adaptive_bit_rate
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).
-rw-r--r--gtk/channel-display-priv.h2
-rw-r--r--gtk/channel-display.c9
2 files changed, 11 insertions, 0 deletions
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 */