SDL  2.0
testautomation_audio.c File Reference
#include <stdio.h>
#include <string.h>
#include "SDL.h"
#include "SDL_test.h"
+ Include dependency graph for testautomation_audio.c:

Go to the source code of this file.

Macros

#define _CRT_SECURE_NO_WARNINGS
 

Functions

void _audioSetUp (void *arg)
 
void _audioTearDown (void *arg)
 
void _audio_testCallback (void *userdata, Uint8 *stream, int len)
 
int audio_quitInitAudioSubSystem ()
 Stop and restart audio subsystem. More...
 
int audio_initQuitAudio ()
 Start and stop audio directly. More...
 
int audio_initOpenCloseQuitAudio ()
 Start, open, close and stop audio. More...
 
int audio_pauseUnpauseAudio ()
 Pause and unpause audio. More...
 
int audio_enumerateAndNameAudioDevices ()
 Enumerate and name available audio devices (output and capture). More...
 
int audio_enumerateAndNameAudioDevicesNegativeTests ()
 Negative tests around enumeration and naming of audio devices. More...
 
int audio_printAudioDrivers ()
 Checks available audio driver names. More...
 
int audio_printCurrentAudioDriver ()
 Checks current audio driver name with initialized audio. More...
 
int audio_buildAudioCVT ()
 Builds various audio conversion structures. More...
 
int audio_buildAudioCVTNegative ()
 Checkes calls with invalid input to SDL_BuildAudioCVT. More...
 
int audio_getAudioStatus ()
 Checks current audio status. More...
 
int audio_openCloseAndGetAudioStatus ()
 Opens, checks current audio status, and closes a device. More...
 
int audio_lockUnlockOpenAudioDevice ()
 Locks and unlocks open audio device. More...
 
int audio_convertAudio ()
 Convert audio using various conversion structures. More...
 
int audio_openCloseAudioDeviceConnected ()
 Opens, checks current connected status, and closes a device. More...
 

Variables

int _audio_testCallbackCounter
 
int _audio_testCallbackLength
 
const int _numAudioFormats = 18
 
SDL_AudioFormat _audioFormats []
 
char * _audioFormatsVerbose []
 
const int _numAudioChannels = 4
 
Uint8 _audioChannels [] = { 1, 2, 4, 6 }
 
const int _numAudioFrequencies = 4
 
int _audioFrequencies [] = { 11025, 22050, 44100, 48000 }
 
static const SDLTest_TestCaseReference audioTest1
 
static const SDLTest_TestCaseReference audioTest2
 
static const SDLTest_TestCaseReference audioTest3
 
static const SDLTest_TestCaseReference audioTest4
 
static const SDLTest_TestCaseReference audioTest5
 
static const SDLTest_TestCaseReference audioTest6
 
static const SDLTest_TestCaseReference audioTest7
 
static const SDLTest_TestCaseReference audioTest8
 
static const SDLTest_TestCaseReference audioTest9
 
static const SDLTest_TestCaseReference audioTest10
 
static const SDLTest_TestCaseReference audioTest11
 
static const SDLTest_TestCaseReference audioTest12
 
static const SDLTest_TestCaseReference audioTest13
 
static const SDLTest_TestCaseReference audioTest14
 
static const SDLTest_TestCaseReference audioTest15
 
static const SDLTest_TestCaseReferenceaudioTests []
 
SDLTest_TestSuiteReference audioTestSuite
 

Macro Definition Documentation

◆ _CRT_SECURE_NO_WARNINGS

#define _CRT_SECURE_NO_WARNINGS

Original code: automated SDL audio test written by Edgar Simo "bobbens" New/updated tests: aschiffler at ferzkopp dot net

Definition at line 7 of file testautomation_audio.c.

Function Documentation

◆ _audio_testCallback()

void _audio_testCallback ( void userdata,
Uint8 stream,
int  len 
)

◆ _audioSetUp()

void _audioSetUp ( void arg)

Definition at line 20 of file testautomation_audio.c.

References SDL_GetError, SDL_INIT_AUDIO, SDL_InitSubSystem, SDLTest_AssertCheck(), SDLTest_AssertPass(), and SDLTest_LogError().

Referenced by audio_initOpenCloseQuitAudio(), audio_initQuitAudio(), audio_pauseUnpauseAudio(), and audio_quitInitAudioSubSystem().

21 {
22  /* Start SDL audio subsystem */
23  int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
24  SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)");
25  SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
26  if (ret != 0) {
28  }
29 }
#define SDL_GetError
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
#define SDL_InitSubSystem
void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and the ERROR priority.
Definition: SDL_test_log.c:103
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_INIT_AUDIO
Definition: SDL.h:77

◆ _audioTearDown()

void _audioTearDown ( void arg)

Definition at line 32 of file testautomation_audio.c.

References SDLTest_AssertPass().

33 {
34  /* Remove a possibly created file from SDL disk writer audio driver; ignore errors */
35  remove("sdlaudio.raw");
36 
37  SDLTest_AssertPass("Cleanup of test files completed");
38 }
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.

◆ audio_buildAudioCVT()

int audio_buildAudioCVT ( )

Builds various audio conversion structures.

See also
https://wiki.libsdl.org/SDL_BuildAudioCVT

Definition at line 515 of file testautomation_audio.c.

References _audioChannels, _audioFormats, _audioFormatsVerbose, _audioFrequencies, _numAudioChannels, _numAudioFormats, _numAudioFrequencies, AUDIO_S16LSB, AUDIO_S8, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, j, k, SDL_AudioCVT::len_mult, SDL_BuildAudioCVT, SDL_GetError, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_LogError(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

516 {
517  int result;
518  SDL_AudioCVT cvt;
519  SDL_AudioSpec spec1;
520  SDL_AudioSpec spec2;
521  int i, ii, j, jj, k, kk;
522 
523  /* No conversion needed */
524  spec1.format = AUDIO_S16LSB;
525  spec1.channels = 2;
526  spec1.freq = 22050;
527  result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
528  spec1.format, spec1.channels, spec1.freq);
529  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec1)");
530  SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0, got: %i", result);
531 
532  /* Typical conversion */
533  spec1.format = AUDIO_S8;
534  spec1.channels = 1;
535  spec1.freq = 22050;
536  spec2.format = AUDIO_S16LSB;
537  spec2.channels = 2;
538  spec2.freq = 44100;
539  result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
540  spec2.format, spec2.channels, spec2.freq);
541  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
542  SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
543 
544  /* All source conversions with random conversion targets, allow 'null' conversions */
545  for (i = 0; i < _numAudioFormats; i++) {
546  for (j = 0; j < _numAudioChannels; j++) {
547  for (k = 0; k < _numAudioFrequencies; k++) {
548  spec1.format = _audioFormats[i];
549  spec1.channels = _audioChannels[j];
550  spec1.freq = _audioFrequencies[k];
551  ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
552  jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
553  kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
554  spec2.format = _audioFormats[ii];
555  spec2.channels = _audioChannels[jj];
556  spec2.freq = _audioFrequencies[kk];
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(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
560  i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
561  SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result);
562  if (result<0) {
564  } else {
565  SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
566  }
567  }
568  }
569  }
570 
571  return TEST_COMPLETED;
572 }
#define SDL_GetError
GLuint64EXT * result
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
#define SDL_BuildAudioCVT
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
char * _audioFormatsVerbose[]
int _audioFrequencies[]
SDL_AudioFormat _audioFormats[]
const int _numAudioFrequencies
A structure to hold a set of audio conversion filters and buffers.
Definition: SDL_audio.h:225
const int _numAudioChannels
void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and the ERROR priority.
Definition: SDL_test_log.c:103
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
Uint8 _audioChannels[]
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
const int _numAudioFormats
SDL_AudioFormat format
Definition: SDL_audio.h:180
#define AUDIO_S16LSB
Definition: SDL_audio.h:92
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
Definition: SDL_x11sym.h:213
#define AUDIO_S8
Definition: SDL_audio.h:90

