AudioDecoder: Replace Init() with Reset()

The Init() method was previously used to initialize and reset
decoders, and returned an error code. The new Reset() method is used
for reset only; the constructor is now responsible for fully
initializing the AudioDecoder.

Reset() doesn't return an error code; it turned out that none of the
functions it ended up calling could actually fail, so this CL removes
their error return codes as well.

R=henrik.lundin@webrtc.org

Review URL: https://codereview.webrtc.org/1319683002 .

Cr-Commit-Position: refs/heads/master@{#9798}
This commit is contained in:
Karl Wiberg
2015-08-27 15:22:11 +02:00
parent 1c3dd38cb8
commit 4376648df0
38 changed files with 105 additions and 208 deletions

View File

@ -157,11 +157,7 @@ static void block4(G722DecoderState *s, int band, int d)
G722DecoderState* WebRtc_g722_decode_init(G722DecoderState* s,
int rate,
int options) {
if (s == NULL)
{
if ((s = (G722DecoderState *) malloc(sizeof(*s))) == NULL)
return NULL;
}
s = s ? s : malloc(sizeof(*s));
memset(s, 0, sizeof(*s));
if (rate == 48000)
s->bits_per_sample = 6;

View File

@ -66,17 +66,10 @@ int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst)
}
}
int16_t WebRtcG722_DecoderInit(G722DecInst *G722dec_inst)
{
// Create and/or reset the G.722 decoder
// Bitrate 64 kbps and wideband mode (2)
G722dec_inst = (G722DecInst *) WebRtc_g722_decode_init(
(G722DecoderState*) G722dec_inst, 64000, 2);
if (G722dec_inst == NULL) {
return -1;
} else {
return 0;
}
void WebRtcG722_DecoderInit(G722DecInst* inst) {
// Create and/or reset the G.722 decoder
// Bitrate 64 kbps and wideband mode (2)
WebRtc_g722_decode_init((G722DecoderState*)inst, 64000, 2);
}
int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst)

View File

@ -113,22 +113,16 @@ size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
*/
int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
/****************************************************************************
* WebRtcG722_DecoderInit(...)
*
* This function initializes a G729 instance
* This function initializes a G722 instance
*
* Input:
* - G729_decinst_t : G729 instance, i.e. the user that should receive
* be initialized
*
* Return value : 0 - Ok
* -1 - Error
* - inst : G722 instance
*/
int16_t WebRtcG722_DecoderInit(G722DecInst *G722dec_inst);
void WebRtcG722_DecoderInit(G722DecInst* inst);
/****************************************************************************
* WebRtcG722_FreeDecoder(...)