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

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

Issue 1424083002: Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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/main/acm2/acm_receiver.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index 23ffafcb835356300fa2837b7ba6276b73716d80..4ffa96f454d6c8e4ea0b64d23ac17e0050e52e1a 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -439,15 +439,17 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
int channels,
int sample_rate_hz,
AudioDecoder* audio_decoder) {
- assert(acm_codec_id >= -1); // -1 means external decoder
- NetEqDecoder neteq_decoder = (acm_codec_id == -1)
- ? kDecoderArbitrary
- : ACMCodecDB::neteq_decoders_[acm_codec_id];
-
- // Make sure the right decoder is registered for Opus.
- if (neteq_decoder == kDecoderOpus && channels == 2) {
- neteq_decoder = kDecoderOpus_2ch;
- }
+ const auto neteq_decoder = [acm_codec_id, channels]() -> NetEqDecoder {
+ if (acm_codec_id == -1)
+ return NetEqDecoder::kDecoderArbitrary; // External decoder.
+ const rtc::Maybe<RentACodec::CodecId> cid =
+ RentACodec::CodecIdFromIndex(acm_codec_id);
+ RTC_DCHECK(cid); // acm_codec_id was a valid codec index.
hlundin-webrtc 2015/10/28 15:14:47 I prefer you stream the debug information to RTC_D
kwiberg-webrtc 2015/10/29 09:29:15 Done.
+ const rtc::Maybe<NetEqDecoder> ned =
+ RentACodec::NetEqDecoderFromCodecId(*cid, channels);
+ RTC_DCHECK(ned); // CodecIdFromIndex gives a valid CodecId.
+ return *ned;
+ }();
CriticalSectionScoped lock(crit_sect_.get());
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc ('k') | webrtc/modules/audio_coding/main/acm2/rent_a_codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698