Word16 GSMInitEncode(void **state_data, Flag dtx, Word8 *id) { Speech_Encode_FrameState* s; OSCL_UNUSED_ARG(id); if (state_data == NULL) { /* fprintf(stderr, "Speech_Encode_Frame_init: invalid parameter\n"); */ return -1; } *state_data = NULL; /* allocate memory */ if ((s = (Speech_Encode_FrameState *) oscl_malloc(sizeof(Speech_Encode_FrameState))) == NULL) { /* fprintf(stderr, "Speech_Encode_Frame_init: can not malloc state " "structure\n"); */ return -1; } s->pre_state = NULL; s->cod_amr_state = NULL; s->dtx = dtx; if (Pre_Process_init(&s->pre_state) || cod_amr_init(&s->cod_amr_state, s->dtx)) { Speech_Encode_FrameState** temp = &s; GSMEncodeFrameExit((void**)temp); return -1; } Speech_Encode_Frame_reset(s); *state_data = (void *)s; return 0; }
/************************************************************************* * * Function: Speech_Encode_Frame_init * Purpose: Allocates memory for filter structure and initializes * state memory * ************************************************************************** */ int Speech_Encode_Frame_init (Speech_Encode_FrameState **state, Flag dtx, char *id) { Speech_Encode_FrameState* s; if (state == (Speech_Encode_FrameState **) NULL){ fprintf(stderr, "Speech_Encode_Frame_init: invalid parameter\n"); return -1; } *state = NULL; /* allocate memory */ if ((s= (Speech_Encode_FrameState *) malloc(sizeof(Speech_Encode_FrameState))) == NULL){ fprintf(stderr, "Speech_Encode_Frame_init: can not malloc state " "structure\n"); return -1; } s->complexityCounter = getCounterId(id); s->pre_state = NULL; s->cod_amr_state = NULL; s->dtx = dtx; if (Pre_Process_init(&s->pre_state) || cod_amr_init(&s->cod_amr_state, s->dtx)) { Speech_Encode_Frame_exit(&s); return -1; } Speech_Encode_Frame_reset(s); *state = s; return 0; }