diff --git a/src/xpra/sound/sink.py b/src/xpra/sound/sink.py index 56718cbfbd..82c2366562 100755 --- a/src/xpra/sound/sink.py +++ b/src/xpra/sound/sink.py @@ -4,7 +4,7 @@ # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. -import sys, os +import sys, os, time from xpra.sound.sound_pipeline import SoundPipeline, debug from xpra.sound.pulseaudio_util import has_pa @@ -30,8 +30,8 @@ GST_QUEUE_LEAK_UPSTREAM = 1 GST_QUEUE_LEAK_DOWNSTREAM = 2 -QUEUE_LEAK = int(os.environ.get("XPRA_SOUND_QUEUE_LEAK", GST_QUEUE_NO_LEAK)) -QUEUE_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_TIME", "200"))*1000000 #ns +QUEUE_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_TIME", "400"))*1000000 #ns +QUEUE_START_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_START_TIME", "200"))*1000000 #ns QUEUE_MIN_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_MIN_TIME", "50"))*1000000 #ns QUEUE_TIME = max(0, QUEUE_TIME) QUEUE_MIN_TIME = max(0, min(QUEUE_TIME, QUEUE_MIN_TIME)) @@ -64,7 +64,7 @@ def __init__(self, sink_type=DEFAULT_SINK, options={}, codec=MP3, decoder_option self.sink_type = sink_type decoder_str = plugin_str(decoder, decoder_options) pipeline_els = [] - pipeline_els.append("appsrc name=src max-bytes=8192") + pipeline_els.append("appsrc name=src max-bytes=512") pipeline_els.append(parser) pipeline_els.append(decoder_str) if VOLUME: @@ -76,10 +76,10 @@ def __init__(self, sink_type=DEFAULT_SINK, options={}, codec=MP3, decoder_option pipeline_els.append("queue" + " name=queue"+ " min-threshold-time=%s" % QUEUE_MIN_TIME+ - " max-size-time=%s" % QUEUE_TIME+ - " leaky=%s" % QUEUE_LEAK) + " max-size-time=%s" % QUEUE_START_TIME+ + " leaky=%s" % GST_QUEUE_LEAK_DOWNSTREAM) else: - pipeline_els.append("queue leaky=%s" % QUEUE_LEAK) + pipeline_els.append("queue leaky=%s" % GST_QUEUE_LEAK_DOWNSTREAM) pipeline_els.append(sink_type) self.setup_pipeline_and_bus(pipeline_els) self.volume = self.pipeline.get_by_name("volume") @@ -93,6 +93,13 @@ def __init__(self, sink_type=DEFAULT_SINK, options={}, codec=MP3, decoder_option self.queue = self.pipeline.get_by_name("queue") def overrun(*args): debug("sound sink queue overrun: level=%s", int(self.queue.get_property("current-level-time")/1000000)) + #no overruns for the first 2 seconds: + if time.time()-self.start_time<2.0: + return + #if we haven't done so yet, just bump the max-size-time + if int(self.queue.get_property("max-size-time")) < QUEUE_TIME: + self.queue.set_property("max-size-time", QUEUE_TIME) + return self.emit("overrun") def underrun(*args): debug("sound sink queue underrun: level=%s", int(self.queue.get_property("current-level-time")/1000000)) diff --git a/src/xpra/sound/sound_pipeline.py b/src/xpra/sound/sound_pipeline.py index caff1ecdf1..bfc0c71e50 100755 --- a/src/xpra/sound/sound_pipeline.py +++ b/src/xpra/sound/sound_pipeline.py @@ -3,6 +3,8 @@ # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. +import time + from xpra.signal_object import SignalObject from xpra.sound.gstreamer_util import gst from xpra.log import Logger, debug_if_env @@ -28,6 +30,7 @@ def __init__(self, codec): self.bus_message_handler_id = None self.bitrate = -1 self.pipeline = None + self.start_time = 0 self.state = "stopped" self.buffer_count = 0 self.byte_count = 0 @@ -49,6 +52,7 @@ def setup_pipeline_and_bus(self, elements): debug("pipeline elements=%s", elements) pipeline_str = " ! ".join([x for x in elements if x is not None]) debug("pipeline=%s", pipeline_str) + self.start_time = time.time() self.pipeline = gst.parse_launch(pipeline_str) self.bus = self.pipeline.get_bus() self.bus_message_handler_id = self.bus.connect("message", self.on_message)