fix(mpd): regularly timeout the event listener to prevent timeout

The MPD server has a connection_timeout that defaults to 60. If no data
is transferred in this timespan, the connection is closed. If the
connection is closed while the event listener is listening for events,
it will block forever. By timing out the event listening and
re-connecting regularly, we prevent this issue. An option "timeout" has
been added for users that have a lower server connection_timeout than
default. Fixes #277
This commit is contained in:
Minijackson
2019-04-21 10:54:40 +02:00
parent 768bc29bc1
commit b50650f63f
2 changed files with 51 additions and 21 deletions

View File

@ -48,6 +48,8 @@ class MPD : public ALabel {
const char* server_;
const unsigned port_;
unsigned timeout_;
// We need a mutex here because we can trigger updates from multiple thread:
// the event based updates, the periodic updates needed for the elapsed time,
// and the click play/pause feature