Skip to content

Commit

Permalink
#663: use min-threshold-time to try to ensure that the buffer is neit…
Browse files Browse the repository at this point in the history
…her too full (overrun) or completely drained (underrun)

git-svn-id: https://xpra.org/svn/Xpra/trunk@7485 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 30, 2014
1 parent 99b6bb7 commit d891983
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/xpra/sound/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d891983

Please sign in to comment.