◆ audio_buildAudioCVTNegative()

int audio_buildAudioCVTNegative ( )

Checkes calls with invalid input to SDL_BuildAudioCVT.

See also
https://wiki.libsdl.org/SDL_BuildAudioCVT

Definition at line 579 of file testautomation_audio.c.

References AUDIO_S16LSB, AUDIO_S8, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, NULL, SDL_BuildAudioCVT, SDL_ClearError, SDL_GetError, SDL_strcmp, SDL_strlcat, SDL_strlcpy, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), and TEST_COMPLETED.

580 {
581  const char *expectedError = "Parameter 'cvt' is invalid";
582  const char *error;
583  int result;
584  SDL_AudioCVT cvt;
585  SDL_AudioSpec spec1;
586  SDL_AudioSpec spec2;
587  int i;
588  char message[256];
589 
590  /* Valid format */
591  spec1.format = AUDIO_S8;
592  spec1.channels = 1;
593  spec1.freq = 22050;
594  spec2.format = AUDIO_S16LSB;
595  spec2.channels = 2;
596  spec2.freq = 44100;
597 
598  SDL_ClearError();
599  SDLTest_AssertPass("Call to SDL_ClearError()");
600 
601  /* NULL input for CVT buffer */
602  result = SDL_BuildAudioCVT((SDL_AudioCVT *)NULL, spec1.format, spec1.channels, spec1.freq,
603  spec2.format, spec2.channels, spec2.freq);
604  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(NULL,...)");
605  SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
606  error = SDL_GetError();
607  SDLTest_AssertPass("Call to SDL_GetError()");
608  SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
609  if (error != NULL) {
610  SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
611  "Validate error message, expected: '%s', got: '%s'", expectedError, error);
612  }
613 
614  /* Invalid conversions */
615  for (i = 1; i < 64; i++) {
616  /* Valid format to start with */
617  spec1.format = AUDIO_S8;
618  spec1.channels = 1;
619  spec1.freq = 22050;
620  spec2.format = AUDIO_S16LSB;
621  spec2.channels = 2;
622  spec2.freq = 44100;
623 
624  SDL_ClearError();
625  SDLTest_AssertPass("Call to SDL_ClearError()");
626 
627  /* Set various invalid format inputs */
628  SDL_strlcpy(message, "Invalid: ", 256);
629  if (i & 1) {
630  SDL_strlcat(message, " spec1.format", 256);
631  spec1.format = 0;
632  }
633  if (i & 2) {
634  SDL_strlcat(message, " spec1.channels", 256);
635  spec1.channels = 0;
636  }
637  if (i & 4) {
638  SDL_strlcat(message, " spec1.freq", 256);
639  spec1.freq = 0;
640  }
641  if (i & 8) {
642  SDL_strlcat(message, " spec2.format", 256);
643  spec2.format = 0;
644  }
645  if (i & 16) {
646  SDL_strlcat(message, " spec2.channels", 256);
647  spec2.channels = 0;
648  }
649  if (i & 32) {
650  SDL_strlcat(message, " spec2.freq", 256);
651  spec2.freq = 0;
652  }
653  SDLTest_Log("%s", message);
654  result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
655  spec2.format, spec2.channels, spec2.freq);
656  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(spec1 ==> spec2)");
657  SDLTest_AssertCheck(result == -1, "Verify result value; expected: -1, got: %i", result);
658  error = SDL_GetError();
659  SDLTest_AssertPass("Call to SDL_GetError()");
660  SDLTest_AssertCheck(error != NULL && error[0] != '\0', "Validate that error message was not NULL or empty");
661  }
662 
663  SDL_ClearError();
664  SDLTest_AssertPass("Call to SDL_ClearError()");
665 
666  return TEST_COMPLETED;
667 }
#define SDL_strlcpy
#define SDL_ClearError
#define SDL_GetError
#define SDL_strlcat
GLuint64EXT * result
GLuint GLsizei const GLchar * message
#define SDL_BuildAudioCVT
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
A structure to hold a set of audio conversion filters and buffers.
Definition: SDL_audio.h:225
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
SDL_AudioFormat format
Definition: SDL_audio.h:180
#define AUDIO_S16LSB
Definition: SDL_audio.h:92
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
#define SDL_strcmp
#define AUDIO_S8
Definition: SDL_audio.h:90

◆ audio_convertAudio()

int audio_convertAudio ( )

Convert audio using various conversion structures.

See also
https://wiki.libsdl.org/SDL_BuildAudioCVT
https://wiki.libsdl.org/SDL_ConvertAudio

Definition at line 817 of file testautomation_audio.c.

References _audioChannels, _audioFormats, _audioFormatsVerbose, _audioFrequencies, _numAudioChannels, _numAudioFormats, _numAudioFrequencies, SDL_AudioCVT::buf, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, j, k, SDL_AudioCVT::len, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, NULL, SDL_BuildAudioCVT, SDL_ConvertAudio, SDL_free, SDL_GetError, SDL_malloc, SDL_strlcat, SDL_strlcpy, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), SDLTest_LogError(), SDLTest_RandomIntegerInRange(), TEST_ABORTED, and TEST_COMPLETED.

