- unique_lock<mutex> input_lock(_input_mutex);
- while(!boost::this_thread::interruption_requested() &&
- !_frame_complete && _samples_decoded >= _sample_count)
- _input_cond.wait(input_lock);
- return boost::make_optional(
- !boost::this_thread::interruption_requested() &&
- (_samples_decoded < _sample_count || !_frame_complete),
- _sample_count);
+ unique_lock<mutex> input_lock(input_mutex_);
+
+ // Do wait if we decoded all samples but we're still capturing
+ // Do not wait if we're done capturing
+ while (!interrupt_ && !frame_complete_ &&
+ (samples_decoded_ >= sample_count_) &&
+ (session_.get_capture_state() != Session::Stopped)) {
+
+ input_cond_.wait(input_lock);
+ }
+
+ // Return value is valid if we're not aborting the decode,
+ return boost::make_optional(!interrupt_ &&
+ // and there's more work to do...
+ (samples_decoded_ < sample_count_ || !frame_complete_) &&
+ // and if the end of the data hasn't been reached yet
+ (!((samples_decoded_ >= sample_count_) && (session_.get_capture_state() == Session::Stopped))),
+ sample_count_);