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()); |