MusicPlayerDaemon / MPD

Music Player Daemon
https://www.musicpd.org/
GNU General Public License v2.0
2.16k stars 346 forks source link

IO-less playback of current file #603

Open JustArchi opened 5 years ago

JustArchi commented 5 years ago

Question/Feature request

I have rather specific usage case that I'd like MPD to work with. In particular, I'd like to be able to modify the currently played file on-the-fly, without interrupting MPD's playback. This could be needed for various reasons, including unstable network shares, exclusive file access, or like in my case, metadata modifications that change the size (and therefore exact place of the audio stream, stopping the playback).

Right now for achieving that I'm using huge audio_buffer_size hack, but that solution is very suboptimal as MPD needs to keep memory equal to that size always allocated, even if the file itself is much smaller, not to mention that it can still not be enough depending on circumstances (the limit is around 131 MB).

I've noticed recent work on input_cache and it looks like it'd almost entirely satisfy me, as long as it's possible to slightly tweak it: instead of accepting maximum cache size, I'd like to be able to specify maximum number of songs that are supposed to be cached in advance, with 1 being the current one.

This is how I see it:

input_cache {
        size "256 MB"
}

^ MPD allocates static 256 MB and makes use of it entirely to fill as much data as possible. This is currently implemented to the best of my knowledge.

input_cache {
        count "1"
}

^ My target scenario, MPD reads up to count files in advance (with 1 specifying current song, so 2 would be current + next etc), and keeps read files in memory until song change (on which the cache advances and next song is read). It'd be the best if MPD could dynamically adapt memory usage to the size of the file, so small files would not put as much pressure on the process, while big ones could still benefit from it.

input_cache {
        count "1"
        size "256 MB"
}

^ Like above, but MPD will never allow the size to grow past specified size, which effectively limits extra memory usage to value specified by the user (as opposed to above config, which doesn't put any limit on it).

Let me know what you think, I'd be happy to further evaluate if needed, and I consider this a very good idea for at least several different scenarios. The above is only my suggestion what could be done in regards to that, I'll be happy with any solution that would allow me to configure MPD in order to read currently played file in full. Thank you in advance for your evaluation.

lulumeya commented 2 years ago

I would love to use this feature, too. Btw, Can I see input cache logs?