Fixed tabs to spaces

This commit is contained in:
Sam Lantinga 2017-03-09 15:12:19 -08:00
parent aae481294d
commit 6bdc0e724d
1 changed files with 33 additions and 33 deletions

View File

@ -51,32 +51,32 @@ quit(int rc)
static void static void
close_audio() close_audio()
{ {
if (device != 0) { if (device != 0) {
SDL_CloseAudioDevice(device); SDL_CloseAudioDevice(device);
device = 0; device = 0;
} }
} }
static void static void
open_audio() open_audio()
{ {
/* Initialize fillerup() variables */ /* Initialize fillerup() variables */
device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0); device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0);
if (!device) { if (!device) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
SDL_FreeWAV(wave.sound); SDL_FreeWAV(wave.sound);
quit(2); quit(2);
} }
/* Let the audio run */ /* Let the audio run */
SDL_PauseAudioDevice(device, SDL_FALSE); SDL_PauseAudioDevice(device, SDL_FALSE);
} }
static void reopen_audio() static void reopen_audio()
{ {
close_audio(); close_audio();
open_audio(); open_audio();
} }
@ -151,35 +151,35 @@ main(int argc, char *argv[])
SDL_Log("Available audio drivers:"); SDL_Log("Available audio drivers:");
for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
SDL_Log("%i: %s", i, SDL_GetAudioDriver(i)); SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
} }
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
open_audio(); open_audio();
SDL_FlushEvents(SDL_AUDIODEVICEADDED, SDL_AUDIODEVICEREMOVED); SDL_FlushEvents(SDL_AUDIODEVICEADDED, SDL_AUDIODEVICEREMOVED);
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1); emscripten_set_main_loop(loop, 0, 1);
#else #else
while (!done) { while (!done) {
SDL_Event event; SDL_Event event;
while (SDL_PollEvent(&event) > 0) { while (SDL_PollEvent(&event) > 0) {
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
done = 1; done = 1;
} }
if ((event.type == SDL_AUDIODEVICEADDED && !event.adevice.iscapture) || if ((event.type == SDL_AUDIODEVICEADDED && !event.adevice.iscapture) ||
(event.type == SDL_AUDIODEVICEREMOVED && !event.adevice.iscapture && event.adevice.which == device)) { (event.type == SDL_AUDIODEVICEREMOVED && !event.adevice.iscapture && event.adevice.which == device)) {
reopen_audio(); reopen_audio();
} }
} }
SDL_Delay(100); SDL_Delay(100);
} }
#endif #endif
/* Clean up on signal */ /* Clean up on signal */
close_audio(); close_audio();
SDL_FreeWAV(wave.sound); SDL_FreeWAV(wave.sound);
SDL_Quit(); SDL_Quit();
return (0); return (0);