Remove the state_ member from AudioDecoder
The subclasses that need a state pointer should declare them---with
the right type, not void*, to get rid of all those casts.
Two small but not quite trivial cleanups are included because they
blocked the state_ removal:
- AudioDecoderG722Stereo now inherits directly from AudioDecoder
instead of being a subclass of AudioDecoderG722.
- AudioDecoder now has a CngDecoderInstance member function, which
is implemented only by AudioDecoderCng. This replaces the previous
practice of calling AudioDecoder::state() and casting the result
to a CNG_dec_inst*. It still isn't pretty, but now the blemish is
plainly visible in the AudioDecoder class declaration.
R=henrik.lundin@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/24169005
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7644 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/neteq/normal.cc b/webrtc/modules/audio_coding/neteq/normal.cc
index 46d03fb..ca2c1ee 100644
--- a/webrtc/modules/audio_coding/neteq/normal.cc
+++ b/webrtc/modules/audio_coding/neteq/normal.cc
@@ -147,9 +147,9 @@
AudioDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
if (cng_decoder) {
- CNG_dec_inst* cng_inst = static_cast<CNG_dec_inst*>(cng_decoder->state());
// Generate long enough for 32kHz.
- if (WebRtcCng_Generate(cng_inst, cng_output, kCngLength, 0) < 0) {
+ if (WebRtcCng_Generate(cng_decoder->CngDecoderInstance(), cng_output,
+ kCngLength, 0) < 0) {
// Error returned; set return vector to all zeros.
memset(cng_output, 0, sizeof(cng_output));
}