Skip to content

Commit

Permalink
#669: allow us to tune the min queue time using an env var
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@8793 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 18, 2015
1 parent 756ecef commit 6a167af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/xpra/sound/gstreamer_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
log.error("invalid leak option %s", QUEUE_LEAK)
QUEUE_LEAK = GST_QUEUE_LEAK_DEFAULT

def get_queue_time(default_value=450):
queue_time = int(os.environ.get("XPRA_SOUND_QUEUE_TIME", default_value))*MS_TO_NS
def get_queue_time(default_value=450, prefix=""):
queue_time = int(os.environ.get("XPRA_SOUND_QUEUE_%sTIME" % prefix, default_value))*MS_TO_NS
queue_time = max(0, queue_time)
return queue_time

Expand Down
9 changes: 6 additions & 3 deletions src/xpra/sound/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
DEFAULT_SINK = SINKS[0]
QUEUE_SILENT = 0
QUEUE_TIME = get_queue_time(450)
QUEUE_MIN = QUEUE_TIME//2
QUEUE_MIN_TIME = get_queue_time(QUEUE_TIME//2//MS_TO_NS, "MIN")
assert QUEUE_MIN_TIME<=QUEUE_TIME


GST_FORMAT_BUFFERS = 4
Expand Down Expand Up @@ -91,7 +92,7 @@ def __init__(self, sink_type=None, sink_options={}, codecs=CODECS, codec_options
pipeline_els.append("volume name=volume volume=%s" % volume)
queue_el = ["queue",
"name=queue",
"min-threshold-time=%s" % QUEUE_MIN,
"min-threshold-time=%s" % QUEUE_MIN_TIME,
"max-size-buffers=0",
"max-size-bytes=0",
"max-size-time=%s" % QUEUE_TIME,
Expand Down Expand Up @@ -145,7 +146,7 @@ def queue_underrun(self, *args):
log("sound sink queue underrun: level=%s", ltime)
if self.queue_state!="underrun":
#lift min time restrictions:
self.queue.set_property("min-threshold-time", QUEUE_MIN)
self.queue.set_property("min-threshold-time", QUEUE_MIN_TIME)
self.queue_state = "underrun"

def queue_overrun(self, *args):
Expand All @@ -170,6 +171,8 @@ def get_info(self):
info = SoundPipeline.get_info(self)
if QUEUE_TIME>0:
clt = self.queue.get_property("current-level-time")
info["queue.time"] = int(QUEUE_TIME/MS_TO_NS)
info["queue.min_time"] = int(QUEUE_MIN_TIME/MS_TO_NS)
info["queue.used_pct"] = int(min(QUEUE_TIME, clt)*100.0/QUEUE_TIME)
info["queue.overruns"] = self.overruns
info["queue.state"] = self.queue_state
Expand Down

0 comments on commit 6a167af

Please sign in to comment.