Index: webrtc/modules/audio_coding/neteq/neteq_impl.cc |
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc |
index 00f854b8db0b6f5ca794a98fd939540115419499..76726fd38529a8c28a8277d3c7c2eb0765ac3dc6 100644 |
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc |
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc |
@@ -835,6 +835,15 @@ int NetEqImpl::GetAudioInternal(size_t max_length, |
LOG(LS_VERBOSE) << "Sync buffer (" << *num_channels << " channel(s)):" << |
" insert " << algorithm_buffer_->Size() << " samples, extract " << |
samples_from_sync << " samples"; |
+ if (sync_buffer_->FutureLength() < expand_->overlap_length()) { |
+ // The sync buffer should always contain |overlap_length| samples, but now |
+ // too many samples have been extracted. Reinstall the |overlap_length| |
+ // lookahead by moving the index. |
+ const size_t missing_lookahead_samples = |
+ expand_->overlap_length() - sync_buffer_->FutureLength(); |
+ sync_buffer_->set_next_index(sync_buffer_->next_index() - |
+ missing_lookahead_samples); |
minyue-webrtc
2015/08/30 21:50:27
How do you know that next_index_ >= missing_lookah
hlundin-webrtc
2015/08/31 08:08:25
next_index_ is by definition FutureLength() from t
minyue-webrtc
2015/09/01 07:36:07
Acknowledged.
|
+ } |
if (samples_from_sync != output_size_samples_) { |
LOG(LS_ERROR) << "samples_from_sync (" << samples_from_sync |
<< ") != output_size_samples_ (" << output_size_samples_ |
@@ -847,7 +856,7 @@ int NetEqImpl::GetAudioInternal(size_t max_length, |
*samples_per_channel = output_size_samples_; |
// Should always have overlap samples left in the |sync_buffer_|. |
- assert(sync_buffer_->FutureLength() >= expand_->overlap_length()); |
+ DCHECK_GE(sync_buffer_->FutureLength(), expand_->overlap_length()); |
if (play_dtmf) { |
return_value = DtmfOverdub(dtmf_event, sync_buffer_->Channels(), output); |