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.
This commit is contained in:
Carl Suster 2019-03-30 19:03:38 +11:00
parent de6718abdf
commit d94a5393b2
2 changed files with 19 additions and 2 deletions

View file

@ -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."""

View file

@ -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({