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

Side by Side Diff: webrtc/modules/audio_coding/acm2/acm_receiver.cc

Issue 2348233002: AcmReceiver: Ask NetEq to delete all decoders at once instead of one by one (Closed)
Patch Set: unit tests 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 decoder.channels = channels; 238 decoder.channels = channels;
239 decoder.sample_rate_hz = sample_rate_hz; 239 decoder.sample_rate_hz = sample_rate_hz;
240 decoders_[payload_type] = decoder; 240 decoders_[payload_type] = decoder;
241 return 0; 241 return 0;
242 } 242 }
243 243
244 void AcmReceiver::FlushBuffers() { 244 void AcmReceiver::FlushBuffers() {
245 neteq_->FlushBuffers(); 245 neteq_->FlushBuffers();
246 } 246 }
247 247
248 // If failed in removing one of the codecs, this method continues to remove as 248 void AcmReceiver::RemoveAllCodecs() {
249 // many as it can.
250 int AcmReceiver::RemoveAllCodecs() {
251 int ret_val = 0;
252 rtc::CritScope lock(&crit_sect_); 249 rtc::CritScope lock(&crit_sect_);
253 for (auto it = decoders_.begin(); it != decoders_.end(); ) { 250 neteq_->RemoveAllPayloadTypes();
254 auto cur = it; 251 decoders_.clear();
255 ++it; // it will be valid even if we erase cur
256 if (neteq_->RemovePayloadType(cur->second.payload_type) == 0) {
257 decoders_.erase(cur);
258 } else {
259 LOG_F(LS_ERROR) << "Cannot remove payload "
260 << static_cast<int>(cur->second.payload_type);
261 ret_val = -1;
262 }
263 }
264
265 // No codec is registered, invalidate last audio decoder.
266 last_audio_decoder_ = rtc::Optional<CodecInst>(); 252 last_audio_decoder_ = rtc::Optional<CodecInst>();
267 last_packet_sample_rate_hz_ = rtc::Optional<int>(); 253 last_packet_sample_rate_hz_ = rtc::Optional<int>();
268 return ret_val;
269 } 254 }
270 255
271 int AcmReceiver::RemoveCodec(uint8_t payload_type) { 256 int AcmReceiver::RemoveCodec(uint8_t payload_type) {
272 rtc::CritScope lock(&crit_sect_); 257 rtc::CritScope lock(&crit_sect_);
273 auto it = decoders_.find(payload_type); 258 auto it = decoders_.find(payload_type);
274 if (it == decoders_.end()) { // Such a payload-type is not registered. 259 if (it == decoders_.end()) { // Such a payload-type is not registered.
275 return 0; 260 return 0;
276 } 261 }
277 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK) { 262 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK) {
278 LOG(LERROR) << "AcmReceiver::RemoveCodec" << static_cast<int>(payload_type); 263 LOG(LERROR) << "AcmReceiver::RemoveCodec" << static_cast<int>(payload_type);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 374
390 void AcmReceiver::GetDecodingCallStatistics( 375 void AcmReceiver::GetDecodingCallStatistics(
391 AudioDecodingCallStats* stats) const { 376 AudioDecodingCallStats* stats) const {
392 rtc::CritScope lock(&crit_sect_); 377 rtc::CritScope lock(&crit_sect_);
393 *stats = call_stats_.GetDecodingStatistics(); 378 *stats = call_stats_.GetDecodingStatistics();
394 } 379 }
395 380
396 } // namespace acm2 381 } // namespace acm2
397 382
398 } // namespace webrtc 383 } // namespace webrtc
OLDNEW
« 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