diff options
author | Max Kellermann <max@duempel.org> | 2008-10-10 16:47:57 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-10 16:47:57 +0200 |
commit | 17d9c1708b5afe32c362fdaba114e74f64a7dd06 (patch) | |
tree | 530967bf2c6bd2b8e29c89df5fcf93e9dab4d03f /src | |
parent | f41fe1e0b5d86470fab406831c18d032e9835d84 (diff) | |
download | mpd-17d9c1708b5afe32c362fdaba114e74f64a7dd06.tar.gz mpd-17d9c1708b5afe32c362fdaba114e74f64a7dd06.tar.xz mpd-17d9c1708b5afe32c362fdaba114e74f64a7dd06.zip |
player: don't wake up decoder after every frame
The decoder was woken up after each chunk which had been played. That
caused a lot of superfluous context switches. Wake up the decoder
only when a certain amount of the buffer has been consumed. This
formula is somewhat arbitrary, and has to be proven experimentally.
Diffstat (limited to 'src')
-rw-r--r-- | src/player_thread.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/player_thread.c b/src/player_thread.c index c5a51a00a..b82005aec 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -339,7 +339,13 @@ static void do_play(void) sizeToTime) < 0) break; ob_shift(); - notify_signal(&dc.notify); + + /* this formula should prevent that the + decoder gets woken up with each chunk; it + is more efficient to make it decode a + larger block at a time */ + if (ob_available() <= (pc.buffered_before_play + ob.size * 3) / 4) + notify_signal(&dc.notify); } else if (!ob_is_empty() && (int)ob.begin == next) { /* at the beginning of a new song */ |