xpra icon
Bug tracker and wiki

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


Ticket #379: sound-restart-from-underrun.patch

File sound-restart-from-underrun.patch, 2.5 KB (added by Antoine Martin, 8 years ago)

another attempt at getting sound to restart on OSX via an underrun signal without stop/start

  • src/xpra/client/ui_client_base.py

    ### Eclipse Workspace Patch 1.0
    #P Xpra
     
    104104            self.microphone_allowed = len(self.microphone_codecs)>0
    105105        self.sink_restart_pending = False
    106106        self.on_sink_ready = None
     107        self.on_sink_underrun = None
    107108        self.sound_sink = None
    108109        self.server_sound_sequence = False
    109110        self.min_sound_sequence = 0
     
    897898        log.warn("stopping speaker because of error: %s", error)
    898899        self.stop_receiving_sound()
    899900
     901    def sound_sink_underrun(self, *args):
     902        soundlog("sound_sink_underrun(%s) on_sink_underrun=%s", args, self.on_sink_underrun)
     903        if self.on_sink_underrun:
     904            if not self.on_sink_underrun():
     905                self.on_sink_underrun = None
     906
    900907    def sound_sink_overrun(self, *args):
    901908        log.warn("re-starting speaker because of overrun")
    902909        if self.sink_restart_pending:
     
    904911        codec = self.sound_sink.codec
    905912        self.sink_restart_pending = True
    906913        if self.server_sound_sequence:
     914            #ignore current sequence and wait for underrun
    907915            self.min_sound_sequence += 1
    908         #Note: the next sound packet will take care of starting a new pipeline
     916            def sink_underrun(*args):
     917                soundlog("sink_underrun(%s)", args)
     918                self.sink_restart_pending = False
     919                self.send_new_sound_sequence()
     920                return False
     921            self.on_sink_underrun = sink_underrun
     922            return
     923
    909924        self.stop_receiving_sound()
    910925        def restart():
    911926            soundlog("restart() sound_sink=%s, codec=%s, server_sound_sequence=%s", self.sound_sink, codec, self.server_sound_sequence)
    912             if self.server_sound_sequence:
    913                 self.send_new_sound_sequence()
    914927            self.sink_restart_pending = False
    915928            self.start_receiving_sound()
    916929            return False
     
    927940            self.sound_sink.connect("bitrate-changed", self.sound_sink_bitrate_changed)
    928941            self.sound_sink.connect("error", self.sound_sink_error)
    929942            self.sound_sink.connect("overrun", self.sound_sink_overrun)
     943            self.sound_sink.connect("underrun", self.sound_sink_underrun)
    930944            self.sound_sink.start()
    931945            soundlog("%s sound sink started", codec)
    932946            return True