diff --git a/src/common_audio/vad/include/webrtc_vad.h b/src/common_audio/vad/include/webrtc_vad.h index c21fdfa89..3f9e40230 100644 --- a/src/common_audio/vad/include/webrtc_vad.h +++ b/src/common_audio/vad/include/webrtc_vad.h @@ -53,34 +53,19 @@ WebRtc_Word16 WebRtcVad_AssignSize(int *size_in_bytes); */ WebRtc_Word16 WebRtcVad_Assign(VadInst **vad_inst, void *vad_inst_addr); -/**************************************************************************** - * WebRtcVad_Create(...) - * - * This function creates an instance to the VAD structure - * - * Input: - * - vad_inst : Pointer to VAD instance that should be created - * - * Output: - * - vad_inst : Pointer to created VAD instance - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcVad_Create(VadInst **vad_inst); +// Creates an instance to the VAD structure. +// +// - handle [o] : Pointer to the VAD instance that should be created. +// +// returns : 0 - (OK), -1 - (Error) +int WebRtcVad_Create(VadInst** handle); -/**************************************************************************** - * WebRtcVad_Free(...) - * - * This function frees the dynamic memory of a specified VAD instance - * - * Input: - * - vad_inst : Pointer to VAD instance that should be freed - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcVad_Free(VadInst *vad_inst); +// Frees the dynamic memory of a specified VAD instance. +// +// - handle [i] : Pointer to VAD instance that should be freed. +// +// returns : 0 - (OK), -1 - (NULL pointer in) +int WebRtcVad_Free(VadInst* handle); /**************************************************************************** * WebRtcVad_Init(...) diff --git a/src/common_audio/vad/webrtc_vad.c b/src/common_audio/vad/webrtc_vad.c index 9c030a3d0..26941e6dc 100644 --- a/src/common_audio/vad/webrtc_vad.c +++ b/src/common_audio/vad/webrtc_vad.c @@ -46,41 +46,34 @@ WebRtc_Word16 WebRtcVad_Assign(VadInst **vad_inst, void *vad_inst_addr) } } -WebRtc_Word16 WebRtcVad_Create(VadInst **vad_inst) -{ +int WebRtcVad_Create(VadInst** handle) { + VadInstT* self = NULL; - VadInstT *vad_ptr = NULL; + if (handle == NULL) { + return -1; + } - if (vad_inst == NULL) - { - return -1; - } + *handle = NULL; + self = (VadInstT*) malloc(sizeof(VadInstT)); + *handle = (VadInst*) self; - *vad_inst = NULL; + if (self == NULL) { + return -1; + } - vad_ptr = (VadInstT *)malloc(sizeof(VadInstT)); - *vad_inst = (VadInst *)vad_ptr; + self->init_flag = 0; - if (vad_ptr == NULL) - { - return -1; - } - - vad_ptr->init_flag = 0; - - return 0; + return 0; } -WebRtc_Word16 WebRtcVad_Free(VadInst *vad_inst) -{ +int WebRtcVad_Free(VadInst* handle) { + if (handle == NULL) { + return -1; + } - if (vad_inst == NULL) - { - return -1; - } + free(handle); - free(vad_inst); - return 0; + return 0; } int WebRtcVad_Init(VadInst* handle) {