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:
@@ -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(...)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user