MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / main

Function main

deps/SDL2/test/loopwave.c:113–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111#endif
112
113int
114main(int argc, char *argv[])
115{
116 int i;
117 char filename[4096];
118
119 /* Enable standard application logging */
120 SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
121
122 /* Load the SDL library */
123 if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_EVENTS) < 0) {
124 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
125 return (1);
126 }
127
128 if (argc > 1) {
129 SDL_strlcpy(filename, argv[1], sizeof(filename));
130 } else {
131 SDL_strlcpy(filename, "sample.wav", sizeof(filename));
132 }
133 /* Load the wave file into memory */
134 if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
135 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
136 quit(1);
137 }
138
139 wave.spec.callback = fillerup;
140
141 /* Show the list of available drivers */
142 SDL_Log("Available audio drivers:");
143 for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
144 SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
145 }
146
147 SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
148
149 open_audio();
150
151 SDL_FlushEvents(SDL_AUDIODEVICEADDED, SDL_AUDIODEVICEREMOVED);
152
153#ifdef __EMSCRIPTEN__
154 emscripten_set_main_loop(loop, 0, 1);
155#else
156 while (!done) {
157 SDL_Event event;
158
159 while (SDL_PollEvent(&event) > 0) {
160 if (event.type == SDL_QUIT) {
161 done = 1;
162 }
163 if ((event.type == SDL_AUDIODEVICEADDED && !event.adevice.iscapture) ||
164 (event.type == SDL_AUDIODEVICEREMOVED && !event.adevice.iscapture && event.adevice.which == device)) {
165 reopen_audio();
166 }
167 }
168 SDL_Delay(100);
169 }
170#endif

Callers

nothing calls this directly

Calls 15

SDL_LogSetPriorityFunction · 0.85
SDL_InitFunction · 0.85
SDL_LogErrorFunction · 0.85
SDL_GetErrorFunction · 0.85
SDL_strlcpyFunction · 0.85
SDL_LogFunction · 0.85
SDL_GetNumAudioDriversFunction · 0.85
SDL_GetAudioDriverFunction · 0.85
open_audioFunction · 0.85
SDL_FlushEventsFunction · 0.85
SDL_PollEventFunction · 0.85

Tested by

no test coverage detected