From aae7e5eb06bf4016d95f3a193879c82f3c266de5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 18 Apr 2017 10:56:51 +0100 Subject: [PATCH] Tidy up slightly. --- src/lib/butler.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/butler.cc b/src/lib/butler.cc index de982a0fe..e88c29455 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -63,6 +63,13 @@ Butler::~Butler () delete _thread; } +bool +Butler::should_run () const +{ + return (_video.size() < VIDEO_READAHEAD || _audio.size() < AUDIO_READAHEAD) && !_stop_thread && !_finished; +} + + void Butler::thread () try @@ -71,7 +78,7 @@ try boost::mutex::scoped_lock lm (_mutex); /* Wait until we have something to do */ - while ((_video.size() >= VIDEO_READAHEAD && _audio.size() >= AUDIO_READAHEAD && !_pending_seek_position) || _stop_thread) { + while (!should_run() && !_pending_seek_position) { _summon.wait (lm); } @@ -85,7 +92,7 @@ try while lm is unlocked, as in that state nothing will be added to _video/_audio. */ - while ((_video.size() < VIDEO_READAHEAD || _audio.size() < AUDIO_READAHEAD) && !_pending_seek_position && !_stop_thread) { + while (should_run() && !_pending_seek_position) { lm.unlock (); if (_player->pass ()) { _finished = true; -- 2.30.2