Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 1324453002: NetEq: Fixing a corner case with depleted sync buffer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h ('k') | webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698