From e96e4f77fbc3b59fa21c5ecfe827be8f8a589ef1 Mon Sep 17 00:00:00 2001 From: Ronag Date: Sun, 14 Aug 2011 01:30:12 +0000 Subject: [PATCH] 2.0. ffmpeg_producer: Use timed_wait instead of wait, more stable. git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1166 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- modules/ffmpeg/producer/input.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ffmpeg/producer/input.cpp b/modules/ffmpeg/producer/input.cpp index 43affb462..327a39fa6 100644 --- a/modules/ffmpeg/producer/input.cpp +++ b/modules/ffmpeg/producer/input.cpp @@ -58,6 +58,7 @@ extern "C" namespace caspar { static const size_t MAX_BUFFER_COUNT = 32; +static const size_t MIN_BUFFER_COUNT = 4; static const size_t MAX_BUFFER_SIZE = 32 * 1000000; struct input::implementation : boost::noncopyable @@ -169,7 +170,8 @@ private: { { boost::unique_lock lock(buffer_mutex_); - buffer_cond_.wait(lock, [this]{return !full();}); + while(full()) + buffer_cond_.timed_wait(lock, boost::posix_time::millisec(20)); } read_next_packet(); } @@ -256,7 +258,7 @@ private: bool full() const { - return is_running_ && (buffer_size_ > MAX_BUFFER_SIZE || buffer_.size() > MAX_BUFFER_COUNT); + return is_running_ && (buffer_size_ > MAX_BUFFER_SIZE || buffer_.size() > MAX_BUFFER_COUNT) && buffer_.size() > MIN_BUFFER_COUNT; } void seek_frame(int64_t frame, int flags = 0) -- 2.39.2