xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #362: drop-early-overruns.patch

File drop-early-overruns.patch, 4.1 KB (added by Antoine Martin, 8 years ago)

should help avoid repeated overruns

  • xpra/sound/sink.py

     
    44# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
    55# later version. See the file COPYING for details.
    66
    7 import sys, os
     7import sys, os, time
    88
    99from xpra.sound.sound_pipeline import SoundPipeline, debug
    1010from xpra.sound.pulseaudio_util import has_pa
     
    3030GST_QUEUE_LEAK_UPSTREAM       = 1
    3131GST_QUEUE_LEAK_DOWNSTREAM     = 2
    3232
    33 QUEUE_LEAK = int(os.environ.get("XPRA_SOUND_QUEUE_LEAK", GST_QUEUE_NO_LEAK))
    34 QUEUE_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_TIME", "200"))*1000000        #ns
     33QUEUE_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_TIME", "400"))*1000000        #ns
     34QUEUE_START_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_START_TIME", "200"))*1000000        #ns
    3535QUEUE_MIN_TIME = int(os.environ.get("XPRA_SOUND_QUEUE_MIN_TIME", "50"))*1000000 #ns
    3636QUEUE_TIME = max(0, QUEUE_TIME)
    3737QUEUE_MIN_TIME = max(0, min(QUEUE_TIME, QUEUE_MIN_TIME))
     
    6464        self.sink_type = sink_type
    6565        decoder_str = plugin_str(decoder, decoder_options)
    6666        pipeline_els = []
    67         pipeline_els.append("appsrc name=src max-bytes=8192")
     67        pipeline_els.append("appsrc name=src max-bytes=512")
    6868        pipeline_els.append(parser)
    6969        pipeline_els.append(decoder_str)
    7070        if VOLUME:
     
    7676                pipeline_els.append("queue" +
    7777                                    " name=queue"+
    7878                                    " min-threshold-time=%s" % QUEUE_MIN_TIME+
    79                                     " max-size-time=%s" % QUEUE_TIME+
    80                                     " leaky=%s" % QUEUE_LEAK)
     79                                    " max-size-time=%s" % QUEUE_START_TIME+
     80                                    " leaky=%s" % GST_QUEUE_LEAK_DOWNSTREAM)
    8181            else:
    82                 pipeline_els.append("queue leaky=%s" % QUEUE_LEAK)
     82                pipeline_els.append("queue leaky=%s" % GST_QUEUE_LEAK_DOWNSTREAM)
    8383        pipeline_els.append(sink_type)
    8484        self.setup_pipeline_and_bus(pipeline_els)
    8585        self.volume = self.pipeline.get_by_name("volume")
     
    9393            self.queue = self.pipeline.get_by_name("queue")
    9494            def overrun(*args):
    9595                debug("sound sink queue overrun: level=%s", int(self.queue.get_property("current-level-time")/1000000))
     96                #no overruns for the first 2 seconds:
     97                if time.time()-self.start_time<2.0:
     98                    return
     99                #if we haven't done so yet, just bump the max-size-time
     100                if int(self.queue.get_property("max-size-time")) < QUEUE_TIME:
     101                    self.queue.set_property("max-size-time", QUEUE_TIME)
     102                    return
    96103                self.emit("overrun")
    97104            def underrun(*args):
    98105                debug("sound sink queue underrun: level=%s", int(self.queue.get_property("current-level-time")/1000000))
  • xpra/sound/sound_pipeline.py

     
    33# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
    44# later version. See the file COPYING for details.
    55
     6import time
     7
    68from xpra.signal_object import SignalObject
    79from xpra.sound.gstreamer_util import gst
    810from xpra.log import Logger, debug_if_env
     
    2830        self.bus_message_handler_id = None
    2931        self.bitrate = -1
    3032        self.pipeline = None
     33        self.start_time = 0
    3134        self.state = "stopped"
    3235        self.buffer_count = 0
    3336        self.byte_count = 0
     
    4952        debug("pipeline elements=%s", elements)
    5053        pipeline_str = " ! ".join([x for x in elements if x is not None])
    5154        debug("pipeline=%s", pipeline_str)
     55        self.start_time = time.time()
    5256        self.pipeline = gst.parse_launch(pipeline_str)
    5357        self.bus = self.pipeline.get_bus()
    5458        self.bus_message_handler_id = self.bus.connect("message", self.on_message)