VAD refactor: Create() and Free()

Style and return value changes. No impact externally, since audio_processing, audio_conference_mixer and audio_coding either already assumes 'int' as return value, assumes nothing or doesn't take care of the return value.

TESTS=vad_unittests, audioproc_unittest
Review URL: https://webrtc-codereview.appspot.com/374006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1581 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org
2012-01-31 14:42:50 +00:00
parent dd478e2081
commit 26e8a58130
2 changed files with 31 additions and 53 deletions

View File

@@ -53,34 +53,19 @@ WebRtc_Word16 WebRtcVad_AssignSize(int *size_in_bytes);
*/ */
WebRtc_Word16 WebRtcVad_Assign(VadInst **vad_inst, void *vad_inst_addr); WebRtc_Word16 WebRtcVad_Assign(VadInst **vad_inst, void *vad_inst_addr);
/**************************************************************************** // Creates an instance to the VAD structure.
* WebRtcVad_Create(...) //
* // - handle [o] : Pointer to the VAD instance that should be created.
* This function creates an instance to the VAD structure //
* // returns : 0 - (OK), -1 - (Error)
* Input: int WebRtcVad_Create(VadInst** handle);
* - 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);
/**************************************************************************** // Frees the dynamic memory of a specified VAD instance.
* WebRtcVad_Free(...) //
* // - handle [i] : Pointer to VAD instance that should be freed.
* This function frees the dynamic memory of a specified VAD instance //
* // returns : 0 - (OK), -1 - (NULL pointer in)
* Input: int WebRtcVad_Free(VadInst* handle);
* - vad_inst : Pointer to VAD instance that should be freed
*
* Return value : 0 - Ok
* -1 - Error
*/
WebRtc_Word16 WebRtcVad_Free(VadInst *vad_inst);
/**************************************************************************** /****************************************************************************
* WebRtcVad_Init(...) * WebRtcVad_Init(...)

View File

@@ -46,40 +46,33 @@ 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) {
if (vad_inst == NULL)
{
return -1; return -1;
} }
*vad_inst = NULL; *handle = NULL;
self = (VadInstT*) malloc(sizeof(VadInstT));
*handle = (VadInst*) self;
vad_ptr = (VadInstT *)malloc(sizeof(VadInstT)); if (self == NULL) {
*vad_inst = (VadInst *)vad_ptr;
if (vad_ptr == NULL)
{
return -1; return -1;
} }
vad_ptr->init_flag = 0; self->init_flag = 0;
return 0; return 0;
} }
WebRtc_Word16 WebRtcVad_Free(VadInst *vad_inst) int WebRtcVad_Free(VadInst* handle) {
{ if (handle == NULL) {
if (vad_inst == NULL)
{
return -1; return -1;
} }
free(vad_inst); free(handle);
return 0; return 0;
} }