From d94a5393b2929cdfc0c759728ad185b8d40f68dd Mon Sep 17 00:00:00 2001 From: Carl Suster Date: Sat, 30 Mar 2019 19:03:38 +1100 Subject: [PATCH] bpd: fix crossfade command Although crossfade is not implemented in bpd, we can store the setting and repeat is back to clients. Also log a warning that the operation is not implemented. The real MPD doesn't show the crossfade in status if it's zero since that means no crossfade, so now we don't either. --- beetsplug/bpd/__init__.py | 6 +++++- test/test_player.py | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index a29690b03..0d16e22ca 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -307,9 +307,11 @@ class BaseServer(object): u'random: ' + six.text_type(int(self.random)), u'playlist: ' + six.text_type(self.playlist_version), u'playlistlength: ' + six.text_type(len(self.playlist)), - u'xfade: ' + six.text_type(self.crossfade), ) + if self.crossfade > 0: + yield u'xfade: ' + six.text_type(self.crossfade) + if self.current_index == -1: state = u'stop' elif self.paused: @@ -353,6 +355,8 @@ class BaseServer(object): crossfade = cast_arg(int, crossfade) if crossfade < 0: raise BPDError(ERROR_ARG, u'crossfade time must be nonnegative') + self._log.warning(u'crossfade is not implemented in bpd') + self.crossfade = crossfade def cmd_clear(self, conn): """Clear the playlist.""" diff --git a/test/test_player.py b/test/test_player.py index 1e917f078..d7f65ff3f 100644 --- a/test/test_player.py +++ b/test/test_player.py @@ -356,11 +356,24 @@ class BPDQueryTest(BPDTestHelper): class BPDPlaybackTest(BPDTestHelper): test_implements_playback = implements({ - 'consume', 'crossfade', 'mixrampd', 'mixrampdelay', 'random', + 'consume', 'mixrampd', 'mixrampdelay', 'random', 'repeat', 'setvol', 'single', 'replay_gain_mode', 'replay_gain_status', 'volume', }, expectedFailure=True) + def test_cmd_crossfade(self): + with self.run_bpd() as client: + responses = client.send_commands( + ('status',), + ('crossfade', '123'), + ('status',), + ('crossfade', '-2')) + response = client.send_command('crossfade', '0.5') + self._assert_failed(responses, bpd.ERROR_ARG, pos=3) + self._assert_failed(response, bpd.ERROR_ARG) + self.assertNotIn('xfade', responses[0].data) + self.assertAlmostEqual(123, int(responses[2].data['xfade'])) + class BPDControlTest(BPDTestHelper): test_implements_control = implements({