testprograms: parse arguments using SDLTest_CommonState
This commit is contained in:
committed by
Anonymous Maarten
parent
8bea41f737
commit
4a6528e3f0
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
static void
|
||||
print_devices(int iscapture)
|
||||
@@ -49,11 +50,24 @@ int main(int argc, char **argv)
|
||||
{
|
||||
char *deviceName = NULL;
|
||||
SDL_AudioSpec spec;
|
||||
int i;
|
||||
int n;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
@@ -65,7 +79,6 @@ int main(int argc, char **argv)
|
||||
if (n == 0) {
|
||||
SDL_Log("No built-in audio drivers\n\n");
|
||||
} else {
|
||||
int i;
|
||||
SDL_Log("Built-in audio drivers:\n");
|
||||
for (i = 0; i < n; ++i) {
|
||||
SDL_Log(" %d: %s\n", i, SDL_GetAudioDriver(i));
|
||||
@@ -99,5 +112,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user