From d891983909296afd68853153851442190af01e78 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 30 Aug 2014 08:34:57 +0000 Subject: [PATCH] #663: use min-threshold-time to try to ensure that the buffer is neither too full (overrun) or completely drained (underrun) git-svn-id: https://xpra.org/svn/Xpra/trunk@7485 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/sound/sink.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/xpra/sound/sink.py b/src/xpra/sound/sink.py index 7684a5230b..9226d9f025 100755 --- a/src/xpra/sound/sink.py +++ b/src/xpra/sound/sink.py @@ -112,11 +112,25 @@ def queue_running(self, *args): def queue_underrun(self, *args): ltime = int(self.queue.get_property("current-level-time")/MS_TO_NS) log("sound sink queue underrun: level=%s", ltime) - self.queue_state = "underrun" + if self.queue_state != "underrun": + self.queue_state = "underrun" + mtt = self.queue.get_property("min-threshold-time") + if mtt==0: + #raise mtt to ensure the queue is not drained: + self.queue.set_property("min-threshold-time", QUEUE_TIME/2) + #reset threshold after 2 seconds: + def reset_mtt(*args): + self.queue.set_property("min-threshold-time", 0) + gobject.timeout_add(2*1000, reset_mtt) def queue_overrun(self, *args): ltime = int(self.queue.get_property("current-level-time")/MS_TO_NS) self.queue_state = "overrun" + mtt = self.queue.get_property("min-threshold-time") + if mtt>0: + log("overrun following underrun... clearing min-threshold-time and ignoring it") + self.queue.set_property("min-threshold-time", 0) + return #no overruns for the first 2 seconds: elapsed = time.time()-self.start_time if elapsed<2.0 or ltime<(QUEUE_TIME/MS_TO_NS/2*75/100):