[spice-gtk,v3,2/6] playback: Use the audio timestamps for the global mmtime conversion

Submitted by Frediano Ziglio on July 26, 2019, 9:52 a.m.

Details

Message ID 20190726095213.15655-3-fziglio@redhat.com
State New
Headers show
Series "Client-side video stream lag reduction" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 26, 2019, 9:52 a.m.
From: Francois Gouget <fgouget@codeweavers.com>

More data helps improve the accuracy of the estimation of the true clock
offset and minimum network latency.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---
 src/channel-playback.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/channel-playback.c b/src/channel-playback.c
index a00706fe..656a4037 100644
--- a/src/channel-playback.c
+++ b/src/channel-playback.c
@@ -302,14 +302,16 @@  static void playback_handle_data(SpiceChannel *channel, SpiceMsgIn *in)
 {
     SpicePlaybackChannelPrivate *c = SPICE_PLAYBACK_CHANNEL(channel)->priv;
     SpiceMsgPlaybackPacket *packet = spice_msg_in_parsed(in);
+    SpiceSession *session;
 
 #ifdef DEBUG
     CHANNEL_DEBUG(channel, "%s: time %u data %p size %d", __FUNCTION__,
                   packet->time, packet->data, packet->data_size);
 #endif
 
-    if (spice_mmtime_diff(c->last_time, packet->time) > 0)
-        g_warn_if_reached();
+    /* This also updates the time offset */
+    session = spice_channel_get_session(channel);
+    spice_session_mmtime2client_time(session, packet->time);
 
     c->last_time = packet->time;
 
@@ -361,11 +363,16 @@  static void playback_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
 {
     SpicePlaybackChannelPrivate *c = SPICE_PLAYBACK_CHANNEL(channel)->priv;
     SpiceMsgPlaybackStart *start = spice_msg_in_parsed(in);
+    SpiceSession *session;
 
     CHANNEL_DEBUG(channel, "%s: fmt %u channels %u freq %u time %u mode %s", __FUNCTION__,
                   start->format, start->channels, start->frequency, start->time,
                   spice_audio_data_mode_to_string(c->mode));
 
+    /* This also updates the time offset */
+    session = spice_channel_get_session(channel);
+    spice_session_mmtime2client_time(session, start->time);
+
     c->frame_count = 0;
     c->last_time = start->time;
     c->is_active = TRUE;