Tidy up slightly.
authorCarl Hetherington <cth@carlh.net>
Tue, 18 Apr 2017 09:56:51 +0000 (10:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Apr 2017 22:04:32 +0000 (23:04 +0100)
src/lib/butler.cc

index de982a0feb89a0f65c6aebb042caaab47a763585..e88c2945530833a4a732e747dd08091af9a5e935 100644 (file)
@@ -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;