818 {
819  int result;
820  SDL_AudioCVT cvt;
821  SDL_AudioSpec spec1;
822  SDL_AudioSpec spec2;
823  int c;
824  char message[128];
825  int i, ii, j, jj, k, kk, l, ll;
826 
827  /* Iterate over bitmask that determines which parameters are modified in the conversion */
828  for (c = 1; c < 8; c++) {
829  SDL_strlcpy(message, "Changing:", 128);
830  if (c & 1) {
831  SDL_strlcat(message, " Format", 128);
832  }
833  if (c & 2) {
834  SDL_strlcat(message, " Channels", 128);
835  }
836  if (c & 4) {
837  SDL_strlcat(message, " Frequencies", 128);
838  }
839  SDLTest_Log("%s", message);
840  /* All source conversions with random conversion targets */
841  for (i = 0; i < _numAudioFormats; i++) {
842  for (j = 0; j < _numAudioChannels; j++) {
843  for (k = 0; k < _numAudioFrequencies; k++) {
844  spec1.format = _audioFormats[i];
845  spec1.channels = _audioChannels[j];
846  spec1.freq = _audioFrequencies[k];
847 
848  /* Ensure we have a different target format */
849  do {
850  if (c & 1) {
851  ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
852  } else {
853  ii = 1;
854  }
855  if (c & 2) {
856  jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
857  } else {
858  jj= j;
859  }
860  if (c & 4) {
861  kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
862  } else {
863  kk = k;
864  }
865  } while ((i == ii) && (j == jj) && (k == kk));
866  spec2.format = _audioFormats[ii];
867  spec2.channels = _audioChannels[jj];
868  spec2.freq = _audioFrequencies[kk];
869 
870  result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
871  spec2.format, spec2.channels, spec2.freq);
872  SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
873  i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
874  SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
875  if (result != 1) {
877  } else {
878  SDLTest_AssertCheck(cvt.len_mult > 0, "Verify that cvt.len_mult value; expected: >0, got: %i", cvt.len_mult);
879  if (cvt.len_mult < 1) return TEST_ABORTED;
880 
881  /* Create some random data to convert */
882  l = 64;
883  ll = l * cvt.len_mult;
884  SDLTest_Log("Creating dummy sample buffer of %i length (%i bytes)", l, ll);
885  cvt.len = l;
886  cvt.buf = (Uint8 *)SDL_malloc(ll);
887  SDLTest_AssertCheck(cvt.buf != NULL, "Check data buffer to convert is not NULL");
888  if (cvt.buf == NULL) return TEST_ABORTED;
889 
890  /* Convert the data */
891  result = SDL_ConvertAudio(&cvt);
892  SDLTest_AssertPass("Call to SDL_ConvertAudio()");
893  SDLTest_AssertCheck(result == 0, "Verify result value; expected: 0; got: %i", result);
894  SDLTest_AssertCheck(cvt.buf != NULL, "Verify conversion buffer is not NULL");
895  SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio);
896 
897  /* Free converted buffer */
898  SDL_free(cvt.buf);
899  cvt.buf = NULL;
900  }
901  }
902  }
903  }
904  }
905 
906  return TEST_COMPLETED;
907 }
#define SDL_strlcpy
#define SDL_GetError
#define TEST_ABORTED
#define SDL_strlcat
GLuint64EXT * result
GLuint GLsizei const GLchar * message
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
Uint8 * buf
Definition: SDL_audio.h:231
#define SDL_BuildAudioCVT
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
char * _audioFormatsVerbose[]
int _audioFrequencies[]
SDL_AudioFormat _audioFormats[]
double len_ratio
Definition: SDL_audio.h:235
const int _numAudioFrequencies
A structure to hold a set of audio conversion filters and buffers.
Definition: SDL_audio.h:225
const int _numAudioChannels
void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and the ERROR priority.
Definition: SDL_test_log.c:103
#define SDL_ConvertAudio
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
uint8_t Uint8
Definition: SDL_stdinc.h:157
#define SDL_free
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
const GLubyte * c
Uint8 _audioChannels[]
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
const int _numAudioFormats
SDL_AudioFormat format
Definition: SDL_audio.h:180
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
Definition: SDL_x11sym.h:213
#define SDL_malloc

◆ audio_enumerateAndNameAudioDevices()

int audio_enumerateAndNameAudioDevices ( )

Enumerate and name available audio devices (output and capture).

See also
https://wiki.libsdl.org/SDL_GetNumAudioDevices
https://wiki.libsdl.org/SDL_GetAudioDeviceName

Definition at line 346 of file testautomation_audio.c.

References i, NULL, SDL_GetAudioDeviceName, SDL_GetNumAudioDevices, SDL_strcmp, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

347 {
348  int t, tt;
349  int i, n, nn;
350  const char *name, *nameAgain;
351 
352  /* Iterate over types: t=0 output device, t=1 input/capture device */
353  for (t=0; t<2; t++) {
354 
355  /* Get number of devices. */
356  n = SDL_GetNumAudioDevices(t);
357  SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t);
358  SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "capture" : "output", n);
359  SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n);
360 
361  /* Variation of non-zero type */
362  if (t==1) {
363  tt = t + SDLTest_RandomIntegerInRange(1,10);
364  nn = SDL_GetNumAudioDevices(tt);
365  SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn);
366  nn = SDL_GetNumAudioDevices(-tt);
367  SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn);
368  }
369 
370  /* List devices. */
371  if (n>0) {
372  for (i=0; i<n; i++) {
373  name = SDL_GetAudioDeviceName(i, t);
374  SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
375  SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t);
376  if (name != NULL) {
377  SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
378  if (t==1) {
379  /* Also try non-zero type */
380  tt = t + SDLTest_RandomIntegerInRange(1,10);
381  nameAgain = SDL_GetAudioDeviceName(i, tt);
382  SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
383  if (nameAgain != NULL) {
384  SDLTest_AssertCheck(nameAgain[0] != '\0', "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
385  SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0,
386  "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string",
387  i, t, i, tt);
388  }
389  }
390  }
391  }
392  }
393  }
394 
395  return TEST_COMPLETED;
396 }
#define SDL_GetNumAudioDevices
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLuint const GLchar * name
#define SDL_GetAudioDeviceName
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
GLdouble n
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
#define SDL_strcmp
GLdouble GLdouble t
Definition: SDL_opengl.h:2071

◆ audio_enumerateAndNameAudioDevicesNegativeTests()

int audio_enumerateAndNameAudioDevicesNegativeTests ( )

Negative tests around enumeration and naming of audio devices.

See also
https://wiki.libsdl.org/SDL_GetNumAudioDevices
https://wiki.libsdl.org/SDL_GetAudioDeviceName

Definition at line 404 of file testautomation_audio.c.

References i, j, NULL, SDL_GetAudioDeviceName, SDL_GetNumAudioDevices, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), and TEST_COMPLETED.

405 {
406  int t;
407  int i, j, no, nc;
408  const char *name;
409 
410  /* Get number of devices. */
411  no = SDL_GetNumAudioDevices(0);
412  SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
413  nc = SDL_GetNumAudioDevices(1);
414  SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)");
415 
416  /* Invalid device index when getting name */
417  for (t=0; t<2; t++) {
418  /* Negative device index */
419  i = SDLTest_RandomIntegerInRange(-10,-1);
420  name = SDL_GetAudioDeviceName(i, t);
421  SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
422  SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
423 
424  /* Device index past range */
425  for (j=0; j<3; j++) {
426  i = (t) ? nc+j : no+j;
427  name = SDL_GetAudioDeviceName(i, t);
428  SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
429  SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
430  }
431 
432  /* Capture index past capture range but within output range */
433  if ((no>0) && (no>nc) && (t==1)) {
434  i = no-1;
435  name = SDL_GetAudioDeviceName(i, t);
436  SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
437  SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
438  }
439  }
440 
441  return TEST_COMPLETED;
442 }
#define SDL_GetNumAudioDevices
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLuint const GLchar * name
#define SDL_GetAudioDeviceName
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
GLdouble GLdouble t
Definition: SDL_opengl.h:2071

