From b5162bae5c0afc83f70dcc4ce1eb6dd77bad8559 Mon Sep 17 00:00:00 2001 From: Johns Date: Sat, 30 Jun 2012 15:40:33 +0200 Subject: [PATCH] Fix bug: 100% CPU use during playback. --- ChangeLog | 1 + softhddev.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1d661a..e093beb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ User johns Date: Release Version 0.5.1 + Fix bug: 100% CPU use during playback. Fix bug: audio use 100% CPU during pause. Guard audio skip against old PTS values. Improved audio skip, after channel switch. diff --git a/softhddev.c b/softhddev.c index b45b198..57858ed 100644 --- a/softhddev.c +++ b/softhddev.c @@ -2181,10 +2181,15 @@ int Poll(int timeout) #else int full; int t; + int used; + int filled; - // one buffer is full - full = AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE - || atomic_read(&VideoPacketsFilled) > VIDEO_PACKET_MAX - 3; + used = AudioUsedBytes(); + filled = atomic_read(&VideoPacketsFilled); + // soft limit + hard limit + full = (used > AUDIO_MIN_BUFFER_FREE && filled > 3) + || AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE + || filled >= VIDEO_PACKET_MAX - 3; if (!full || !timeout) { return !full;