testautomation_audio.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. /**
  2. * Original code: automated SDL audio test written by Edgar Simo "bobbens"
  3. * New/updated tests: aschiffler at ferzkopp dot net
  4. */
  5. /* quiet windows compiler warnings */
  6. #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
  7. # define _CRT_SECURE_NO_WARNINGS
  8. #endif
  9. #include <stdio.h>
  10. #include <SDL3/SDL.h>
  11. #include <SDL3/SDL_test.h>
  12. /* ================= Test Case Implementation ================== */
  13. /* Fixture */
  14. void
  15. _audioSetUp(void *arg)
  16. {
  17. /* Start SDL audio subsystem */
  18. int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
  19. SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)");
  20. SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
  21. if (ret != 0) {
  22. SDLTest_LogError("%s", SDL_GetError());
  23. }
  24. }
  25. void
  26. _audioTearDown(void *arg)
  27. {
  28. /* Remove a possibly created file from SDL disk writer audio driver; ignore errors */
  29. remove("sdlaudio.raw");
  30. SDLTest_AssertPass("Cleanup of test files completed");
  31. }
  32. /* Global counter for callback invocation */
  33. int _audio_testCallbackCounter;
  34. /* Global accumulator for total callback length */
  35. int _audio_testCallbackLength;
  36. /* Test callback function */
  37. void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len)
  38. {
  39. /* track that callback was called */
  40. _audio_testCallbackCounter++;
  41. _audio_testCallbackLength += len;
  42. }
  43. /* Test case functions */
  44. /**
  45. * \brief Stop and restart audio subsystem
  46. *
  47. * \sa https://wiki.libsdl.org/SDL_QuitSubSystem
  48. * \sa https://wiki.libsdl.org/SDL_InitSubSystem
  49. */
  50. int audio_quitInitAudioSubSystem()
  51. {
  52. /* Stop SDL audio subsystem */
  53. SDL_QuitSubSystem( SDL_INIT_AUDIO );
  54. SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
  55. /* Restart audio again */
  56. _audioSetUp(NULL);
  57. return TEST_COMPLETED;
  58. }
  59. /**
  60. * \brief Start and stop audio directly
  61. *
  62. * \sa https://wiki.libsdl.org/SDL_InitAudio
  63. * \sa https://wiki.libsdl.org/SDL_QuitAudio
  64. */
  65. int audio_initQuitAudio()
  66. {
  67. int result;
  68. int i, iMax;
  69. const char* audioDriver;
  70. /* Stop SDL audio subsystem */
  71. SDL_QuitSubSystem( SDL_INIT_AUDIO );
  72. SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
  73. /* Loop over all available audio drivers */
  74. iMax = SDL_GetNumAudioDrivers();
  75. SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
  76. SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
  77. for (i = 0; i < iMax; i++) {
  78. audioDriver = SDL_GetAudioDriver(i);
  79. SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
  80. SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
  81. SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
  82. /* Call Init */
  83. result = SDL_AudioInit(audioDriver);
  84. SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
  85. SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
  86. /* Call Quit */
  87. SDL_AudioQuit();
  88. SDLTest_AssertPass("Call to SDL_AudioQuit()");
  89. }
  90. /* NULL driver specification */
  91. audioDriver = NULL;
  92. /* Call Init */
  93. result = SDL_AudioInit(audioDriver);
  94. SDLTest_AssertPass("Call to SDL_AudioInit(NULL)");
  95. SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
  96. /* Call Quit */
  97. SDL_AudioQuit();
  98. SDLTest_AssertPass("Call to SDL_AudioQuit()");
  99. /* Restart audio again */
  100. _audioSetUp(NULL);
  101. return TEST_COMPLETED;
  102. }
  103. /**
  104. * \brief Start, open, close and stop audio
  105. *
  106. * \sa https://wiki.libsdl.org/SDL_InitAudio
  107. * \sa https://wiki.libsdl.org/SDL_OpenAudio
  108. * \sa https://wiki.libsdl.org/SDL_CloseAudio
  109. * \sa https://wiki.libsdl.org/SDL_QuitAudio
  110. */
  111. int audio_initOpenCloseQuitAudio()
  112. {
  113. int result, expectedResult;
  114. int i, iMax, j, k;
  115. const char* audioDriver;
  116. SDL_AudioSpec desired;
  117. /* Stop SDL audio subsystem */
  118. SDL_QuitSubSystem( SDL_INIT_AUDIO );
  119. SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
  120. /* Loop over all available audio drivers */
  121. iMax = SDL_GetNumAudioDrivers();
  122. SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
  123. SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
  124. for (i = 0; i < iMax; i++) {
  125. audioDriver = SDL_GetAudioDriver(i);
  126. SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
  127. SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
  128. SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
  129. /* Change specs */
  130. for (j = 0; j < 2; j++) {
  131. /* Call Init */
  132. result = SDL_AudioInit(audioDriver);
  133. SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
  134. SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
  135. /* Set spec */
  136. SDL_memset(&desired, 0, sizeof(desired));
  137. switch (j) {
  138. case 0:
  139. /* Set standard desired spec */
  140. desired.freq = 22050;
  141. desired.format = AUDIO_S16SYS;
  142. desired.channels = 2;
  143. desired.samples = 4096;
  144. desired.callback = _audio_testCallback;
  145. desired.userdata = NULL;
  146. case 1:
  147. /* Set custom desired spec */
  148. desired.freq = 48000;
  149. desired.format = AUDIO_F32SYS;
  150. desired.channels = 2;
  151. desired.samples = 2048;
  152. desired.callback = _audio_testCallback;
  153. desired.userdata = NULL;
  154. break;
  155. }
  156. /* Call Open (maybe multiple times) */
  157. for (k=0; k <= j; k++) {
  158. result = SDL_OpenAudio(&desired, NULL);
  159. SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL), call %d", j, k+1);
  160. expectedResult = (k==0) ? 0 : -1;
  161. SDLTest_AssertCheck(result == expectedResult, "Verify return value; expected: %d, got: %d", expectedResult, result);
  162. }
  163. /* Call Close (maybe multiple times) */
  164. for (k=0; k <= j; k++) {
  165. SDL_CloseAudio();
  166. SDLTest_AssertPass("Call to SDL_CloseAudio(), call %d", k+1);
  167. }
  168. /* Call Quit (maybe multiple times) */
  169. for (k=0; k <= j; k++) {
  170. SDL_AudioQuit();
  171. SDLTest_AssertPass("Call to SDL_AudioQuit(), call %d", k+1);
  172. }
  173. } /* spec loop */
  174. } /* driver loop */
  175. /* Restart audio again */
  176. _audioSetUp(NULL);
  177. return TEST_COMPLETED;
  178. }
  179. /**
  180. * \brief Pause and unpause audio
  181. *
  182. * \sa https://wiki.libsdl.org/SDL_PauseAudio
  183. */
  184. int audio_pauseUnpauseAudio()
  185. {
  186. int result;
  187. int i, iMax, j, k, l;
  188. int totalDelay;
  189. int pause_on;
  190. int originalCounter;
  191. const char* audioDriver;
  192. SDL_AudioSpec desired;
  193. /* Stop SDL audio subsystem */
  194. SDL_QuitSubSystem( SDL_INIT_AUDIO );
  195. SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
  196. /* Loop over all available audio drivers */
  197. iMax = SDL_GetNumAudioDrivers();
  198. SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
  199. SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
  200. for (i = 0; i < iMax; i++) {
  201. audioDriver = SDL_GetAudioDriver(i);
  202. SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
  203. SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
  204. SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
  205. /* Change specs */
  206. for (j = 0; j < 2; j++) {
  207. /* Call Init */
  208. result = SDL_AudioInit(audioDriver);
  209. SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
  210. SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
  211. /* Set spec */
  212. SDL_memset(&desired, 0, sizeof(desired));
  213. switch (j) {
  214. case 0:
  215. /* Set standard desired spec */
  216. desired.freq = 22050;
  217. desired.format = AUDIO_S16SYS;
  218. desired.channels = 2;
  219. desired.samples = 4096;
  220. desired.callback = _audio_testCallback;
  221. desired.userdata = NULL;
  222. case 1:
  223. /* Set custom desired spec */
  224. desired.freq = 48000;
  225. desired.format = AUDIO_F32SYS;
  226. desired.channels = 2;
  227. desired.samples = 2048;
  228. desired.callback = _audio_testCallback;
  229. desired.userdata = NULL;
  230. break;
  231. }
  232. /* Call Open */
  233. result = SDL_OpenAudio(&desired, NULL);
  234. SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
  235. SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
  236. /* Start and stop audio multiple times */
  237. for (l=0; l<3; l++) {
  238. SDLTest_Log("Pause/Unpause iteration: %d", l+1);
  239. /* Reset callback counters */
  240. _audio_testCallbackCounter = 0;
  241. _audio_testCallbackLength = 0;
  242. /* Un-pause audio to start playing (maybe multiple times) */
  243. pause_on = 0;
  244. for (k=0; k <= j; k++) {
  245. SDL_PauseAudio(pause_on);
  246. SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1);
  247. }
  248. /* Wait for callback */
  249. totalDelay = 0;
  250. do {
  251. SDL_Delay(10);
  252. totalDelay += 10;
  253. }
  254. while (_audio_testCallbackCounter == 0 && totalDelay < 1000);
  255. SDLTest_AssertCheck(_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", _audio_testCallbackCounter);
  256. SDLTest_AssertCheck(_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", _audio_testCallbackLength);
  257. /* Pause audio to stop playing (maybe multiple times) */
  258. for (k=0; k <= j; k++) {
  259. pause_on = (k==0) ? 1 : SDLTest_RandomIntegerInRange(99, 9999);
  260. SDL_PauseAudio(pause_on);
  261. SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1);
  262. }
  263. /* Ensure callback is not called again */
  264. originalCounter = _audio_testCallbackCounter;
  265. SDL_Delay(totalDelay + 10);
  266. SDLTest_AssertCheck(originalCounter == _audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, _audio_testCallbackCounter);
  267. }
  268. /* Call Close */
  269. SDL_CloseAudio();
  270. SDLTest_AssertPass("Call to SDL_CloseAudio()");
  271. /* Call Quit */
  272. SDL_AudioQuit();
  273. SDLTest_AssertPass("Call to SDL_AudioQuit()");
  274. } /* spec loop */
  275. } /* driver loop */
  276. /* Restart audio again */
  277. _audioSetUp(NULL);
  278. return TEST_COMPLETED;
  279. }
  280. /**
  281. * \brief Enumerate and name available audio devices (output and capture).
  282. *
  283. * \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
  284. * \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
  285. */
  286. int audio_enumerateAndNameAudioDevices()
  287. {
  288. int t, tt;
  289. int i, n, nn;
  290. const char *name, *nameAgain;
  291. /* Iterate over types: t=0 output device, t=1 input/capture device */
  292. for (t=0; t<2; t++) {
  293. /* Get number of devices. */
  294. n = SDL_GetNumAudioDevices(t);
  295. SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t);
  296. SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "capture" : "output", n);
  297. SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n);
  298. /* Variation of non-zero type */
  299. if (t==1) {
  300. tt = t + SDLTest_RandomIntegerInRange(1,10);
  301. nn = SDL_GetNumAudioDevices(tt);
  302. SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn);
  303. nn = SDL_GetNumAudioDevices(-tt);
  304. SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn);
  305. }
  306. /* List devices. */
  307. if (n>0) {
  308. for (i=0; i<n; i++) {
  309. name = SDL_GetAudioDeviceName(i, t);
  310. SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
  311. SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t);
  312. if (name != NULL) {
  313. SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
  314. if (t==1) {
  315. /* Also try non-zero type */
  316. tt = t + SDLTest_RandomIntegerInRange(1,10);
  317. nameAgain = SDL_GetAudioDeviceName(i, tt);
  318. SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
  319. if (nameAgain != NULL) {
  320. SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
  321. SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0,
  322. "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
  323. i, t, i, tt);
  324. }
  325. }
  326. }
  327. }
  328. }
  329. }
  330. return TEST_COMPLETED;
  331. }
  332. /**
  333. * \brief Negative tests around enumeration and naming of audio devices.
  334. *
  335. * \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
  336. * \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
  337. */
  338. int audio_enumerateAndNameAudioDevicesNegativeTests()
  339. {
  340. int t;
  341. int i, j, no, nc;
  342. const char *name;
  343. /* Get number of devices. */
  344. no = SDL_GetNumAudioDevices(0);
  345. SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
  346. nc = SDL_GetNumAudioDevices(1);
  347. SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)");
  348. /* Invalid device index when getting name */
  349. for (t=0; t<2; t++) {
  350. /* Negative device index */
  351. i = SDLTest_RandomIntegerInRange(-10,-1);
  352. name = SDL_GetAudioDeviceName(i, t);
  353. SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
  354. SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
  355. /* Device index past range */
  356. for (j=0; j<3; j++) {
  357. i = (t) ? nc+j : no+j;
  358. name = SDL_GetAudioDeviceName(i, t);
  359. SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
  360. SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
  361. }
  362. /* Capture index past capture range but within output range */
  363. if ((no>0) && (no>nc) && (t==1)) {
  364. i = no-1;
  365. name = SDL_GetAudioDeviceName(i, t);
  366. SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
  367. SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
  368. }
  369. }
  370. return TEST_COMPLETED;
  371. }
  372. /**
  373. * \brief Checks available audio driver names.
  374. *
  375. * \sa https://wiki.libsdl.org/SDL_GetNumAudioDrivers
  376. * \sa https://wiki.libsdl.org/SDL_GetAudioDriver
  377. */
  378. int audio_printAudioDrivers()
  379. {
  380. int i, n;
  381. const char *name;
  382. /* Get number of drivers */
  383. n = SDL_GetNumAudioDrivers();
  384. SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
  385. SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n);
  386. /* List drivers. */
  387. if (n>0) {
  388. for (i=0; i<n; i++) {
  389. name = SDL_GetAudioDriver(i);
  390. SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i);
  391. SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
  392. if (name != NULL) {
  393. SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
  394. }
  395. }
  396. }
  397. return TEST_COMPLETED;
  398. }
  399. /**
  400. * \brief Checks current audio driver name with initialized audio.
  401. *
  402. * \sa https://wiki.libsdl.org/SDL_GetCurrentAudioDriver
  403. */
  404. int audio_printCurrentAudioDriver()
  405. {
  406. /* Check current audio driver */
  407. const char *name = SDL_GetCurrentAudioDriver();
  408. SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()");
  409. SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
  410. if (name != NULL) {
  411. SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
  412. }
  413. return TEST_COMPLETED;
  414. }
  415. /* Definition of all formats, channels, and frequencies used to test audio conversions */
  416. const int _numAudioFormats = 18;
  417. SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB,
  418. AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32,
  419. AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
  420. const char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB",
  421. "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32",
  422. "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
  423. const int _numAudioChannels = 4;
  424. Uint8 _audioChannels[] = { 1, 2, 4, 6 };
  425. const int _numAudioFrequencies = 4;
  426. int _audioFrequencies[] = { 11025, 22050, 44100, 48000 };
  427. /**
  428. * \brief Builds various audio conversion structures
  429. *
  430. * \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
  431. */
  432. int audio_buildAudioCVT()
  433. {
  434. int result;
  435. SDL_AudioCVT cvt;
  436. SDL_AudioSpec spec1;
  437. SDL_AudioSpec spec2;
  438. int i, ii, j, jj, k, kk;
  439. /* No conversion needed */
  440. spec1.format = AUDIO_S16LSB;
  441. spec1.channels = 2;
  442. spec1.freq = 22050;
  443. result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
  444. spec1.format, spec1.channels, spec1.freq);
  445. SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec1)");
  446. SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0, got: %i", result);
  447. /* Typical conversion */
  448. spec1.format = AUDIO_S8;
  449. spec1.channels = 1;
  450. spec1.freq = 22050;
  451. spec2.format = AUDIO_S16LSB;
  452. spec2.channels = 2;
  453. spec2.freq = 44100;
  454. result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
  455. spec2.format, spec2.channels, spec2.freq);
  456. SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
  457. SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
  458. /* All source conversions with random conversion targets, allow 'null' conversions */
  459. for (i = 0; i < _numAudioFormats; i++) {
  460. for (j = 0; j < _numAudioChannels; j++) {
  461. for (k = 0; k < _numAudioFrequencies; k++) {
  462. spec1.format = _audioFormats[i];
  463. spec1.channels = _audioChannels[j];
  464. spec1.freq = _audioFrequencies[k];
  465. ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
  466. jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
  467. kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
  468. spec2.format = _audioFormats[ii];
  469. spec2.channels = _audioChannels[jj];
  470. spec2.freq = _audioFrequencies[kk];
  471. result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
  472. spec2.format, spec2.channels, spec2.freq);
  473. 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)",
  474. i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
  475. SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result);
  476. if (result<0) {
  477. SDLTest_LogError("%s", SDL_GetError());
  478. } else {
  479. SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
  480. }
  481. }
  482. }
  483. }
  484. return TEST_COMPLETED;
  485. }
  486. /**
  487. * \brief Checkes calls with invalid input to SDL_BuildAudioCVT
  488. *
  489. * \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
  490. */
  491. int audio_buildAudioCVTNegative()
  492. {
  493. const char *expectedError = "Parameter 'cvt' is invalid";
  494. const char *error;
  495. int result;
  496. SDL_AudioCVT cvt;
  497. SDL_AudioSpec spec1;
  498. SDL_AudioSpec spec2;
  499. int i;
  500. char message[256];
  501. /* Valid format */
  502. spec1.format = AUDIO_S8;
  503. spec1.channels = 1;
  504. spec1.freq = 22050;
  505. spec2.format = AUDIO_S16LSB;
  506. spec2.channels = 2;
  507. spec2.freq = 44100;
  508. SDL_ClearError();
  509. SDLTest_AssertPass("Call to SDL_ClearError()");
  510. /* NULL input for CVT buffer */
  511. result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq,
  512. spec2.format, spec2.channels, spec2.freq);
  513. SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)");
  514. SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
  515. error = SDL_GetError();
  516. SDLTest_AssertPass("Call to SDL_GetError()");
  517. SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
  518. if (error != NULL) {
  519. SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
  520. "Validate error message, expected: '%s', got: '%s'", expectedError, error);
  521. }
  522. /* Invalid conversions */
  523. for (i = 1; i < 64; i++) {
  524. /* Valid format to start with */
  525. spec1.format = AUDIO_S8;
  526. spec1.channels = 1;
  527. spec1.freq = 22050;
  528. spec2.format = AUDIO_S16LSB;
  529. spec2.channels = 2;
  530. spec2.freq = 44100;
  531. SDL_ClearError();
  532. SDLTest_AssertPass("Call to SDL_ClearError()");
  533. /* Set various invalid format inputs */
  534. SDL_strlcpy(message, "Invalid: ", 256);
  535. if (i & 1) {
  536. SDL_strlcat(message, " spec1.format", 256);
  537. spec1.format = 0;
  538. }
  539. if (i & 2) {
  540. SDL_strlcat(message, " spec1.channels", 256);
  541. spec1.channels = 0;
  542. }
  543. if (i & 4) {
  544. SDL_strlcat(message, " spec1.freq", 256);
  545. spec1.freq = 0;
  546. }
  547. if (i & 8) {
  548. SDL_strlcat(message, " spec2.format", 256);
  549. spec2.format = 0;
  550. }
  551. if (i & 16) {
  552. SDL_strlcat(message, " spec2.channels", 256);
  553. spec2.channels = 0;
  554. }
  555. if (i & 32) {
  556. SDL_strlcat(message, " spec2.freq", 256);
  557. spec2.freq = 0;
  558. }
  559. SDLTest_Log("%s", message);
  560. result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
  561. spec2.format, spec2.channels, spec2.freq);
  562. SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
  563. SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
  564. error = SDL_GetError();
  565. SDLTest_AssertPass("Call to SDL_GetError()");
  566. SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty");
  567. }
  568. SDL_ClearError();
  569. SDLTest_AssertPass("Call to SDL_ClearError()");
  570. return TEST_COMPLETED;
  571. }
  572. /**
  573. * \brief Checks current audio status.
  574. *
  575. * \sa https://wiki.libsdl.org/SDL_GetAudioStatus
  576. */
  577. int audio_getAudioStatus()
  578. {
  579. SDL_AudioStatus result;
  580. /* Check current audio status */
  581. result = SDL_GetAudioStatus();
  582. SDLTest_AssertPass("Call to SDL_GetAudioStatus()");
  583. SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
  584. "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
  585. SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result);
  586. return TEST_COMPLETED;
  587. }
  588. /**
  589. * \brief Opens, checks current audio status, and closes a device.
  590. *
  591. * \sa https://wiki.libsdl.org/SDL_GetAudioStatus
  592. */
  593. int audio_openCloseAndGetAudioStatus()
  594. {
  595. SDL_AudioStatus result;
  596. int i;
  597. int count;
  598. const char *device;
  599. SDL_AudioDeviceID id;
  600. SDL_AudioSpec desired, obtained;
  601. /* Get number of devices. */
  602. count = SDL_GetNumAudioDevices(0);
  603. SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
  604. if (count > 0) {
  605. for (i = 0; i < count; i++) {
  606. /* Get device name */
  607. device = SDL_GetAudioDeviceName(i, 0);
  608. SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
  609. SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
  610. if (device == NULL) {
  611. return TEST_ABORTED;
  612. }
  613. /* Set standard desired spec */
  614. desired.freq=22050;
  615. desired.format=AUDIO_S16SYS;
  616. desired.channels=2;
  617. desired.samples=4096;
  618. desired.callback=_audio_testCallback;
  619. desired.userdata=NULL;
  620. /* Open device */
  621. id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
  622. SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
  623. SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %" SDL_PRIu32, id);
  624. if (id > 1) {
  625. /* Check device audio status */
  626. result = SDL_GetAudioDeviceStatus(id);
  627. SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()");
  628. SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
  629. "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
  630. SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED, result);
  631. /* Close device again */
  632. SDL_CloseAudioDevice(id);
  633. SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
  634. }
  635. }
  636. } else {
  637. SDLTest_Log("No devices to test with");
  638. }
  639. return TEST_COMPLETED;
  640. }
  641. /**
  642. * \brief Locks and unlocks open audio device.
  643. *
  644. * \sa https://wiki.libsdl.org/SDL_LockAudioDevice
  645. * \sa https://wiki.libsdl.org/SDL_UnlockAudioDevice
  646. */
  647. int audio_lockUnlockOpenAudioDevice()
  648. {
  649. int i;
  650. int count;
  651. const char *device;
  652. SDL_AudioDeviceID id;
  653. SDL_AudioSpec desired, obtained;
  654. /* Get number of devices. */
  655. count = SDL_GetNumAudioDevices(0);
  656. SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
  657. if (count > 0) {
  658. for (i = 0; i < count; i++) {
  659. /* Get device name */
  660. device = SDL_GetAudioDeviceName(i, 0);
  661. SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
  662. SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
  663. if (device == NULL) {
  664. return TEST_ABORTED;
  665. }
  666. /* Set standard desired spec */
  667. desired.freq=22050;
  668. desired.format=AUDIO_S16SYS;
  669. desired.channels=2;
  670. desired.samples=4096;
  671. desired.callback=_audio_testCallback;
  672. desired.userdata=NULL;
  673. /* Open device */
  674. id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
  675. SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
  676. SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %" SDL_PRIu32, id);
  677. if (id > 1) {
  678. /* Lock to protect callback */
  679. SDL_LockAudioDevice(id);
  680. SDLTest_AssertPass("SDL_LockAudioDevice(%" SDL_PRIu32 ")", id);
  681. /* Simulate callback processing */
  682. SDL_Delay(10);
  683. SDLTest_Log("Simulate callback processing - delay");
  684. /* Unlock again */
  685. SDL_UnlockAudioDevice(id);
  686. SDLTest_AssertPass("SDL_UnlockAudioDevice(%" SDL_PRIu32 ")", id);
  687. /* Close device again */
  688. SDL_CloseAudioDevice(id);
  689. SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
  690. }
  691. }
  692. } else {
  693. SDLTest_Log("No devices to test with");
  694. }
  695. return TEST_COMPLETED;
  696. }
  697. /**
  698. * \brief Convert audio using various conversion structures
  699. *
  700. * \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
  701. * \sa https://wiki.libsdl.org/SDL_ConvertAudio
  702. */
  703. int audio_convertAudio()
  704. {
  705. int result;
  706. SDL_AudioCVT cvt;
  707. SDL_AudioSpec spec1;
  708. SDL_AudioSpec spec2;
  709. int c;
  710. char message[128];
  711. int i, ii, j, jj, k, kk, l, ll;
  712. /* Iterate over bitmask that determines which parameters are modified in the conversion */
  713. for (c = 1; c < 8; c++) {
  714. SDL_strlcpy(message, "Changing:", 128);
  715. if (c & 1) {
  716. SDL_strlcat(message, " Format", 128);
  717. }
  718. if (c & 2) {
  719. SDL_strlcat(message, " Channels", 128);
  720. }
  721. if (c & 4) {
  722. SDL_strlcat(message, " Frequencies", 128);
  723. }
  724. SDLTest_Log("%s", message);
  725. /* All source conversions with random conversion targets */
  726. for (i = 0; i < _numAudioFormats; i++) {
  727. for (j = 0; j < _numAudioChannels; j++) {
  728. for (k = 0; k < _numAudioFrequencies; k++) {
  729. spec1.format = _audioFormats[i];
  730. spec1.channels = _audioChannels[j];
  731. spec1.freq = _audioFrequencies[k];
  732. /* Ensure we have a different target format */
  733. do {
  734. if (c & 1) {
  735. ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
  736. } else {
  737. ii = 1;
  738. }
  739. if (c & 2) {
  740. jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
  741. } else {
  742. jj= j;
  743. }
  744. if (c & 4) {
  745. kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
  746. } else {
  747. kk = k;
  748. }
  749. } while ((i == ii) && (j == jj) && (k == kk));
  750. spec2.format = _audioFormats[ii];
  751. spec2.channels = _audioChannels[jj];
  752. spec2.freq = _audioFrequencies[kk];
  753. result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
  754. spec2.format, spec2.channels, spec2.freq);
  755. 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)",
  756. i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
  757. SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
  758. if (result != 1) {
  759. SDLTest_LogError("%s", SDL_GetError());
  760. } else {
  761. SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
  762. if (cvt.len_mult < 1) {
  763. return TEST_ABORTED;
  764. }
  765. /* Create some random data to convert */
  766. l = 64;
  767. ll = l * cvt.len_mult;
  768. SDLTest_Log("Creating dummy sample buffer of %i length (%i bytes)", l, ll);
  769. cvt.len = l;
  770. cvt.buf = (Uint8 *)SDL_malloc(ll);
  771. SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL");
  772. if (cvt.buf == NULL) {
  773. return TEST_ABORTED;
  774. }
  775. /* Convert the data */
  776. result = SDL_ConvertAudio(&cvt);
  777. SDLTest_AssertPass("Call to SDL_ConvertAudio()");
  778. SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result);
  779. SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL");
  780. SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio);
  781. /* Free converted buffer */
  782. SDL_free(cvt.buf);
  783. cvt.buf = NULL;
  784. }
  785. }
  786. }
  787. }
  788. }
  789. return TEST_COMPLETED;
  790. }
  791. /**
  792. * \brief Opens, checks current connected status, and closes a device.
  793. *
  794. * \sa https://wiki.libsdl.org/SDL_AudioDeviceConnected
  795. */
  796. int audio_openCloseAudioDeviceConnected()
  797. {
  798. int result = -1;
  799. int i;
  800. int count;
  801. const char *device;
  802. SDL_AudioDeviceID id;
  803. SDL_AudioSpec desired, obtained;
  804. /* Get number of devices. */
  805. count = SDL_GetNumAudioDevices(0);
  806. SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
  807. if (count > 0) {
  808. for (i = 0; i < count; i++) {
  809. /* Get device name */
  810. device = SDL_GetAudioDeviceName(i, 0);
  811. SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
  812. SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
  813. if (device == NULL) {
  814. return TEST_ABORTED;
  815. }
  816. /* Set standard desired spec */
  817. desired.freq=22050;
  818. desired.format=AUDIO_S16SYS;
  819. desired.channels=2;
  820. desired.samples=4096;
  821. desired.callback=_audio_testCallback;
  822. desired.userdata=NULL;
  823. /* Open device */
  824. id = SDL_OpenAudioDevice(device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
  825. SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
  826. SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %" SDL_PRIu32, id);
  827. if (id > 1) {
  828. /* TODO: enable test code when function is available in SDL3 */
  829. #ifdef AUDIODEVICECONNECTED_DEFINED
  830. /* Get connected status */
  831. result = SDL_AudioDeviceConnected(id);
  832. SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()");
  833. #endif
  834. SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result);
  835. /* Close device again */
  836. SDL_CloseAudioDevice(id);
  837. SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
  838. }
  839. }
  840. } else {
  841. SDLTest_Log("No devices to test with");
  842. }
  843. return TEST_COMPLETED;
  844. }
  845. /* ================= Test Case References ================== */
  846. /* Audio test cases */
  847. static const SDLTest_TestCaseReference audioTest1 =
  848. { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED };
  849. static const SDLTest_TestCaseReference audioTest2 =
  850. { (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED };
  851. static const SDLTest_TestCaseReference audioTest3 =
  852. { (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED };
  853. static const SDLTest_TestCaseReference audioTest4 =
  854. { (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED };
  855. static const SDLTest_TestCaseReference audioTest5 =
  856. { (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED };
  857. static const SDLTest_TestCaseReference audioTest6 =
  858. { (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED };
  859. static const SDLTest_TestCaseReference audioTest7 =
  860. { (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED };
  861. static const SDLTest_TestCaseReference audioTest8 =
  862. { (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED };
  863. static const SDLTest_TestCaseReference audioTest9 =
  864. { (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED };
  865. /* TODO: enable test when SDL_ConvertAudio segfaults on cygwin have been fixed. */
  866. /* For debugging, test case can be run manually using --filter audio_convertAudio */
  867. static const SDLTest_TestCaseReference audioTest10 =
  868. { (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED };
  869. /* TODO: enable test when SDL_AudioDeviceConnected has been implemented. */
  870. static const SDLTest_TestCaseReference audioTest11 =
  871. { (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED };
  872. static const SDLTest_TestCaseReference audioTest12 =
  873. { (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED };
  874. static const SDLTest_TestCaseReference audioTest13 =
  875. { (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_ENABLED };
  876. static const SDLTest_TestCaseReference audioTest14 =
  877. { (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_ENABLED };
  878. static const SDLTest_TestCaseReference audioTest15 =
  879. { (SDLTest_TestCaseFp)audio_pauseUnpauseAudio, "audio_pauseUnpauseAudio", "Pause and Unpause audio for various audio specs while testing callback.", TEST_ENABLED };
  880. /* Sequence of Audio test cases */
  881. static const SDLTest_TestCaseReference *audioTests[] = {
  882. &audioTest1, &audioTest2, &audioTest3, &audioTest4, &audioTest5, &audioTest6,
  883. &audioTest7, &audioTest8, &audioTest9, &audioTest10, &audioTest11,
  884. &audioTest12, &audioTest13, &audioTest14, &audioTest15, NULL
  885. };
  886. /* Audio test suite (global) */
  887. SDLTest_TestSuiteReference audioTestSuite = {
  888. "Audio",
  889. _audioSetUp,
  890. audioTests,
  891. _audioTearDown
  892. };
  893. /* vi: set ts=4 sw=4 expandtab: */