def init_sound_options(self): def sound_option_or_all(*_args): return [] if self.supports_speaker or self.supports_microphone: 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.listget(k) assert val, "%s not found in sound properties" % bytestostr( k) return ".".join(bytestostr(x) for x in val[:3]) bits = self.sound_properties.intget("python.bits", 32) soundlog.info("GStreamer version %s for Python %s %i-bit", vinfo("gst.version"), vinfo("python.version"), bits) except Exception as e: soundlog("failed to query sound", exc_info=True) soundlog.error("Error: failed to query sound subsystem:") soundlog.error(" %s", e) self.speaker_allowed = False self.microphone_allowed = False encoders = self.sound_properties.strlistget("encoders", []) decoders = self.sound_properties.strlistget("decoders", []) self.speaker_codecs = sound_option_or_all("speaker-codec", self.speaker_codec_str, encoders) self.microphone_codecs = sound_option_or_all("microphone-codec", self.microphone_codec_str, decoders) if not self.speaker_codecs: self.supports_speaker = False if not self.microphone_codecs: self.supports_microphone = False if bool(self.sound_properties): try: from xpra.sound.pulseaudio.pulseaudio_util import set_icon_path, get_info as get_pa_info pa_info = get_pa_info() soundlog("pulseaudio info=%s", pa_info) self.sound_properties.update(pa_info) set_icon_path(get_icon_filename("xpra.png")) except ImportError as e: if POSIX and not OSX: log.warn("Warning: failed to set pulseaudio tagging icon:") log.warn(" %s", e) soundlog("init_sound_options speaker: supported=%s, encoders=%s", self.supports_speaker, csv(self.speaker_codecs)) soundlog("init_sound_options microphone: supported=%s, decoders=%s", self.supports_microphone, csv(self.microphone_codecs)) soundlog("init_sound_options sound properties=%s", self.sound_properties)
def query_pulseaudio_properties(self): try: from xpra.sound.pulseaudio.pulseaudio_util import set_icon_path, get_info as get_pa_info pa_info = get_pa_info() soundlog("pulseaudio info=%s", pa_info) self.sound_properties.update(pa_info) set_icon_path(get_icon_filename("xpra.png")) except ImportError as e: if POSIX and not OSX: log.warn("Warning: failed to set pulseaudio tagging icon:") log.warn(" %s", e)
def init_audio_tagging(self, tray_icon): if not POSIX: return try: from xpra import sound assert sound except ImportError: log("no sound module, skipping pulseaudio tagging setup") return try: from xpra.sound.pulseaudio.pulseaudio_util import set_icon_path tray_icon_filename = get_icon_filename(tray_icon or "xpra") set_icon_path(tray_icon_filename) except ImportError as e: if not OSX: log.warn("Warning: failed to set pulseaudio tagging icon:") log.warn(" %s", e)