◆ audio_getAudioStatus()

int audio_getAudioStatus ( )

Checks current audio status.

See also
https://wiki.libsdl.org/SDL_GetAudioStatus

Definition at line 674 of file testautomation_audio.c.

References SDL_AUDIO_PAUSED, SDL_AUDIO_PLAYING, SDL_AUDIO_STOPPED, SDL_GetAudioStatus, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

675 {
677 
678  /* Check current audio status */
679  result = SDL_GetAudioStatus();
680  SDLTest_AssertPass("Call to SDL_GetAudioStatus()");
681  SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
682  "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
684 
685  return TEST_COMPLETED;
686 }
#define SDL_GetAudioStatus
GLuint64EXT * result
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
SDL_AudioStatus
Definition: SDL_audio.h:394
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define TEST_COMPLETED

◆ audio_initOpenCloseQuitAudio()

int audio_initOpenCloseQuitAudio ( )

Start, open, close and stop audio.

See also
https://wiki.libsdl.org/SDL_InitAudio
https://wiki.libsdl.org/SDL_OpenAudio
https://wiki.libsdl.org/SDL_CloseAudio
https://wiki.libsdl.org/SDL_QuitAudio

Definition at line 139 of file testautomation_audio.c.

References _audio_testCallback(), _audioSetUp(), AUDIO_F32SYS, AUDIO_S16SYS, SDL_AudioSpec::callback, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, j, k, NULL, SDL_AudioSpec::samples, SDL_AudioInit, SDL_AudioQuit, SDL_CloseAudio, SDL_GetAudioDriver, SDL_GetNumAudioDrivers, SDL_INIT_AUDIO, SDL_memset, SDL_OpenAudio, SDL_QuitSubSystem, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_COMPLETED, and SDL_AudioSpec::userdata.

140 {
141  int result, expectedResult;
142  int i, iMax, j, k;
143  const char* audioDriver;
144  SDL_AudioSpec desired;
145 
146  /* Stop SDL audio subsystem */
148  SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
149 
150  /* Loop over all available audio drivers */
151  iMax = SDL_GetNumAudioDrivers();
152  SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
153  SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
154  for (i = 0; i < iMax; i++) {
155  audioDriver = SDL_GetAudioDriver(i);
156  SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
157  SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
158  SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
159 
160  /* Change specs */
161  for (j = 0; j < 2; j++) {
162 
163  /* Call Init */
164  result = SDL_AudioInit(audioDriver);
165  SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
166  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
167 
168  /* Set spec */
169  SDL_memset(&desired, 0, sizeof(desired));
170  switch (j) {
171  case 0:
172  /* Set standard desired spec */
173  desired.freq = 22050;
174  desired.format = AUDIO_S16SYS;
175  desired.channels = 2;
176  desired.samples = 4096;
177  desired.callback = _audio_testCallback;
178  desired.userdata = NULL;
179 
180  case 1:
181  /* Set custom desired spec */
182  desired.freq = 48000;
183  desired.format = AUDIO_F32SYS;
184  desired.channels = 2;
185  desired.samples = 2048;
186  desired.callback = _audio_testCallback;
187  desired.userdata = NULL;
188  break;
189  }
190 
191  /* Call Open (maybe multiple times) */
192  for (k=0; k <= j; k++) {
193  result = SDL_OpenAudio(&desired, NULL);
194  SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL), call %d", j, k+1);
195  expectedResult = (k==0) ? 0 : -1;
196  SDLTest_AssertCheck(result == expectedResult, "Verify return value; expected: %d, got: %d", expectedResult, result);
197  }
198 
199  /* Call Close (maybe multiple times) */
200  for (k=0; k <= j; k++) {
201  SDL_CloseAudio();
202  SDLTest_AssertPass("Call to SDL_CloseAudio(), call %d", k+1);
203  }
204 
205  /* Call Quit (maybe multiple times) */
206  for (k=0; k <= j; k++) {
207  SDL_AudioQuit();
208  SDLTest_AssertPass("Call to SDL_AudioQuit(), call %d", k+1);
209  }
210 
211  } /* spec loop */
212  } /* driver loop */
213 
214  /* Restart audio again */
215  _audioSetUp(NULL);
216 
217  return TEST_COMPLETED;
218 }
#define SDL_GetNumAudioDrivers
#define SDL_OpenAudio
GLuint64EXT * result
#define SDL_AudioInit
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
#define SDL_QuitSubSystem
Uint16 samples
Definition: SDL_audio.h:183
#define AUDIO_S16SYS
Definition: SDL_audio.h:123
#define SDL_AudioQuit
#define AUDIO_F32SYS
Definition: SDL_audio.h:125
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
#define SDL_GetAudioDriver
SDL_AudioCallback callback
Definition: SDL_audio.h:186
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
#define SDL_INIT_AUDIO
Definition: SDL.h:77
SDL_AudioFormat format
Definition: SDL_audio.h:180
#define SDL_CloseAudio
void * userdata
Definition: SDL_audio.h:187
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
Definition: SDL_x11sym.h:213
void _audio_testCallback(void *userdata, Uint8 *stream, int len)
void _audioSetUp(void *arg)
#define SDL_memset

◆ audio_initQuitAudio()

int audio_initQuitAudio ( )

Start and stop audio directly.

See also
https://wiki.libsdl.org/SDL_InitAudio
https://wiki.libsdl.org/SDL_QuitAudio

Definition at line 83 of file testautomation_audio.c.

References _audioSetUp(), i, NULL, SDL_AudioInit, SDL_AudioQuit, SDL_GetAudioDriver, SDL_GetNumAudioDrivers, SDL_INIT_AUDIO, SDL_QuitSubSystem, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

84 {
85  int result;
86  int i, iMax;
87  const char* audioDriver;
88 
89  /* Stop SDL audio subsystem */
91  SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
92 
93  /* Loop over all available audio drivers */
94  iMax = SDL_GetNumAudioDrivers();
95  SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
96  SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
97  for (i = 0; i < iMax; i++) {
98  audioDriver = SDL_GetAudioDriver(i);
99  SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
100  SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
101  SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
102 
103  /* Call Init */
104  result = SDL_AudioInit(audioDriver);
105  SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
106  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
107 
108  /* Call Quit */
109  SDL_AudioQuit();
110  SDLTest_AssertPass("Call to SDL_AudioQuit()");
111  }
112 
113  /* NULL driver specification */
114  audioDriver = NULL;
115 
116  /* Call Init */
117  result = SDL_AudioInit(audioDriver);
118  SDLTest_AssertPass("Call to SDL_AudioInit(NULL)");
119  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
120 
121  /* Call Quit */
122  SDL_AudioQuit();
123  SDLTest_AssertPass("Call to SDL_AudioQuit()");
124 
125  /* Restart audio again */
126  _audioSetUp(NULL);
127 
128  return TEST_COMPLETED;
129 }
#define SDL_GetNumAudioDrivers
GLuint64EXT * result
#define SDL_AudioInit
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
#define SDL_QuitSubSystem
#define SDL_AudioQuit
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_GetAudioDriver
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
#define SDL_INIT_AUDIO
Definition: SDL.h:77
void _audioSetUp(void *arg)

