deps: SDL update to 2.30.0 (#3384)

In the hopes that some things have been fixed in the last year
(GAME_CONTROLLER init time, etc)

Make sure this does not regress #2691
This commit is contained in:
Tyler Wilding
2024-03-05 22:12:13 -05:00
committed by GitHub
parent 60db0e5ef9
commit ecd6091d7f
1295 changed files with 87263 additions and 281799 deletions
+23 -29
View File
@@ -1,5 +1,5 @@
/*
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -21,7 +21,7 @@
#include "SDL.h"
#if HAVE_SIGNAL_H
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
@@ -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,37 +43,33 @@ 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)) {
emscripten_cancel_main_loop();
}
else
} else
#endif
{
/* 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;
@@ -84,12 +79,12 @@ main(int argc, char *argv[])
/* 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());
return (1);
return 1;
}
filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
if (filename == NULL) {
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
quit(1);
}
@@ -100,18 +95,18 @@ 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
#ifdef HAVE_SIGNAL_H
/* Set the signals */
#ifdef SIGHUP
signal(SIGHUP, poked);
(void)signal(SIGHUP, poked);
#endif
signal(SIGINT, poked);
(void)signal(SIGINT, poked);
#ifdef SIGQUIT
signal(SIGQUIT, poked);
(void)signal(SIGQUIT, poked);
#endif
signal(SIGTERM, poked);
(void)signal(SIGTERM, poked);
#endif /* HAVE_SIGNAL_H */
/* Initialize fillerup() variables */
@@ -131,15 +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))
{
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