From d58dbaf4fecc13fc1262c7a60dafdb5f0ffa6b8a Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 8 Apr 2015 11:48:49 +0000 Subject: [PATCH] #669: * logging tweaks * log restart delay (and simplify delay calculation) * always include a sound sequence: start at 0 (so we can distinguish when one is not present) * discard sound buffers on the server side if the sequence has been bumped * associate the sequence number with a sound_source (that's the point) git-svn-id: https://xpra.org/svn/Xpra/trunk@8966 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/ui_client_base.py | 36 ++++++++++++++++--------------- src/xpra/server/source.py | 21 ++++++++++-------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index 12336a4876..fab9b505ea 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -1606,7 +1606,7 @@ def sink_ready(*args): def stop_receiving_sound(self, tell_server=True): """ ask the server to stop sending sound, toggle flag so we ignore further packets and emit client signal """ - soundlog("stop_receiving_sound() sound sink=%s", self.sound_sink) + soundlog("stop_receiving_sound(%s) sound sink=%s", tell_server, self.sound_sink) ss = self.sound_sink self.speaker_enabled = False if tell_server: @@ -1614,8 +1614,10 @@ def stop_receiving_sound(self, tell_server=True): if ss is None: return self.sound_sink = None + soundlog("stop_receiving_sound(%s) calling %s", tell_server, ss.cleanup) ss.cleanup() self.emit("speaker-changed") + soundlog("stop_receiving_sound(%s) done", tell_server) def bump_sound_sequence(self): if self.server_sound_sequence: @@ -1660,16 +1662,14 @@ def sound_sink_overrun(self, sound_sink, *args): self.min_sound_sequence += 1 self.stop_receiving_sound() def restart(): - soundlog("sound_sink=%s, codec=%s, server_sound_sequence=%s", self.sound_sink, codec, self.server_sound_sequence) + soundlog("restarting sound sound_sink=%s, codec=%s, server_sound_sequence=%s", self.sound_sink, codec, self.server_sound_sequence) if self.server_sound_sequence: self.send_new_sound_sequence() self.start_receiving_sound() #by default for older servers, #wait before restarting so we can process the "end-of-stream" message: - delay = 500 - if self.server_sound_eos_sequence: - #no need to wait, we won't mistakenly stop() the wrong sink: - delay = 0 + delay = 500 * int(not self.server_sound_eos_sequence) + soundlog("sound_sink_overrun() will restart in %ims (server supports eos sequence: %s)", delay, self.server_sound_eos_sequence) self.timeout_add(delay, restart) def start_sound_sink(self, codec): @@ -1707,6 +1707,12 @@ def _process_sound_data(self, packet): metadata = typedict(metadata) if data: self.sound_in_bytecount += len(data) + #verify sequence number if present: + seq = metadata.intget("sequence", -1) + if self.min_sound_sequence>0 and seq>=0 and seq0 and seq>=0 and seq0: - metadata["sequence"] = self.sound_source_sequence + if sound_source.sequence=0: + metadata["sequence"] = self.sound_source.sequence self.send("sound-data", self.sound_source.codec, Compressed(self.sound_source.codec, data), metadata) def stop_receiving_sound(self): @@ -876,7 +879,7 @@ def fadeout(): return False self.timeout_add(100, fadeout) elif action=="new-sequence": - self.sound_source_sequence = args[0] + self.sound_source_sequence = int(args[0]) return "new sequence is %s" % self.sound_source_sequence #elif action=="quality": # assert self.sound_source