◆ audio_lockUnlockOpenAudioDevice()

int audio_lockUnlockOpenAudioDevice ( )

Locks and unlocks open audio device.

See also
https://wiki.libsdl.org/SDL_LockAudioDevice
https://wiki.libsdl.org/SDL_UnlockAudioDevice

Definition at line 754 of file testautomation_audio.c.

References _audio_testCallback(), AUDIO_S16SYS, SDL_AudioSpec::callback, SDL_AudioSpec::channels, device, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, NULL, SDL_AudioSpec::samples, SDL_AUDIO_ALLOW_ANY_CHANGE, SDL_CloseAudioDevice, SDL_Delay, SDL_GetAudioDeviceName, SDL_GetNumAudioDevices, SDL_LockAudioDevice, SDL_OpenAudioDevice, SDL_UnlockAudioDevice, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), TEST_ABORTED, TEST_COMPLETED, and SDL_AudioSpec::userdata.

755 {
756  int i;
757  int count;
758  char *device;
760  SDL_AudioSpec desired, obtained;
761 
762  /* Get number of devices. */
763  count = SDL_GetNumAudioDevices(0);
764  SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
765  if (count > 0) {
766  for (i = 0; i < count; i++) {
767  /* Get device name */
768  device = (char *)SDL_GetAudioDeviceName(i, 0);
769  SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
770  SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
771  if (device == NULL) return TEST_ABORTED;
772 
773  /* Set standard desired spec */
774  desired.freq=22050;
775  desired.format=AUDIO_S16SYS;
776  desired.channels=2;
777  desired.samples=4096;
779  desired.userdata=NULL;
780 
781  /* Open device */
782  id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
783  SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
784  SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
785  if (id > 1) {
786  /* Lock to protect callback */
788  SDLTest_AssertPass("SDL_LockAudioDevice(%i)", id);
789 
790  /* Simulate callback processing */
791  SDL_Delay(10);
792  SDLTest_Log("Simulate callback processing - delay");
793 
794  /* Unlock again */
796  SDLTest_AssertPass("SDL_UnlockAudioDevice(%i)", id);
797 
798  /* Close device again */
800  SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
801  }
802  }
803  } else {
804  SDLTest_Log("No devices to test with");
805  }
806 
807  return TEST_COMPLETED;
808 }
#define SDL_GetNumAudioDevices
GLuint id
#define SDL_CloseAudioDevice
#define TEST_ABORTED
#define SDL_OpenAudioDevice
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
#define SDL_LockAudioDevice
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Uint16 samples
Definition: SDL_audio.h:183
#define AUDIO_S16SYS
Definition: SDL_audio.h:123
static SDL_AudioDeviceID device
Definition: loopwave.c:37
#define SDL_GetAudioDeviceName
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_AUDIO_ALLOW_ANY_CHANGE
Definition: SDL_audio.h:143
SDL_AudioCallback callback
Definition: SDL_audio.h:186
#define TEST_COMPLETED
#define SDL_Delay
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
Uint32 SDL_AudioDeviceID
Definition: SDL_audio.h:329
SDL_AudioFormat format
Definition: SDL_audio.h:180
void * userdata
Definition: SDL_audio.h:187
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
void _audio_testCallback(void *userdata, Uint8 *stream, int len)
#define SDL_UnlockAudioDevice

◆ audio_openCloseAndGetAudioStatus()

int audio_openCloseAndGetAudioStatus ( )

Opens, checks current audio status, and closes a device.

See also
https://wiki.libsdl.org/SDL_GetAudioStatus

Definition at line 695 of file testautomation_audio.c.

References _audio_testCallback(), AUDIO_S16SYS, SDL_AudioSpec::callback, SDL_AudioSpec::channels, device, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, NULL, SDL_AudioSpec::samples, SDL_AUDIO_ALLOW_ANY_CHANGE, SDL_AUDIO_PAUSED, SDL_AUDIO_PLAYING, SDL_AUDIO_STOPPED, SDL_CloseAudioDevice, SDL_GetAudioDeviceName, SDL_GetAudioDeviceStatus, SDL_GetNumAudioDevices, SDL_OpenAudioDevice, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), TEST_ABORTED, TEST_COMPLETED, and SDL_AudioSpec::userdata.

696 {
698  int i;
699  int count;
700  char *device;
702  SDL_AudioSpec desired, obtained;
703 
704  /* Get number of devices. */
705  count = SDL_GetNumAudioDevices(0);
706  SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
707  if (count > 0) {
708  for (i = 0; i < count; i++) {
709  /* Get device name */
710  device = (char *)SDL_GetAudioDeviceName(i, 0);
711  SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
712  SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
713  if (device == NULL) return TEST_ABORTED;
714 
715  /* Set standard desired spec */
716  desired.freq=22050;
717  desired.format=AUDIO_S16SYS;
718  desired.channels=2;
719  desired.samples=4096;
721  desired.userdata=NULL;
722 
723  /* Open device */
724  id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
725  SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
726  SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >=2, got: %i", id);
727  if (id > 1) {
728 
729  /* Check device audio status */
730  result = SDL_GetAudioDeviceStatus(id);
731  SDLTest_AssertPass("Call to SDL_GetAudioDeviceStatus()");
732  SDLTest_AssertCheck(result == SDL_AUDIO_STOPPED || result == SDL_AUDIO_PLAYING || result == SDL_AUDIO_PAUSED,
733  "Verify returned value; expected: STOPPED (%i) | PLAYING (%i) | PAUSED (%i), got: %i",
735 
736  /* Close device again */
738  SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
739  }
740  }
741  } else {
742  SDLTest_Log("No devices to test with");
743  }
744 
745  return TEST_COMPLETED;
746 }
#define SDL_GetNumAudioDevices
GLuint id
#define SDL_CloseAudioDevice
#define TEST_ABORTED
GLuint64EXT * result
#define SDL_OpenAudioDevice
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
SDL_AudioStatus
Definition: SDL_audio.h:394
Uint16 samples
Definition: SDL_audio.h:183
#define AUDIO_S16SYS
Definition: SDL_audio.h:123
static SDL_AudioDeviceID device
Definition: loopwave.c:37
#define SDL_GetAudioDeviceName
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_AUDIO_ALLOW_ANY_CHANGE
Definition: SDL_audio.h:143
#define SDL_GetAudioDeviceStatus
SDL_AudioCallback callback
Definition: SDL_audio.h:186
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
Uint32 SDL_AudioDeviceID
Definition: SDL_audio.h:329
SDL_AudioFormat format
Definition: SDL_audio.h:180
void * userdata
Definition: SDL_audio.h:187
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
void _audio_testCallback(void *userdata, Uint8 *stream, int len)

◆ audio_openCloseAudioDeviceConnected()

int audio_openCloseAudioDeviceConnected ( )

Opens, checks current connected status, and closes a device.

See also
https://wiki.libsdl.org/SDL_AudioDeviceConnected

Definition at line 915 of file testautomation_audio.c.

References _audio_testCallback(), AUDIO_S16SYS, SDL_AudioSpec::callback, SDL_AudioSpec::channels, device, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, NULL, SDL_AudioSpec::samples, SDL_AUDIO_ALLOW_ANY_CHANGE, SDL_CloseAudioDevice, SDL_GetAudioDeviceName, SDL_GetNumAudioDevices, SDL_OpenAudioDevice, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), TEST_ABORTED, TEST_COMPLETED, and SDL_AudioSpec::userdata.

