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

Unified Diff: webrtc/modules/audio_coding/acm2/acm_receiver.cc

Issue 2349973002: Revert of AcmReceiver: Ask NetEq to delete all decoders at once instead of one by one (Closed)
Patch Set: Created 4 years, 3 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/acm2/acm_receiver.cc
diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/acm2/acm_receiver.cc
index b89091f3626374d8f3fe0693c5437f8b2e989d2e..2ae75485e0ff928e2c7029ff4b7d0e1baef41883 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_receiver.cc
@@ -245,12 +245,27 @@
neteq_->FlushBuffers();
}
-void AcmReceiver::RemoveAllCodecs() {
- rtc::CritScope lock(&crit_sect_);
- neteq_->RemoveAllPayloadTypes();
- decoders_.clear();
+// If failed in removing one of the codecs, this method continues to remove as
+// many as it can.
+int AcmReceiver::RemoveAllCodecs() {
+ int ret_val = 0;
+ rtc::CritScope lock(&crit_sect_);
+ for (auto it = decoders_.begin(); it != decoders_.end(); ) {
+ auto cur = it;
+ ++it; // it will be valid even if we erase cur
+ if (neteq_->RemovePayloadType(cur->second.payload_type) == 0) {
+ decoders_.erase(cur);
+ } else {
+ LOG_F(LS_ERROR) << "Cannot remove payload "
+ << static_cast<int>(cur->second.payload_type);
+ ret_val = -1;
+ }
+ }
+
+ // No codec is registered, invalidate last audio decoder.
last_audio_decoder_ = rtc::Optional<CodecInst>();
last_packet_sample_rate_hz_ = rtc::Optional<int>();
+ return ret_val;
}
int AcmReceiver::RemoveCodec(uint8_t payload_type) {
« no previous file with comments | « webrtc/modules/audio_coding/acm2/acm_receiver.h ('k') | webrtc/modules/audio_coding/acm2/audio_coding_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698