From e36cce4683f347d4eb423fc3e9ba9a8892a6c793 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Mon, 21 Jul 2014 21:50:29 +0200 Subject: guarantee streamer sleep at the end of last track, to avoid 100% CPU load --- streamer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/streamer.c b/streamer.c index c84a4097..432bc16b 100644 --- a/streamer.c +++ b/streamer.c @@ -1840,9 +1840,12 @@ streamer_thread (void *ctx) { // add 1ms here to compensate the rounding error // and another 1ms to buffer slightly faster then playing alloc_time -= ms+2; - if ((bytes_until_next_song > 0 && stop_after_current) || (streamer_ringbuf.remaining > STREAM_BUFFER_SIZE / 2 && !streamer_buffering && alloc_time > 0)) { + if (streamer_ringbuf.remaining > STREAM_BUFFER_SIZE / 2 && !streamer_buffering && alloc_time > 0) { usleep (alloc_time * 1000); } + else if (bytes_until_next_song > 0) { + usleep (20000); + } } // stop streaming song -- cgit v1.2.3