916 {
917  int result = -1;
918  int i;
919  int count;
920  char *device;
922  SDL_AudioSpec desired, obtained;
923 
924  /* Get number of devices. */
925  count = SDL_GetNumAudioDevices(0);
926  SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
927  if (count > 0) {
928  for (i = 0; i < count; i++) {
929  /* Get device name */
930  device = (char *)SDL_GetAudioDeviceName(i, 0);
931  SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
932  SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
933  if (device == NULL) return TEST_ABORTED;
934 
935  /* Set standard desired spec */
936  desired.freq=22050;
937  desired.format=AUDIO_S16SYS;
938  desired.channels=2;
939  desired.samples=4096;
941  desired.userdata=NULL;
942 
943  /* Open device */
944  id = SDL_OpenAudioDevice((const char *)device, 0, &desired, &obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
945  SDLTest_AssertPass("SDL_OpenAudioDevice('%s',...)", device);
946  SDLTest_AssertCheck(id > 1, "Validate device ID; expected: >1, got: %i", id);
947  if (id > 1) {
948 
949 /* TODO: enable test code when function is available in SDL2 */
950 
951 #ifdef AUDIODEVICECONNECTED_DEFINED
952  /* Get connected status */
953  result = SDL_AudioDeviceConnected(id);
954  SDLTest_AssertPass("Call to SDL_AudioDeviceConnected()");
955 #endif
956  SDLTest_AssertCheck(result == 1, "Verify returned value; expected: 1; got: %i", result);
957 
958  /* Close device again */
960  SDLTest_AssertPass("Call to SDL_CloseAudioDevice()");
961  }
962  }
963  } else {
964  SDLTest_Log("No devices to test with");
965  }
966 
967  return TEST_COMPLETED;
968 }
#define SDL_GetNumAudioDevices
GLuint id
#define SDL_CloseAudioDevice
#define TEST_ABORTED
GLuint64EXT * result
#define SDL_OpenAudioDevice
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Uint16 samples
Definition: SDL_audio.h:183
#define AUDIO_S16SYS
Definition: SDL_audio.h:123
static SDL_AudioDeviceID device
Definition: loopwave.c:37
#define SDL_GetAudioDeviceName
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_AUDIO_ALLOW_ANY_CHANGE
Definition: SDL_audio.h:143
SDL_AudioCallback callback
Definition: SDL_audio.h:186
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
Uint32 SDL_AudioDeviceID
Definition: SDL_audio.h:329
SDL_AudioFormat format
Definition: SDL_audio.h:180
void * userdata
Definition: SDL_audio.h:187
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
void _audio_testCallback(void *userdata, Uint8 *stream, int len)

◆ audio_pauseUnpauseAudio()

int audio_pauseUnpauseAudio ( )

Pause and unpause audio.

See also
https://wiki.libsdl.org/SDL_PauseAudio

Definition at line 225 of file testautomation_audio.c.

References _audio_testCallback(), _audio_testCallbackCounter, _audio_testCallbackLength, _audioSetUp(), AUDIO_F32SYS, AUDIO_S16SYS, SDL_AudioSpec::callback, SDL_AudioSpec::channels, SDL_AudioSpec::format, SDL_AudioSpec::freq, i, j, k, NULL, SDL_AudioSpec::samples, SDL_AudioInit, SDL_AudioQuit, SDL_CloseAudio, SDL_Delay, SDL_GetAudioDriver, SDL_GetNumAudioDrivers, SDL_INIT_AUDIO, SDL_memset, SDL_OpenAudio, SDL_PauseAudio, SDL_QuitSubSystem, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), SDLTest_RandomIntegerInRange(), TEST_COMPLETED, and SDL_AudioSpec::userdata.

226 {
227  int result;
228  int i, iMax, j, k, l;
229  int totalDelay;
230  int pause_on;
231  int originalCounter;
232  const char* audioDriver;
233  SDL_AudioSpec desired;
234 
235  /* Stop SDL audio subsystem */
237  SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
238 
239  /* Loop over all available audio drivers */
240  iMax = SDL_GetNumAudioDrivers();
241  SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
242  SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
243  for (i = 0; i < iMax; i++) {
244  audioDriver = SDL_GetAudioDriver(i);
245  SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
246  SDLTest_AssertCheck(audioDriver != NULL, "Audio driver name is not NULL");
247  SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver);
248 
249  /* Change specs */
250  for (j = 0; j < 2; j++) {
251 
252  /* Call Init */
253  result = SDL_AudioInit(audioDriver);
254  SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
255  SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
256 
257  /* Set spec */
258  SDL_memset(&desired, 0, sizeof(desired));
259  switch (j) {
260  case 0:
261  /* Set standard desired spec */
262  desired.freq = 22050;
263  desired.format = AUDIO_S16SYS;
264  desired.channels = 2;
265  desired.samples = 4096;
266  desired.callback = _audio_testCallback;
267  desired.userdata = NULL;
268 
269  case 1:
270  /* Set custom desired spec */
271  desired.freq = 48000;
272  desired.format = AUDIO_F32SYS;
273  desired.channels = 2;
274  desired.samples = 2048;
275  desired.callback = _audio_testCallback;
276  desired.userdata = NULL;
277  break;
278  }
279 
280  /* Call Open */
281  result = SDL_OpenAudio(&desired, NULL);
282  SDLTest_AssertPass("Call to SDL_OpenAudio(desired_spec_%d, NULL)", j);
283  SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0 got: %d", result);
284 
285  /* Start and stop audio multiple times */
286  for (l=0; l<3; l++) {
287  SDLTest_Log("Pause/Unpause iteration: %d", l+1);
288 
289  /* Reset callback counters */
292 
293  /* Un-pause audio to start playing (maybe multiple times) */
294  pause_on = 0;
295  for (k=0; k <= j; k++) {
296  SDL_PauseAudio(pause_on);
297  SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1);
298  }
299 
300  /* Wait for callback */
301  totalDelay = 0;
302  do {
303  SDL_Delay(10);
304  totalDelay += 10;
305  }
306  while (_audio_testCallbackCounter == 0 && totalDelay < 1000);
307  SDLTest_AssertCheck(_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", _audio_testCallbackCounter);
308  SDLTest_AssertCheck(_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", _audio_testCallbackLength);
309 
310  /* Pause audio to stop playing (maybe multiple times) */
311  for (k=0; k <= j; k++) {
312  pause_on = (k==0) ? 1 : SDLTest_RandomIntegerInRange(99, 9999);
313  SDL_PauseAudio(pause_on);
314  SDLTest_AssertPass("Call to SDL_PauseAudio(%d), call %d", pause_on, k+1);
315  }
316 
317  /* Ensure callback is not called again */
318  originalCounter = _audio_testCallbackCounter;
319  SDL_Delay(totalDelay + 10);
320  SDLTest_AssertCheck(originalCounter == _audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, _audio_testCallbackCounter);
321  }
322 
323  /* Call Close */
324  SDL_CloseAudio();
325  SDLTest_AssertPass("Call to SDL_CloseAudio()");
326 
327  /* Call Quit */
328  SDL_AudioQuit();
329  SDLTest_AssertPass("Call to SDL_AudioQuit()");
330 
331  } /* spec loop */
332  } /* driver loop */
333 
334  /* Restart audio again */
335  _audioSetUp(NULL);
336 
337  return TEST_COMPLETED;
338 }
#define SDL_GetNumAudioDrivers
#define SDL_OpenAudio
GLuint64EXT * result
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
#define SDL_AudioInit
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
#define SDL_QuitSubSystem
Uint16 samples
Definition: SDL_audio.h:183
#define AUDIO_S16SYS
Definition: SDL_audio.h:123
#define SDL_AudioQuit
#define SDL_PauseAudio
#define AUDIO_F32SYS
Definition: SDL_audio.h:125
Uint8 channels
Definition: SDL_audio.h:181
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
int _audio_testCallbackLength
#define SDL_GetAudioDriver
SDL_AudioCallback callback
Definition: SDL_audio.h:186
#define TEST_COMPLETED
#define SDL_Delay
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
#define SDL_INIT_AUDIO
Definition: SDL.h:77
SDL_AudioFormat format
Definition: SDL_audio.h:180
#define SDL_CloseAudio
void * userdata
Definition: SDL_audio.h:187
int _audio_testCallbackCounter
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:85
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
Definition: SDL_x11sym.h:213
void _audio_testCallback(void *userdata, Uint8 *stream, int len)
void _audioSetUp(void *arg)
#define SDL_memset

