testautomation_audio.c 40 KB

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