示例#1
0
 def init(self, opts):
     self.sound_source_plugin = opts.sound_source
     self.supports_speaker = sound_option(opts.speaker) in ("on", "off")
     self.supports_microphone = sound_option(opts.microphone) in ("on",
                                                                  "off")
     self.pulseaudio = opts.pulseaudio
     self.pulseaudio_command = opts.pulseaudio_command
     self.pulseaudio_configure_commands = opts.pulseaudio_configure_commands
示例#2
0
 def init(self, opts):
     self.sound_source_plugin = opts.sound_source
     self.supports_speaker = sound_option(opts.speaker) in ("on", "off")
     if self.supports_speaker:
         self.speaker_codecs = opts.speaker_codec
     self.supports_microphone = sound_option(opts.microphone) in ("on", "off")
     if self.supports_microphone:
         self.microphone_codecs = opts.microphone_codec
     self.pulseaudio = opts.pulseaudio
     self.pulseaudio_command = opts.pulseaudio_command
     self.pulseaudio_configure_commands = opts.pulseaudio_configure_commands
     log("AudioServer.init(..) supports speaker=%s, microphone=%s",
         self.supports_speaker, self.supports_microphone)
     self.av_sync = opts.av_sync
     log("AudioServer.init(..) av-sync=%s", self.av_sync)
示例#3
0
    def init(self, opts):
        self.av_sync = opts.av_sync
        self.sound_properties = typedict()
        self.speaker_allowed = sound_option(opts.speaker) in ("on", "off")
        #ie: "on", "off", "on:Some Device", "off:Some Device"
        mic = [x.strip() for x in opts.microphone.split(":", 1)]
        self.microphone_allowed = sound_option(mic[0]) in ("on", "off")
        self.microphone_device = None
        if self.microphone_allowed and len(mic) == 2:
            self.microphone_device = mic[1]
        self.sound_source_plugin = opts.sound_source

        def sound_option_or_all(*_args):
            return []

        if self.speaker_allowed or self.microphone_allowed:
            try:
                from xpra.sound import common
                assert common
            except ImportError as e:
                self.may_notify_audio(
                    "No Audio", "audio subsystem is not installed\n" +
                    " speaker and microphone forwarding are disabled")
                self.speaker_allowed = False
                self.microphone_allowed = False
            else:
                try:
                    from xpra.sound.common import sound_option_or_all
                    from xpra.sound.wrapper import query_sound
                    self.sound_properties = query_sound()
                    assert self.sound_properties, "query did not return any data"

                    def vinfo(k):
                        val = self.sound_properties.strtupleget(k)
                        assert val, "%s not found in sound properties" % k
                        return ".".join(val[:3])

                    bits = self.sound_properties.intget("python.bits", 32)
                    log.info("GStreamer version %s for Python %s %s-bit",
                             vinfo("gst.version"), vinfo("python.version"),
                             bits)
                except Exception as e:
                    log("failed to query sound", exc_info=True)
                    log.error("Error: failed to query sound subsystem:")
                    log.error(" %s", e)
                    self.speaker_allowed = False
                    self.microphone_allowed = False
        encoders = self.sound_properties.strtupleget("encoders")
        decoders = self.sound_properties.strtupleget("decoders")
        self.speaker_codecs = sound_option_or_all("speaker-codec",
                                                  opts.speaker_codec, decoders)
        self.microphone_codecs = sound_option_or_all("microphone-codec",
                                                     opts.microphone_codec,
                                                     encoders)
        if not self.speaker_codecs:
            self.speaker_allowed = False
        if not self.microphone_codecs:
            self.microphone_allowed = False
        self.speaker_enabled = self.speaker_allowed and sound_option(
            opts.speaker) == "on"
        self.microphone_enabled = self.microphone_allowed and opts.microphone.lower(
        ) == "on"
        log("speaker: codecs=%s, allowed=%s, enabled=%s", encoders,
            self.speaker_allowed, csv(self.speaker_codecs))
        log("microphone: codecs=%s, allowed=%s, enabled=%s, default device=%s",
            decoders, self.microphone_allowed, csv(self.microphone_codecs),
            self.microphone_device)
        log("av-sync=%s", self.av_sync)
        if POSIX and not OSX:
            try:
                from xpra.sound.pulseaudio.pulseaudio_util import get_info as get_pa_info
                pa_info = get_pa_info()
                log("pulseaudio info=%s", pa_info)
                self.sound_properties.update(pa_info)
            except ImportError as e:
                log.warn("Warning: no pulseaudio information available")
                log.warn(" %s", e)
            except Exception:
                log.error("failed to add pulseaudio info", exc_info=True)
        #audio tagging:
        self.init_audio_tagging(opts.tray_icon)