player/Thread: add attribute `decoder_wakeup_threshold`
Calculate the value only once.
This commit is contained in:
parent
bfd261929e
commit
1191025bbf
|
@ -78,6 +78,16 @@ class Player {
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<Tag> cross_fade_tag;
|
std::unique_ptr<Tag> cross_fade_tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the decoder pipe gets consumed below this threshold,
|
||||||
|
* it's time to wake up the decoder.
|
||||||
|
*
|
||||||
|
* It is calculated in a way which should prevent a wakeup
|
||||||
|
* after each single consumed chunk; it is more efficient to
|
||||||
|
* make the decoder decode a larger block at a time.
|
||||||
|
*/
|
||||||
|
const unsigned decoder_wakeup_threshold;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* are we waiting for buffered_before_play?
|
* are we waiting for buffered_before_play?
|
||||||
*/
|
*/
|
||||||
|
@ -174,7 +184,11 @@ class Player {
|
||||||
public:
|
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),
|
||||||
|
decoder_wakeup_threshold((pc.buffered_before_play +
|
||||||
|
buffer.GetSize() * 3) / 4)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -886,9 +900,7 @@ Player::PlayNextChunk() noexcept
|
||||||
/* this formula should prevent that the decoder gets woken up
|
/* this formula should prevent that the decoder gets woken up
|
||||||
with each chunk; it is more efficient to make it decode a
|
with each chunk; it is more efficient to make it decode a
|
||||||
larger block at a time */
|
larger block at a time */
|
||||||
if (!dc.IsIdle() &&
|
if (!dc.IsIdle() && dc.pipe->GetSize() <= decoder_wakeup_threshold) {
|
||||||
dc.pipe->GetSize() <= (pc.buffered_before_play +
|
|
||||||
buffer.GetSize() * 3) / 4) {
|
|
||||||
if (!decoder_woken) {
|
if (!decoder_woken) {
|
||||||
decoder_woken = true;
|
decoder_woken = true;
|
||||||
dc.Signal();
|
dc.Signal();
|
||||||
|
|
Loading…
Reference in New Issue