◆ audio_printAudioDrivers()

int audio_printAudioDrivers ( )

Checks available audio driver names.

See also
https://wiki.libsdl.org/SDL_GetNumAudioDrivers
https://wiki.libsdl.org/SDL_GetAudioDriver

Definition at line 451 of file testautomation_audio.c.

References i, NULL, SDL_GetAudioDriver, SDL_GetNumAudioDrivers, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

452 {
453  int i, n;
454  const char *name;
455 
456  /* Get number of drivers */
458  SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
459  SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n);
460 
461  /* List drivers. */
462  if (n>0)
463  {
464  for (i=0; i<n; i++) {
465  name = SDL_GetAudioDriver(i);
466  SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i);
467  SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
468  if (name != NULL) {
469  SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
470  }
471  }
472  }
473 
474  return TEST_COMPLETED;
475 }
#define SDL_GetNumAudioDrivers
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLuint const GLchar * name
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define SDL_GetAudioDriver
#define TEST_COMPLETED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
GLdouble n

◆ audio_printCurrentAudioDriver()

int audio_printCurrentAudioDriver ( )

Checks current audio driver name with initialized audio.

See also
https://wiki.libsdl.org/SDL_GetCurrentAudioDriver

Definition at line 483 of file testautomation_audio.c.

References NULL, SDL_GetCurrentAudioDriver, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

484 {
485  /* Check current audio driver */
486  const char *name = SDL_GetCurrentAudioDriver();
487  SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()");
488  SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
489  if (name != NULL) {
490  SDLTest_AssertCheck(name[0] != '\0', "Verify returned name is not empty, got: '%s'", name);
491  }
492 
493  return TEST_COMPLETED;
494 }
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
GLuint const GLchar * name
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
#define TEST_COMPLETED
#define SDL_GetCurrentAudioDriver
#define NULL
Definition: begin_code.h:164

◆ audio_quitInitAudioSubSystem()

int audio_quitInitAudioSubSystem ( )

Stop and restart audio subsystem.

See also
https://wiki.libsdl.org/SDL_QuitSubSystem
https://wiki.libsdl.org/SDL_InitSubSystem

Definition at line 65 of file testautomation_audio.c.

References _audioSetUp(), NULL, SDL_INIT_AUDIO, SDL_QuitSubSystem, SDLTest_AssertPass(), and TEST_COMPLETED.

66 {
67  /* Stop SDL audio subsystem */
69  SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
70 
71  /* Restart audio again */
73 
74  return TEST_COMPLETED;
75 }
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
#define SDL_QuitSubSystem
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_INIT_AUDIO
Definition: SDL.h:77
void _audioSetUp(void *arg)

Variable Documentation

◆ _audio_testCallbackCounter

int _audio_testCallbackCounter

Definition at line 42 of file testautomation_audio.c.

Referenced by _audio_testCallback(), and audio_pauseUnpauseAudio().

◆ _audio_testCallbackLength

int _audio_testCallbackLength

Definition at line 45 of file testautomation_audio.c.

Referenced by _audio_testCallback(), and audio_pauseUnpauseAudio().

◆ _audioChannels

Uint8 _audioChannels[] = { 1, 2, 4, 6 }

Definition at line 505 of file testautomation_audio.c.

Referenced by audio_buildAudioCVT(), and audio_convertAudio().

◆ _audioFormats

SDL_AudioFormat _audioFormats[]
Initial value:
#define AUDIO_S32MSB
Definition: SDL_audio.h:104
#define AUDIO_U16LSB
Definition: SDL_audio.h:91
#define AUDIO_S16SYS
Definition: SDL_audio.h:123
#define AUDIO_F32MSB
Definition: SDL_audio.h:113
#define AUDIO_U8
Definition: SDL_audio.h:89
#define AUDIO_F32SYS
Definition: SDL_audio.h:125
#define AUDIO_F32LSB
Definition: SDL_audio.h:112
#define AUDIO_S32
Definition: SDL_audio.h:105
#define AUDIO_S32LSB
Definition: SDL_audio.h:103
#define AUDIO_S16MSB
Definition: SDL_audio.h:94
#define AUDIO_S16
Definition: SDL_audio.h:96
#define AUDIO_S16LSB
Definition: SDL_audio.h:92
#define AUDIO_S32SYS
Definition: SDL_audio.h:124
#define AUDIO_F32
Definition: SDL_audio.h:114
#define AUDIO_U16
Definition: SDL_audio.h:95
#define AUDIO_S8
Definition: SDL_audio.h:90
#define AUDIO_U16SYS
Definition: SDL_audio.h:122
#define AUDIO_U16MSB
Definition: SDL_audio.h:93

Definition at line 498 of file testautomation_audio.c.

Referenced by audio_buildAudioCVT(), and audio_convertAudio().

◆ _audioFormatsVerbose

