diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/config/Templates.cxx | 2 | ||||
-rw-r--r-- | src/player/Thread.cxx | 18 |
3 files changed, 17 insertions, 4 deletions
@@ -14,6 +14,7 @@ ver 0.21 (not yet released) - proxy: require libmpdclient 2.9 - proxy: forward `sort` and `window` to server * player + - hard-code "buffer_before_play" to 1 second, independent of audio format - "one-shot" single mode * input - curl: download to buffer instead of throttling transfer diff --git a/src/config/Templates.cxx b/src/config/Templates.cxx index 3c2d78aae..8df588aca 100644 --- a/src/config/Templates.cxx +++ b/src/config/Templates.cxx @@ -54,7 +54,7 @@ const ConfigTemplate config_param_templates[] = { { "volume_normalization" }, { "samplerate_converter" }, { "audio_buffer_size" }, - { "buffer_before_play" }, + { "buffer_before_play", false, true }, { "http_proxy_host", false, true }, { "http_proxy_port", false, true }, { "http_proxy_user", false, true }, diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 017e4c5be..cd930c039 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -57,6 +57,12 @@ static constexpr Domain player_domain("player"); +/** + * Start playback as soon as enough data for this duration has been + * pushed to the decoder pipe. + */ +static constexpr auto buffer_before_play_duration = std::chrono::seconds(1); + class Player { PlayerControl &pc; @@ -80,9 +86,10 @@ class Player { /** * Start playback as soon as this number of chunks has been - * pushed to the decoder pipe. + * pushed to the decoder pipe. This is calculated based on + * #buffer_before_play_duration. */ - const unsigned buffer_before_play; + unsigned buffer_before_play; /** * If the decoder pipe gets consumed below this threshold, @@ -191,7 +198,6 @@ public: Player(PlayerControl &_pc, DecoderControl &_dc, MusicBuffer &_buffer) noexcept :pc(_pc), dc(_dc), buffer(_buffer), - buffer_before_play(pc.buffered_before_play), decoder_wakeup_threshold(buffer.GetSize() * 3 / 4) { } @@ -517,6 +523,12 @@ Player::CheckDecoderStartup() noexcept play_audio_format = dc.out_audio_format; decoder_starting = false; + const size_t buffer_before_play_size = + play_audio_format.TimeToSize(buffer_before_play_duration); + buffer_before_play = + (buffer_before_play_size + sizeof(MusicChunk::data) - 1) + / sizeof(MusicChunk::data); + idle_add(IDLE_PLAYER); if (pending_seek > SongTime::zero()) { |