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