mirror of https://github.com/libsdl-org/SDL.git
test/testautomation_audio.c: Free variables before returning
This commit is contained in:
parent
7ea0ffb748
commit
da2460f9e7
|
|
@ -809,6 +809,7 @@ static int SDLCALL audio_convertAudio(void *arg)
|
||||||
src_buf = (Uint8 *)SDL_malloc(src_len);
|
src_buf = (Uint8 *)SDL_malloc(src_len);
|
||||||
SDLTest_AssertCheck(src_buf != NULL, "Check src data buffer to convert is not NULL");
|
SDLTest_AssertCheck(src_buf != NULL, "Check src data buffer to convert is not NULL");
|
||||||
if (src_buf == NULL) {
|
if (src_buf == NULL) {
|
||||||
|
SDL_DestroyAudioStream(stream);
|
||||||
return TEST_ABORTED;
|
return TEST_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -819,6 +820,8 @@ static int SDLCALL audio_convertAudio(void *arg)
|
||||||
dst_buf = (Uint8 *)SDL_malloc(dst_len);
|
dst_buf = (Uint8 *)SDL_malloc(dst_len);
|
||||||
SDLTest_AssertCheck(dst_buf != NULL, "Check dst data buffer to convert is not NULL");
|
SDLTest_AssertCheck(dst_buf != NULL, "Check dst data buffer to convert is not NULL");
|
||||||
if (dst_buf == NULL) {
|
if (dst_buf == NULL) {
|
||||||
|
SDL_DestroyAudioStream(stream);
|
||||||
|
SDL_free(src_buf);
|
||||||
return TEST_ABORTED;
|
return TEST_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -828,6 +831,9 @@ static int SDLCALL audio_convertAudio(void *arg)
|
||||||
/* Run the audio converter */
|
/* Run the audio converter */
|
||||||
if (!SDL_PutAudioStreamData(stream, src_buf, src_len) ||
|
if (!SDL_PutAudioStreamData(stream, src_buf, src_len) ||
|
||||||
!SDL_FlushAudioStream(stream)) {
|
!SDL_FlushAudioStream(stream)) {
|
||||||
|
SDL_DestroyAudioStream(stream);
|
||||||
|
SDL_free(src_buf);
|
||||||
|
SDL_free(dst_buf);
|
||||||
return TEST_ABORTED;
|
return TEST_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -837,6 +843,9 @@ static int SDLCALL audio_convertAudio(void *arg)
|
||||||
real_dst_len = SDL_GetAudioStreamData(stream, dst_buf, dst_len);
|
real_dst_len = SDL_GetAudioStreamData(stream, dst_buf, dst_len);
|
||||||
SDLTest_AssertCheck(dst_len == real_dst_len, "Verify result value; expected: %i; got: %i", dst_len, real_dst_len);
|
SDLTest_AssertCheck(dst_len == real_dst_len, "Verify result value; expected: %i; got: %i", dst_len, real_dst_len);
|
||||||
if (dst_len != real_dst_len) {
|
if (dst_len != real_dst_len) {
|
||||||
|
SDL_DestroyAudioStream(stream);
|
||||||
|
SDL_free(src_buf);
|
||||||
|
SDL_free(dst_buf);
|
||||||
return TEST_ABORTED;
|
return TEST_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -848,6 +857,9 @@ static int SDLCALL audio_convertAudio(void *arg)
|
||||||
for (m = 0; m < dst_len; ++m) {
|
for (m = 0; m < dst_len; ++m) {
|
||||||
if (dst_buf[m] != dst_silence) {
|
if (dst_buf[m] != dst_silence) {
|
||||||
SDLTest_LogError("Output buffer is not silent");
|
SDLTest_LogError("Output buffer is not silent");
|
||||||
|
SDL_DestroyAudioStream(stream);
|
||||||
|
SDL_free(src_buf);
|
||||||
|
SDL_free(dst_buf);
|
||||||
return TEST_ABORTED;
|
return TEST_ABORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1104,6 +1116,7 @@ static int SDLCALL audio_resampleLoss(void *arg)
|
||||||
SDLTest_AssertCheck(buf_out != NULL, "Expected output buffer to be created.");
|
SDLTest_AssertCheck(buf_out != NULL, "Expected output buffer to be created.");
|
||||||
if (buf_out == NULL) {
|
if (buf_out == NULL) {
|
||||||
SDL_DestroyAudioStream(stream);
|
SDL_DestroyAudioStream(stream);
|
||||||
|
SDL_free(buf_in);
|
||||||
return TEST_ABORTED;
|
return TEST_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1114,6 +1127,7 @@ static int SDLCALL audio_resampleLoss(void *arg)
|
||||||
SDL_free(buf_in);
|
SDL_free(buf_in);
|
||||||
if (len_out != len_target) {
|
if (len_out != len_target) {
|
||||||
SDL_DestroyAudioStream(stream);
|
SDL_DestroyAudioStream(stream);
|
||||||
|
SDL_free(buf_out);
|
||||||
return TEST_ABORTED;
|
return TEST_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1130,6 +1144,7 @@ static int SDLCALL audio_resampleLoss(void *arg)
|
||||||
sum_squared_value += target * target;
|
sum_squared_value += target * target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SDL_DestroyAudioStream(stream);
|
||||||
SDL_free(buf_out);
|
SDL_free(buf_out);
|
||||||
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
|
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
|
||||||
SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
|
SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue