diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-07-21 21:50:29 +0200 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-07-21 21:50:29 +0200 |
commit | e36cce4683f347d4eb423fc3e9ba9a8892a6c793 (patch) | |
tree | 216f4304201683c693980d1f1d68609186ae1751 | |
parent | 64e58f02324fb84ca2f6013fbfe48c4877a41ee1 (diff) |
guarantee streamer sleep at the end of last track, to avoid 100% CPU load
-rw-r--r-- | streamer.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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 |