diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2013-01-25 09:27:33 -0500 |
---|---|---|
committer | Yonit Halperin <yhalperi@redhat.com> | 2013-04-22 16:30:55 -0400 |
commit | 073aeec569e2bee3feec8042986b8434db8afad3 (patch) | |
tree | aa4abff930aed959f0981a7b3a197697d40832b5 /server/reds.c | |
parent | a9087c4c8a1cf38c9dae331a9255f0dc6823e7b8 (diff) |
reds: support mm_time latency adjustments
When there is no audio playback, we set the mm_time in the client to be older
than the one in the server by at least the requested latency (the delta is
actually bigger, due to the network latency).
When there is an audio playback, we adjust the mm_time in the client by
adjusting the playback buffer using SPICE_MSG_PLAYBACK_LATENCY.
Diffstat (limited to 'server/reds.c')
-rw-r--r-- | server/reds.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/server/reds.c b/server/reds.c index 822289bc..c3b5518c 100644 --- a/server/reds.c +++ b/server/reds.c @@ -3031,6 +3031,29 @@ listen: return slisten; } +static void reds_send_mm_time(void) +{ + main_channel_push_multi_media_time(reds->main_channel, + reds_get_mm_time() - reds->mm_time_latency); +} + +void reds_set_client_mm_time_latency(RedClient *client, uint32_t latency) +{ + // TODO: multi-client support for mm_time + if (reds->mm_timer_enabled) { + // TODO: consider network latency + if (latency > reds->mm_time_latency) { + reds->mm_time_latency = latency; + reds_send_mm_time(); + } else { + spice_debug("new latency %u is smaller than existing %u", + latency, reds->mm_time_latency); + } + } else { + snd_set_playback_latency(client, latency); + } +} + static int reds_init_net(void) { if (spice_port != -1) { @@ -3463,12 +3486,15 @@ void reds_enable_mm_timer(void) if (!reds_main_channel_connected()) { return; } - main_channel_push_multi_media_time(reds->main_channel, reds_get_mm_time() - MM_TIME_DELTA); + reds->mm_timer_enabled = TRUE; + reds->mm_time_latency = MM_TIME_DELTA; + reds_send_mm_time(); } void reds_disable_mm_timer(void) { core->timer_cancel(reds->mm_timer); + reds->mm_timer_enabled = FALSE; } static void mm_timer_proc(void *opaque) |