VAD Refactoring: Removed assign calls
These calls are not used anywhere in WebRTC and there is no plan on using them. Removed them and updated corresponding unit tests. Tested on trybots, vad_unittests, audioproc_unittest BUG=None TEST=None Review URL: https://webrtc-codereview.appspot.com/608004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2306 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -26,23 +26,6 @@ typedef struct WebRtcVadInst VadInst;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO(bjornv): Investigate if we need the Assign calls below at all.
|
||||
|
||||
// Gets the size needed for storing the instance for the VAD.
|
||||
//
|
||||
// returns : The size in bytes needed to allocate memory for the VAD instance.
|
||||
size_t WebRtcVad_AssignSize();
|
||||
|
||||
// Assigns memory for the instances at a given address. It is assumed that the
|
||||
// memory for the VAD instance is allocated at |memory| in accordance with
|
||||
// WebRtcVad_AssignSize().
|
||||
//
|
||||
// - memory [i] : Address to where the memory is assigned.
|
||||
// - handle [o] : Pointer to the instance that should be created.
|
||||
//
|
||||
// returns : 0 - (OK), -1 (NULL pointer in)
|
||||
int WebRtcVad_Assign(void* memory, VadInst** handle);
|
||||
|
||||
// Creates an instance to the VAD structure.
|
||||
//
|
||||
// - handle [o] : Pointer to the VAD instance that should be created.
|
||||
|
||||
@@ -65,23 +65,10 @@ TEST_F(VadTest, ApiTest) {
|
||||
// NULL instance tests
|
||||
EXPECT_EQ(-1, WebRtcVad_Create(NULL));
|
||||
EXPECT_EQ(-1, WebRtcVad_Init(NULL));
|
||||
EXPECT_EQ(-1, WebRtcVad_Assign(NULL, NULL));
|
||||
EXPECT_EQ(-1, WebRtcVad_Free(NULL));
|
||||
EXPECT_EQ(-1, WebRtcVad_set_mode(NULL, kModes[0]));
|
||||
EXPECT_EQ(-1, WebRtcVad_Process(NULL, kRates[0], speech, kFrameLengths[0]));
|
||||
|
||||
// WebRtcVad_AssignSize() test.
|
||||
size_t handle_size_bytes = WebRtcVad_AssignSize();
|
||||
EXPECT_EQ(576u, handle_size_bytes);
|
||||
|
||||
// WebRtcVad_Assign() tests.
|
||||
void* tmp_handle = malloc(handle_size_bytes);
|
||||
EXPECT_EQ(-1, WebRtcVad_Assign(NULL, &handle));
|
||||
EXPECT_EQ(-1, WebRtcVad_Assign(tmp_handle, NULL));
|
||||
EXPECT_EQ(0, WebRtcVad_Assign(tmp_handle, &handle));
|
||||
EXPECT_EQ(handle, tmp_handle);
|
||||
free(tmp_handle);
|
||||
|
||||
// WebRtcVad_Create()
|
||||
ASSERT_EQ(0, WebRtcVad_Create(&handle));
|
||||
|
||||
|
||||
@@ -16,19 +16,6 @@
|
||||
|
||||
static const int kInitCheck = 42;
|
||||
|
||||
size_t WebRtcVad_AssignSize() {
|
||||
return sizeof(VadInstT);
|
||||
}
|
||||
|
||||
int WebRtcVad_Assign(void* memory, VadInst** handle) {
|
||||
if (handle == NULL || memory == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*handle = (VadInst*) memory;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcVad_Create(VadInst** handle) {
|
||||
VadInstT* self = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user