testautomation_audio.c 41 KB

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