Skip to content
Permalink
Browse files

Fixed tabs to spaces

  • Loading branch information
slouken committed Mar 9, 2017
1 parent aae4812 commit 6bdc0e724d0bb65aff204b50baada37c9915d1cd
Showing with 34 additions and 34 deletions.
  1. +34 −34 test/loopwave.c
@@ -51,32 +51,32 @@ quit(int rc)
static void
close_audio()
{
if (device != 0) {
SDL_CloseAudioDevice(device);
device = 0;
}
if (device != 0) {
SDL_CloseAudioDevice(device);
device = 0;
}
}

static void
open_audio()
{
/* Initialize fillerup() variables */
device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0);
if (!device) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
SDL_FreeWAV(wave.sound);
quit(2);
}
/* Initialize fillerup() variables */
device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0);
if (!device) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
SDL_FreeWAV(wave.sound);
quit(2);
}


/* Let the audio run */
SDL_PauseAudioDevice(device, SDL_FALSE);
/* Let the audio run */
SDL_PauseAudioDevice(device, SDL_FALSE);
}

static void reopen_audio()
{
close_audio();
open_audio();
close_audio();
open_audio();
}


@@ -151,35 +151,35 @@ main(int argc, char *argv[])
SDL_Log("Available audio drivers:");
for (i = 0; i < SDL_GetNumAudioDrivers(); ++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__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done) {
SDL_Event event;

while (SDL_PollEvent(&event) > 0) {
if (event.type == SDL_QUIT) {
done = 1;
}
if ((event.type == SDL_AUDIODEVICEADDED && !event.adevice.iscapture) ||
(event.type == SDL_AUDIODEVICEREMOVED && !event.adevice.iscapture && event.adevice.which == device)) {
reopen_audio();
}
}
SDL_Delay(100);
}
while (!done) {
SDL_Event event;

while (SDL_PollEvent(&event) > 0) {
if (event.type == SDL_QUIT) {
done = 1;
}
if ((event.type == SDL_AUDIODEVICEADDED && !event.adevice.iscapture) ||
(event.type == SDL_AUDIODEVICEREMOVED && !event.adevice.iscapture && event.adevice.which == device)) {
reopen_audio();
}
}
SDL_Delay(100);
}
#endif

/* Clean up on signal */
close_audio();
close_audio();
SDL_FreeWAV(wave.sound);
SDL_Quit();
return (0);

0 comments on commit 6bdc0e7

Please sign in to comment.