From 27c462d287a7c4788a2f3aab6fe9410ea19098c2 Mon Sep 17 00:00:00 2001 From: Carl Suster Date: Mon, 15 Apr 2019 15:08:47 +1000 Subject: [PATCH] bpd: make noidle a no-op outside idle mode The real MPD ignores `noidle` when the client is not idle. It doesn't even send a successful response, just ignores the command. Although I don't understand why a client would fail to keep track of its own state, it seems that this is necessary to get ncmpcpp working. --- beetsplug/bpd/__init__.py | 3 +++ test/test_player.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index 7c40cb6b6..97d89d914 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -847,6 +847,9 @@ class MPDConnection(Connection): yield self.send(err.response()) break continue + if line == u'noidle': + # When not in idle, this command sends no response. + continue if clist is not None: # Command list already opened. diff --git a/test/test_player.py b/test/test_player.py index 048f2cedd..f22c19261 100644 --- a/test/test_player.py +++ b/test/test_player.py @@ -457,6 +457,14 @@ class BPDQueryTest(BPDTestHelper): response = client.send_command('noidle') self._assert_ok(response) + def test_cmd_noidle_when_not_idle(self): + with self.run_bpd() as client: + # Manually send a command without reading a response. + request = client.serialise_command('noidle') + client.sock.sendall(request) + response = client.send_command('notacommand') + self._assert_failed(response, bpd.ERROR_UNKNOWN) + class BPDPlaybackTest(BPDTestHelper): test_implements_playback = implements({