7 #define _CRT_SECURE_NO_WARNINGS 35 remove(
"sdlaudio.raw");
87 const char* audioDriver;
96 SDLTest_AssertCheck(iMax > 0,
"Validate number of audio drivers; expected: >0 got: %d", iMax);
97 for (i = 0; i < iMax; i++) {
101 SDLTest_AssertCheck(audioDriver[0] !=
'\0',
"Audio driver name is not empty; got: %s", audioDriver);
141 int result, expectedResult;
143 const char* audioDriver;
153 SDLTest_AssertCheck(iMax > 0,
"Validate number of audio drivers; expected: >0 got: %d", iMax);
154 for (i = 0; i < iMax; i++) {
158 SDLTest_AssertCheck(audioDriver[0] !=
'\0',
"Audio driver name is not empty; got: %s", audioDriver);
161 for (j = 0; j < 2; j++) {
173 desired.
freq = 22050;
182 desired.
freq = 48000;
192 for (k=0; k <=
j; k++) {
195 expectedResult = (k==0) ? 0 : -1;
196 SDLTest_AssertCheck(result == expectedResult,
"Verify return value; expected: %d, got: %d", expectedResult, result);
200 for (k=0; k <=
j; k++) {
206 for (k=0; k <=
j; k++) {
228 int i, iMax,
j, k, l;
232 const char* audioDriver;
242 SDLTest_AssertCheck(iMax > 0,
"Validate number of audio drivers; expected: >0 got: %d", iMax);
243 for (i = 0; i < iMax; i++) {
247 SDLTest_AssertCheck(audioDriver[0] !=
'\0',
"Audio driver name is not empty; got: %s", audioDriver);
250 for (j = 0; j < 2; j++) {
262 desired.
freq = 22050;
271 desired.
freq = 48000;
286 for (l=0; l<3; l++) {
295 for (k=0; k <=
j; k++) {
311 for (k=0; k <=
j; k++) {
350 const char *
name, *nameAgain;
353 for (t=0; t<2; t++) {
358 SDLTest_Log(
"Number of %s devices < 0, reported as %i", (t) ?
"capture" :
"output", n);
365 SDLTest_AssertCheck(n==nn,
"Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn);
367 SDLTest_AssertCheck(n==nn,
"Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn);
372 for (i=0; i<
n; i++) {
377 SDLTest_AssertCheck(name[0] !=
'\0',
"verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
382 SDLTest_AssertCheck(nameAgain !=
NULL,
"Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
383 if (nameAgain !=
NULL) {
384 SDLTest_AssertCheck(nameAgain[0] !=
'\0',
"Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
386 "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
417 for (t=0; t<2; t++) {
422 SDLTest_AssertCheck(name ==
NULL,
"Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name ==
NULL) ?
"NULL" : name);
425 for (j=0; j<3; j++) {
426 i = (
t) ? nc+j : no+j;
429 SDLTest_AssertCheck(name ==
NULL,
"Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name ==
NULL) ?
"NULL" : name);
433 if ((no>0) && (no>nc) && (t==1)) {
437 SDLTest_AssertCheck(name ==
NULL,
"Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name ==
NULL) ?
"NULL" : name);
464 for (i=0; i<
n; i++) {
469 SDLTest_AssertCheck(name[0] !=
'\0',
"Verify returned name is not empty, got: '%s'", name);
490 SDLTest_AssertCheck(name[0] !=
'\0',
"Verify returned name is not empty, got: '%s'", name);
501 char *
_audioFormatsVerbose[] = {
"AUDIO_S8",
"AUDIO_U8",
"AUDIO_S16LSB",
"AUDIO_S16MSB",
"AUDIO_S16SYS",
"AUDIO_S16",
"AUDIO_U16LSB",
502 "AUDIO_U16MSB",
"AUDIO_U16SYS",
"AUDIO_U16",
"AUDIO_S32LSB",
"AUDIO_S32MSB",
"AUDIO_S32SYS",
"AUDIO_S32",
503 "AUDIO_F32LSB",
"AUDIO_F32MSB",
"AUDIO_F32SYS",
"AUDIO_F32" };
521 int i, ii,
j, jj, k, kk;
559 SDLTest_AssertPass(
"Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
560 i,
_audioFormatsVerbose[i], spec1.
format, j, spec1.
channels, k, spec1.
freq, ii,
_audioFormatsVerbose[ii], spec2.
format, jj, spec2.
channels, kk, spec2.
freq);
561 SDLTest_AssertCheck(result == 0 || result == 1,
"Verify result value; expected: 0 or 1, got: %i", result);
581 const char *expectedError =
"Parameter 'cvt' is invalid";
611 "Validate error message, expected: '%s', got: '%s'", expectedError, error);
615 for (i = 1; i < 64; i++) {
682 "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
708 for (i = 0; i <
count; i++) {
733 "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
766 for (i = 0; i <
count; i++) {
792 SDLTest_Log(
"Simulate callback processing - delay");
825 int i, ii,
j, jj, k, kk, l, ll;
828 for (c = 1; c < 8; c++) {
865 }
while ((i == ii) && (j == jj) && (k == kk));
872 SDLTest_AssertPass(
"Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
873 i,
_audioFormatsVerbose[i], spec1.
format, j, spec1.
channels, k, spec1.
freq, ii,
_audioFormatsVerbose[ii], spec2.
format, jj, spec2.
channels, kk, spec2.
freq);
884 SDLTest_Log(
"Creating dummy sample buffer of %i length (%i bytes)", l, ll);
928 for (i = 0; i <
count; i++) {
951 #ifdef AUDIODEVICECONNECTED_DEFINED 953 result = SDL_AudioDeviceConnected(
id);
#define SDL_GetNumAudioDrivers
#define SDL_GetNumAudioDevices
int audio_initOpenCloseQuitAudio()
Start, open, close and stop audio.
#define SDL_GetAudioStatus
#define SDL_CloseAudioDevice
static const SDLTest_TestCaseReference * audioTests[]
#define SDL_OpenAudioDevice
GLuint GLsizei const GLchar * message
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
#define SDL_BuildAudioCVT
static const SDLTest_TestCaseReference audioTest12
GLuint GLuint GLsizei count
#define SDL_LockAudioDevice
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
char * _audioFormatsVerbose[]
static const SDLTest_TestCaseReference audioTest14
int audio_initQuitAudio()
Start and stop audio directly.
static const SDLTest_TestCaseReference audioTest5
#define SDL_QuitSubSystem
int audio_buildAudioCVT()
Builds various audio conversion structures.
SDL_AudioFormat _audioFormats[]
static const SDLTest_TestCaseReference audioTest9
static const SDLTest_TestCaseReference audioTest8
static const SDLTest_TestCaseReference audioTest4
#define SDL_InitSubSystem
Uint16 SDL_AudioFormat
Audio format flags.
GLuint const GLchar * name
const int _numAudioFrequencies
int audio_enumerateAndNameAudioDevices()
Enumerate and name available audio devices (output and capture).
SDLTest_TestSuiteReference audioTestSuite
static const SDLTest_TestCaseReference audioTest2
int audio_lockUnlockOpenAudioDevice()
Locks and unlocks open audio device.
static const SDLTest_TestCaseReference audioTest1
int audio_pauseUnpauseAudio()
Pause and unpause audio.
#define SDL_GetAudioDeviceName
const int _numAudioChannels
int(* SDLTest_TestCaseFp)(void *arg)
void _audioTearDown(void *arg)
void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and the ERROR priority.
static const SDLTest_TestCaseReference audioTest15
int audio_quitInitAudioSubSystem()
Stop and restart audio subsystem.
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
int audio_buildAudioCVTNegative()
Checkes calls with invalid input to SDL_BuildAudioCVT.
uint8_t Uint8
An unsigned 8-bit integer type.
int audio_openCloseAudioDeviceConnected()
Opens, checks current connected status, and closes a device.
#define SDL_AUDIO_ALLOW_ANY_CHANGE
int _audio_testCallbackLength
int audio_openCloseAndGetAudioStatus()
Opens, checks current audio status, and closes a device.
#define SDL_GetAudioDeviceStatus
#define SDL_GetAudioDriver
int audio_getAudioStatus()
Checks current audio status.
SDL_AudioCallback callback
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_GetCurrentAudioDriver
static const SDLTest_TestCaseReference audioTest6
static const SDLTest_TestCaseReference audioTest13
const int _numAudioFormats
static const SDLTest_TestCaseReference audioTest11
static const SDLTest_TestCaseReference audioTest10
int _audio_testCallbackCounter
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
int audio_printAudioDrivers()
Checks available audio driver names.
int audio_convertAudio()
Convert audio using various conversion structures.
void _audio_testCallback(void *userdata, Uint8 *stream, int len)
static const SDLTest_TestCaseReference audioTest7
#define SDL_UnlockAudioDevice
int audio_printCurrentAudioDriver()
Checks current audio driver name with initialized audio.
void _audioSetUp(void *arg)
int audio_enumerateAndNameAudioDevicesNegativeTests()
Negative tests around enumeration and naming of audio devices.
static const SDLTest_TestCaseReference audioTest3
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)