char* _audioFormatsVerbose[]
Initial value:
= { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB",
"AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32",
"AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" }

Definition at line 501 of file testautomation_audio.c.

Referenced by audio_buildAudioCVT(), and audio_convertAudio().

◆ _audioFrequencies

int _audioFrequencies[] = { 11025, 22050, 44100, 48000 }

Definition at line 507 of file testautomation_audio.c.

Referenced by audio_buildAudioCVT(), and audio_convertAudio().

◆ _numAudioChannels

const int _numAudioChannels = 4

Definition at line 504 of file testautomation_audio.c.

Referenced by audio_buildAudioCVT(), and audio_convertAudio().

◆ _numAudioFormats

const int _numAudioFormats = 18

Definition at line 497 of file testautomation_audio.c.

Referenced by audio_buildAudioCVT(), and audio_convertAudio().

◆ _numAudioFrequencies

const int _numAudioFrequencies = 4

Definition at line 506 of file testautomation_audio.c.

Referenced by audio_buildAudioCVT(), and audio_convertAudio().

◆ audioTest1

const SDLTest_TestCaseReference audioTest1
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED }
int audio_enumerateAndNameAudioDevices()
Enumerate and name available audio devices (output and capture).
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 975 of file testautomation_audio.c.

◆ audioTest10

const SDLTest_TestCaseReference audioTest10
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_convertAudio, "audio_convertAudio", "Convert audio using available formats.", TEST_DISABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_DISABLED
int audio_convertAudio()
Convert audio using various conversion structures.

Definition at line 1005 of file testautomation_audio.c.

◆ audioTest11

const SDLTest_TestCaseReference audioTest11
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_openCloseAudioDeviceConnected, "audio_openCloseAudioDeviceConnected", "Opens and closes audio device and get connected status.", TEST_DISABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_DISABLED
int audio_openCloseAudioDeviceConnected()
Opens, checks current connected status, and closes a device.

Definition at line 1010 of file testautomation_audio.c.

◆ audioTest12

const SDLTest_TestCaseReference audioTest12
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_quitInitAudioSubSystem, "audio_quitInitAudioSubSystem", "Quit and re-init audio subsystem.", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
int audio_quitInitAudioSubSystem()
Stop and restart audio subsystem.
#define TEST_ENABLED

Definition at line 1013 of file testautomation_audio.c.

◆ audioTest13

const SDLTest_TestCaseReference audioTest13
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_initQuitAudio, "audio_initQuitAudio", "Init and quit audio drivers directly.", TEST_ENABLED }
int audio_initQuitAudio()
Start and stop audio directly.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 1016 of file testautomation_audio.c.

◆ audioTest14

const SDLTest_TestCaseReference audioTest14
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_initOpenCloseQuitAudio, "audio_initOpenCloseQuitAudio", "Cycle through init, open, close and quit with various audio specs.", TEST_ENABLED }
int audio_initOpenCloseQuitAudio()
Start, open, close and stop audio.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 1019 of file testautomation_audio.c.

◆ audioTest15

const SDLTest_TestCaseReference audioTest15
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_pauseUnpauseAudio, "audio_pauseUnpauseAudio", "Pause and Unpause audio for various audio specs while testing callback.", TEST_ENABLED }
int audio_pauseUnpauseAudio()
Pause and unpause audio.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 1022 of file testautomation_audio.c.

◆ audioTest2

const SDLTest_TestCaseReference audioTest2
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int audio_enumerateAndNameAudioDevicesNegativeTests()
Negative tests around enumeration and naming of audio devices.

Definition at line 978 of file testautomation_audio.c.

◆ audioTest3

const SDLTest_TestCaseReference audioTest3
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int audio_printAudioDrivers()
Checks available audio driver names.

Definition at line 981 of file testautomation_audio.c.

◆ audioTest4

const SDLTest_TestCaseReference audioTest4
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int audio_printCurrentAudioDriver()
Checks current audio driver name with initialized audio.

Definition at line 984 of file testautomation_audio.c.

◆ audioTest5

const SDLTest_TestCaseReference audioTest5
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_buildAudioCVT, "audio_buildAudioCVT", "Builds various audio conversion structures.", TEST_ENABLED }
int audio_buildAudioCVT()
Builds various audio conversion structures.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 987 of file testautomation_audio.c.

◆ audioTest6

const SDLTest_TestCaseReference audioTest6
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_buildAudioCVTNegative, "audio_buildAudioCVTNegative", "Checks calls with invalid input to SDL_BuildAudioCVT", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
int audio_buildAudioCVTNegative()
Checkes calls with invalid input to SDL_BuildAudioCVT.
#define TEST_ENABLED

Definition at line 990 of file testautomation_audio.c.

◆ audioTest7

const SDLTest_TestCaseReference audioTest7
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_getAudioStatus, "audio_getAudioStatus", "Checks current audio status.", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
int audio_getAudioStatus()
Checks current audio status.
#define TEST_ENABLED

Definition at line 993 of file testautomation_audio.c.

◆ audioTest8

const SDLTest_TestCaseReference audioTest8
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_openCloseAndGetAudioStatus, "audio_openCloseAndGetAudioStatus", "Opens and closes audio device and get audio status.", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
int audio_openCloseAndGetAudioStatus()
Opens, checks current audio status, and closes a device.
#define TEST_ENABLED

Definition at line 996 of file testautomation_audio.c.

◆ audioTest9

const SDLTest_TestCaseReference audioTest9
static
Initial value:
=
{ (SDLTest_TestCaseFp)audio_lockUnlockOpenAudioDevice, "audio_lockUnlockOpenAudioDevice", "Locks and unlocks an open audio device.", TEST_ENABLED }
int audio_lockUnlockOpenAudioDevice()
Locks and unlocks open audio device.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 999 of file testautomation_audio.c.

◆ audioTests

const SDLTest_TestCaseReference* audioTests[]
static
Initial value:
= {
}
static const SDLTest_TestCaseReference audioTest12
static const SDLTest_TestCaseReference audioTest14
static const SDLTest_TestCaseReference audioTest5
static const SDLTest_TestCaseReference audioTest9
static const SDLTest_TestCaseReference audioTest8
static const SDLTest_TestCaseReference audioTest4
static const SDLTest_TestCaseReference audioTest2
static const SDLTest_TestCaseReference audioTest1
static const SDLTest_TestCaseReference audioTest15
#define NULL
Definition: begin_code.h:164
static const SDLTest_TestCaseReference audioTest6
static const SDLTest_TestCaseReference audioTest13
static const SDLTest_TestCaseReference audioTest11
static const SDLTest_TestCaseReference audioTest10
static const SDLTest_TestCaseReference audioTest7
static const SDLTest_TestCaseReference audioTest3

Definition at line 1026 of file testautomation_audio.c.

◆ audioTestSuite

Initial value:
= {
"Audio",
}
static const SDLTest_TestCaseReference * audioTests[]
void _audioTearDown(void *arg)
void _audioSetUp(void *arg)

Reference to all test suites.

Definition at line 1033 of file testautomation_audio.c.