From f25d7096e0e4d902d5f6f5942023389f94d42780 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Tue, 16 Jul 2019 04:27:30 +0000 Subject: [PATCH] #1773: start sending audio, test fadeout and stop packets git-svn-id: https://xpra.org/svn/Xpra/trunk@23141 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/unittests/unit/server/mixins/audio_test.py | 11 ++++++++++- .../unit/server/mixins/servermixintest_util.py | 8 ++++++++ src/xpra/server/mixins/audio_server.py | 2 -- src/xpra/server/source/audio_mixin.py | 14 ++++++++------ src/xpra/server/source/stub_source_mixin.py | 7 +++++++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/unittests/unit/server/mixins/audio_test.py b/src/unittests/unit/server/mixins/audio_test.py index 4ce3bbdb5c..5ae6807e33 100755 --- a/src/unittests/unit/server/mixins/audio_test.py +++ b/src/unittests/unit/server/mixins/audio_test.py @@ -4,6 +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 time import unittest from xpra.util import AdHocStruct @@ -14,6 +15,7 @@ class AudioMixinTest(ServerMixinTest): def test_audio(self): from xpra.server.mixins.audio_server import AudioServer + from xpra.server.source.audio_mixin import AudioMixin opts = AdHocStruct() opts.sound_source = "" opts.speaker = "on" @@ -23,7 +25,14 @@ def test_audio(self): opts.pulseaudio = True opts.pulseaudio_command = "" opts.pulseaudio_configure_commands = [] - self._test_mixin_class(AudioServer, opts) + self._test_mixin_class(AudioServer, opts, { + "sound.receive" : True, + "sound.decoders" : ("mp3",), + }, AudioMixin) + self.handle_packet(("sound-control", "start", "mp3")) + time.sleep(1) + self.handle_packet(("sound-control", "fadeout")) + time.sleep(1) self.handle_packet(("sound-control", "stop")) def main(): diff --git a/src/unittests/unit/server/mixins/servermixintest_util.py b/src/unittests/unit/server/mixins/servermixintest_util.py index 2592cb0347..6541d87258 100755 --- a/src/unittests/unit/server/mixins/servermixintest_util.py +++ b/src/unittests/unit/server/mixins/servermixintest_util.py @@ -33,6 +33,10 @@ def tearDown(self): self.mixin.cleanup() self.mixin = None + def debug_all(self): + from xpra.log import enable_debug_for + enable_debug_for("all") + def stop(self): self.glib.timeout_add(1000, self.main_loop.quit) @@ -73,7 +77,11 @@ def _test_mixin_class(self, mclass, opts, caps=None, source_mixin_class=None): if source_mixin_class: self.source = source_mixin_class() self.protocol = AdHocStruct() + self.source.timeout_add = self.glib.timeout_add + self.source.idle_add = self.glib.idle_add + self.source.source_remove = self.glib.source_remove self.source.protocol = self.protocol + self.source.init_from(self.protocol, x) self.source.init_state() self.source.parse_client_caps(caps) self.source.get_info() diff --git a/src/xpra/server/mixins/audio_server.py b/src/xpra/server/mixins/audio_server.py index 643dc2d2b6..5b266ce62c 100644 --- a/src/xpra/server/mixins/audio_server.py +++ b/src/xpra/server/mixins/audio_server.py @@ -329,8 +329,6 @@ def _process_sound_data(self, proto, packet): def init_packet_handlers(self): - log.info("AudioServer.init_packet_handlers() supports speaker=%s, microphone=%s", - self.supports_speaker, self.supports_microphone) if self.supports_speaker or self.supports_microphone: self.add_packet_handlers({ "sound-control" : self._process_sound_control, diff --git a/src/xpra/server/source/audio_mixin.py b/src/xpra/server/source/audio_mixin.py index 0762373cff..2afd1357e7 100644 --- a/src/xpra/server/source/audio_mixin.py +++ b/src/xpra/server/source/audio_mixin.py @@ -93,13 +93,17 @@ def audio_loop_check(self, mode="speaker"): return True machine_id = get_machine_id() uuid = get_user_uuid() + #these attributes belong in a different mixin, + #so we can't assume that they exist: + client_machine_id = getattr(self, "machine_id", None) + client_uuid = getattr(self, "uuid", None) log("audio_loop_check(%s) machine_id=%s client machine_id=%s, uuid=%s, client uuid=%s", - mode, machine_id, self.machine_id, uuid, self.uuid) - if self.machine_id: - if self.machine_id!=machine_id: + mode, machine_id, client_machine_id, uuid, client_uuid) + if client_machine_id: + if client_machine_id!=machine_id: #not the same machine, so OK return True - if self.uuid!=uuid: + if client_uuid!=uuid: #different user, assume different pulseaudio server return True #check pulseaudio id if we have it @@ -131,7 +135,6 @@ def audio_loop_check(self, mode="speaker"): def start_sending_sound(self, codec=None, volume=1.0, new_stream=None, new_buffer=None, skip_client_codec_check=False): - assert self.hello_sent log("start_sending_sound(%s)", codec) ss = None if getattr(self, "suspended", False): @@ -310,7 +313,6 @@ def stop_receiving_sound(self): ########################################################################## # sound control commands: def sound_control(self, action, *args): - assert self.hello_sent action = bytestostr(action) log("sound_control(%s, %s)", action, args) method = getattr(self, "sound_control_%s" % (action.replace("-", "_")), None) diff --git a/src/xpra/server/source/stub_source_mixin.py b/src/xpra/server/source/stub_source_mixin.py index a9c44eb199..e2c50184fd 100644 --- a/src/xpra/server/source/stub_source_mixin.py +++ b/src/xpra/server/source/stub_source_mixin.py @@ -67,3 +67,10 @@ def user_event(self): """ def may_notify(self, *args, **kwargs): pass + + + def send_more(self, *parts, **kwargs): + pass + + def send_async(self, *parts, **kwargs): + pass