bpd: support volume command for real

This commit is contained in:
Carl Suster 2019-04-15 14:19:09 +10:00
parent 5c37a58ad6
commit 1a5263b68f
2 changed files with 9 additions and 3 deletions

View file

@ -454,7 +454,8 @@ class BaseServer(object):
def cmd_volume(self, conn, vol_delta):
"""Deprecated command to change the volume by a relative amount."""
raise BPDError(ERROR_SYSTEM, u'No mixer')
vol_delta = cast_arg(int, vol_delta)
return self.cmd_setvol(conn, self.volume + vol_delta)
def cmd_crossfade(self, conn, crossfade):
"""Set the number of seconds of crossfading."""

View file

@ -623,8 +623,13 @@ class BPDPlaybackTest(BPDTestHelper):
def test_cmd_volume(self):
with self.run_bpd() as client:
response = client.send_command('volume', '10')
self._assert_failed(response, bpd.ERROR_SYSTEM)
responses = client.send_commands(
('setvol', '10'),
('volume', '5'),
('volume', '-2'),
('status',))
self._assert_ok(*responses)
self.assertEqual('13', responses[3].data['volume'])
def test_cmd_replay_gain(self):
with self.run_bpd() as client: