Skip to content

Commit

Permalink
let the user enable, disable or tune the av-sync delay using the tray
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@17223 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 22, 2017
1 parent 888b2a2 commit 9bc052e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
Binary file added src/icons/video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 42 additions & 1 deletion src/xpra/client/gtk_base/gtk_tray_menu_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
log = Logger("menu")
clipboardlog = Logger("menu", "clipboard")
webcamlog = Logger("menu", "webcam")

avsynclog = Logger("menu", "av-sync")

HIDE_DISABLED_MENU_ENTRIES = OSX

Expand Down Expand Up @@ -848,6 +848,7 @@ def make_audiomenuitem(self):
self.popup_menu_workaround(menu)
menu.append(self.make_speakermenuitem())
menu.append(self.make_microphonemenuitem())
menu.append(self.make_avsyncmenuitem())
audio_menu_item.show_all()
return audio_menu_item

Expand Down Expand Up @@ -944,6 +945,46 @@ def update_soundsubmenu_state(*args):
menu.show_all()
return menu

def make_avsyncmenuitem(self):
sync = self.menuitem("Video Sync", "video.png", "Synchronize audio and video", None)
menu = gtk.Menu()
self.popup_menu_workaround(menu)
current_value = 0
if not self.client.av_sync:
current_value = None
def syncitem(label, delta=0):
c = CheckMenuItem(label)
c.set_draw_as_radio(True)
c.set_active(current_value==delta)
def activate_cb(item, *_args):
avsynclog("activate_cb(%s, %s) delta=%s", item, menu, delta)
if delta==0:
self.client.av_sync = False
self.client.send_sound_sync(0)
else:
self.client.av_sync = True
self.client.av_sync_delta = delta
#the actual sync value will be calculated and sent
#in client._process_sound_data
c.connect("toggled", activate_cb, menu)
return c
menu.append(syncitem("Off", None))
menu.append(gtk.SeparatorMenuItem())
menu.append(syncitem("-200", -200))
menu.append(syncitem("-100", -100))
menu.append(syncitem(" -50", -50))
menu.append(syncitem("Auto", 0))
menu.append(syncitem(" +50", 50))
menu.append(syncitem(" +100", 100))
menu.append(syncitem(" +200", 200))
sync.set_submenu(menu)
sync.show_all()
def set_avsyncmenu(*_args):
set_sensitive(sync, self.client.server_av_sync)
self.client.after_handshake(set_avsyncmenu)
return sync


def make_webcammenuitem(self):
webcam = self.menuitem("Webcam", "webcam.png", "Forward webcam pictures to the server", None)
if not self.client.webcam_forwarding:
Expand Down
12 changes: 8 additions & 4 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def __init__(self):
self.microphone_codecs = []
self.microphone_device = None
self.av_sync = False
self.av_sync_delta = AV_SYNC_DELTA
#sound state:
self.on_sink_ready = None
self.sound_sink = None
Expand Down Expand Up @@ -2778,10 +2779,13 @@ def _process_sound_data(self, packet):
if self.queue_used_sent is None or abs(delta)>=80:
avsynclog("server sound sync: sending updated queue.used=%i (was %s)", queue_used, (self.queue_used_sent or "unset"))
self.queue_used_sent = queue_used
v = queue_used + AV_SYNC_DELTA
if AV_SYNC_DELTA:
avsynclog(" adjusted value=%i with sync delta=%i", v, AV_SYNC_DELTA)
self.send("sound-control", "sync", v)
v = queue_used + self.av_sync_delta
if self.av_sync_delta:
avsynclog(" adjusted value=%i with sync delta=%i", v, self.av_sync_delta)
self.send_sound_sync(v)

def send_sound_sync(self, v):
self.send("sound-control", "sync", v)


def send_notify_enabled(self):
Expand Down
1 change: 1 addition & 0 deletions src/xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ def get_info(self):
"dimensions" : self.window_dimensions,
"suspended" : self.suspended or False,
"av-sync" : {
"enabled" : self.av_sync,
"current" : self.av_sync_delay,
"target" : self.av_sync_delay_target
},
Expand Down

0 comments on commit 9bc052e

Please sign in to comment.