Skip to content

Commit

Permalink
#835: add the ability to fine tune the av-sync delay by dynamically t…
Browse files Browse the repository at this point in the history
…weaking the av-sync-delta value (initially set with XPRA_AV_SYNC_DELTA)

git-svn-id: https://xpra.org/svn/Xpra/trunk@11366 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 7, 2015
1 parent 60e4e21 commit 7e1714f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/xpra/server/dbus/dbus_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ def StopSpeaker(self):
self.source.stop_sending_sound()


@dbus.service.method(INTERFACE, in_signature='i')
def SetAVSyncDelay(self, delay):
self.source.set_av_sync_delay(delay)


@dbus.service.method(INTERFACE, in_signature='as')
def SendClientCommand(self, args):
self.source.send_client_command(*args)
19 changes: 15 additions & 4 deletions src/xpra/server/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def __init__(self, protocol, disconnect_cb, idle_add, timeout_add, source_remove
self.av_sync = av_sync
self.av_sync_delay = 0
self.av_sync_delay_total = 0
self.av_sync_delta = AV_SYNC_DELTA

self.server_core_encodings = core_encodings
self.server_encodings = encodings
Expand Down Expand Up @@ -1052,8 +1053,12 @@ def fadeout():
return "new sequence is %s" % self.sound_source_sequence
elif action=="sync":
assert self.av_sync, "av-sync is not enabled"
self.set_av_sync_delay(args[0])
self.set_av_sync_delay(int(args[0]))
return "av-sync delay set to %ims" % self.av_sync_delay
elif action=="av-sync-delta":
assert self.av_sync, "av-sync is not enabled"
self.set_av_sync_delta(int(args[0]))
return "av-sync delta set to %ims" % self.av_sync_delta
#elif action=="quality":
# assert self.sound_source
# quality = args[0]
Expand Down Expand Up @@ -1095,6 +1100,12 @@ def sound_sink_error(*args):
return
self.sound_sink.add_data(data, metadata)


def set_av_sync_delta(self, delta):
avsynclog("set_av_sync_delta(%i)", delta)
self.av_sync_delta = delta
self.update_av_sync_delay_total()

def set_av_sync_delay(self, v):
#update all window sources with the given delay
self.av_sync_delay = v
Expand All @@ -1113,8 +1124,8 @@ def update_av_sync_delay_total(self):
except Exception as e:
encoder_latency = 0
avsynclog("failed to get encoder latency for %s: %s", ss.codec, e)
self.av_sync_delay_total = min(1000, max(0, int(self.av_sync_delay) + AV_SYNC_DELTA + encoder_latency))
avsynclog("av-sync set to %ims (from client queue latency=%s, %sencoder latency=%s, env delta=%s)", self.av_sync_delay_total, self.av_sync_delay, cinfo, encoder_latency, AV_SYNC_DELTA)
self.av_sync_delay_total = min(1000, max(0, int(self.av_sync_delay) + self.av_sync_delta + encoder_latency))
avsynclog("av-sync set to %ims (from client queue latency=%s, %sencoder latency=%s, delta=%s)", self.av_sync_delay_total, self.av_sync_delay, cinfo, encoder_latency, self.av_sync_delta)
else:
avsynclog("av-sync support is disabled, setting it to 0")
self.av_sync_delay_total = 0
Expand Down Expand Up @@ -1352,7 +1363,7 @@ def up(prefix, d):
up("connection", self.protocol.get_info())
up("av-sync", {"client.delay" : self.av_sync_delay,
"total" : self.av_sync_delay_total,
"delta" : AV_SYNC_DELTA})
"delta" : self.av_sync_delta})
if self.window_frame_sizes:
up("window.frame-sizes", self.window_frame_sizes)
if self.window_filters:
Expand Down

0 comments on commit 7e1714f

Please sign in to comment.