MPD icon indicating copy to clipboard operation
MPD copied to clipboard

add exit on idle mode

Open twojstaryzdomu opened this issue 3 years ago • 3 comments

Feature request

Related to the ignored feature proposed on #1317. It's difficult to get any sort of response there. In essence, stop mpd process when mpd has been idle for a certain amount of time. Activating playback, a scan or otherwise interacting with mpd would stop and reset the timer. When prompted by the idle timer, Mpd should terminate with the zero status to allow mpd service to return exitted rather than faulted for the systemd mpd service. This will be useful with systemd socket activation to save resources and forgo the need to start mpd service, only the mpd socket (listener). The socket will ensure mpd can always be started whereas the idle timer will stop mpd when no longer needed.

twojstaryzdomu avatar Oct 30 '21 08:10 twojstaryzdomu

I'm not interested in spending time on such a feature. But maybe you can develop it and send a pull request.

MaxKellermann avatar Oct 31 '21 11:10 MaxKellermann

Do you have any clue how it could be implemented? A separate thread for the timer?

twojstaryzdomu avatar Nov 04 '21 16:11 twojstaryzdomu

No thread! A new thread causes lots of headaches for thread-safety - I mean, how should that thread learn about new activity? How will it tell MPD to exit? How will it be shut down? What you need is a CoarseTimerEvent in the main thread's EventLoop which gets (re-)scheduled with the configured duration every time something happens (client command? playback stopped in all partitions?); and should probably be canceled whenever at least one partition plays something.

MaxKellermann avatar Nov 04 '21 16:11 MaxKellermann