Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594

(cherry picked from commit 5750bcb174)
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
parent 5c4bc807f7
commit b8d85c6939
764 changed files with 50598 additions and 54407 deletions

View File

@@ -30,11 +30,10 @@
static struct
{
SDL_AudioSpec spec;
Uint8 *sound; /* Pointer to wave data */
Uint32 soundlen; /* Length of wave data */
Uint8 *sound; /* Pointer to wave data */
Uint32 soundlen; /* Length of wave data */
} wave;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
quit(int rc)
@@ -44,14 +43,12 @@ quit(int rc)
}
static int done = 0;
void
poked(int sig)
void poked(int sig)
{
done = 1;
}
void
loop()
void loop()
{
#ifdef __EMSCRIPTEN__
if (done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)) {
@@ -61,19 +58,18 @@ loop()
{
/* The device from SDL_OpenAudio() is always device #1. */
const Uint32 queued = SDL_GetQueuedAudioSize(1);
SDL_Log("Device has %u bytes queued.\n", (unsigned int) queued);
if (queued <= 8192) { /* time to requeue the whole thing? */
SDL_Log("Device has %u bytes queued.\n", (unsigned int)queued);
if (queued <= 8192) { /* time to requeue the whole thing? */
if (SDL_QueueAudio(1, wave.sound, wave.soundlen) == 0) {
SDL_Log("Device queued %u more bytes.\n", (unsigned int) wave.soundlen);
SDL_Log("Device queued %u more bytes.\n", (unsigned int)wave.soundlen);
} else {
SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int) wave.soundlen, SDL_GetError());
SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int)wave.soundlen, SDL_GetError());
}
}
}
}
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
char *filename = NULL;
@@ -99,7 +95,7 @@ main(int argc, char *argv[])
quit(1);
}
wave.spec.callback = NULL; /* we'll push audio. */
wave.spec.callback = NULL; /* we'll push audio. */
#if HAVE_SIGNAL_H
/* Set the signals */
@@ -130,14 +126,14 @@ main(int argc, char *argv[])
/* Note that we stuff the entire audio buffer into the queue in one
shot. Most apps would want to feed it a little at a time, as it
plays, but we're going for simplicity here. */
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) {
loop();
SDL_Delay(100); /* let it play for awhile. */
SDL_Delay(100); /* let it play for awhile. */
}
#endif