Closed whomwah closed 6 years ago
MPD supports a command called idle
, which will stall the connection and report back when there is any change. One option would be opening a second connection to MPD and then waiting for an update on that socket.
I think it would be much more optimal as we get rid of polling every 100ms.
idle
certainly looks interesting and worth exploring. I see that it only lets you know there has been a change in a subsystem and does not let you know what that change is. It's up to you to find that out. All thought I guess a simple mpd.status
would be enough.
Yeah, that's the idea. Any time idle returns, just fetch mpd.status
.
Testing
callback_thread
is proving complex. I think the method needs refactoring first to try and move some of the logic elsewhere to try and make it easier to test. I'll create another branch to try this out. I also found the way@socket
is set confusing. May try and work on that too in another branch for review.