Commit c1600bcf authored by Max Kellermann's avatar Max Kellermann

player/Thread: copy `buffered_before_play`

parent a82d864c
...@@ -79,6 +79,12 @@ class Player { ...@@ -79,6 +79,12 @@ class Player {
std::unique_ptr<Tag> cross_fade_tag; std::unique_ptr<Tag> cross_fade_tag;
/** /**
* Start playback as soon as this number of chunks has been
* pushed to the decoder pipe.
*/
const unsigned buffer_before_play;
/**
* If the decoder pipe gets consumed below this threshold, * If the decoder pipe gets consumed below this threshold,
* it's time to wake up the decoder. * it's time to wake up the decoder.
* *
...@@ -89,7 +95,7 @@ class Player { ...@@ -89,7 +95,7 @@ class Player {
const unsigned decoder_wakeup_threshold; const unsigned decoder_wakeup_threshold;
/** /**
* are we waiting for buffered_before_play? * Are we waiting for #buffer_before_play?
*/ */
bool buffering = true; bool buffering = true;
...@@ -185,6 +191,7 @@ public: ...@@ -185,6 +191,7 @@ public:
Player(PlayerControl &_pc, DecoderControl &_dc, Player(PlayerControl &_pc, DecoderControl &_dc,
MusicBuffer &_buffer) noexcept MusicBuffer &_buffer) noexcept
:pc(_pc), dc(_dc), buffer(_buffer), :pc(_pc), dc(_dc), buffer(_buffer),
buffer_before_play(pc.buffered_before_play),
decoder_wakeup_threshold(buffer.GetSize() * 3 / 4) decoder_wakeup_threshold(buffer.GetSize() * 3 / 4)
{ {
} }
...@@ -954,7 +961,7 @@ Player::Run() noexcept ...@@ -954,7 +961,7 @@ Player::Run() noexcept
until the buffer is large enough, to until the buffer is large enough, to
prevent stuttering on slow machines */ prevent stuttering on slow machines */
if (pipe->GetSize() < pc.buffered_before_play && if (pipe->GetSize() < buffer_before_play &&
!dc.IsIdle() && !buffer.IsFull()) { !dc.IsIdle() && !buffer.IsFull()) {
/* not enough decoded buffer space yet */ /* not enough decoded buffer space yet */
...@@ -1002,7 +1009,7 @@ Player::Run() noexcept ...@@ -1002,7 +1009,7 @@ Player::Run() noexcept
dc.out_audio_format, dc.out_audio_format,
play_audio_format, play_audio_format,
buffer.GetSize() - buffer.GetSize() -
pc.buffered_before_play); buffer_before_play);
if (cross_fade_chunks > 0) if (cross_fade_chunks > 0)
xfade_state = CrossFadeState::ENABLED; xfade_state = CrossFadeState::ENABLED;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment