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);
|
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(...)
|
||||||
|
|||||||
@@ -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)
|
*handle = NULL;
|
||||||
{
|
self = (VadInstT*) malloc(sizeof(VadInstT));
|
||||||
return -1;
|
*handle = (VadInst*) self;
|
||||||
}
|
|
||||||
|
|
||||||
*vad_inst = NULL;
|
if (self == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
vad_ptr = (VadInstT *)malloc(sizeof(VadInstT));
|
self->init_flag = 0;
|
||||||
*vad_inst = (VadInst *)vad_ptr;
|
|
||||||
|
|
||||||
if (vad_ptr == NULL)
|
return 0;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
vad_ptr->init_flag = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16 WebRtcVad_Free(VadInst *vad_inst)
|
int WebRtcVad_Free(VadInst* handle) {
|
||||||
{
|
if (handle == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (vad_inst == NULL)
|
free(handle);
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(vad_inst);
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int WebRtcVad_Init(VadInst* handle) {
|
int WebRtcVad_Init(VadInst* handle) {
|
||||||
|
|||||||
Reference in New Issue
Block a user