- for (int64_t i = 0;
- !boost::this_thread::interruption_requested() &&
- i < sample_count;
- i += chunk_sample_count)
- {
- lock_guard<mutex> decode_lock(_global_decode_mutex);
-
- const int64_t chunk_end = min(
- i + chunk_sample_count, sample_count);
- snapshot->get_samples(chunk, i, chunk_end);
-
- if (srd_session_send(session, i, i + sample_count, chunk,
- (chunk_end - i) * unit_size) != SRD_OK) {
- _error_message = tr("Decoder reported an error");
- break;
- }
-
- {
- lock_guard<mutex> lock(_mutex);
- _samples_decoded = chunk_end;
- }
- }
+ do {
+ decode_data(*sample_count, unit_size, session);
+ } while(_error_message.isEmpty() && (sample_count = wait_for_data()));