mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-20 15:13:45 +00:00
Updates the SDL library to the latest standard bugfix release
This commit is contained in:
parent
cb766f2878
commit
083d2175ea
1280 changed files with 343926 additions and 179615 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 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
|
||||
|
|
@ -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,7 +79,7 @@ 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");
|
||||
|
|
@ -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
|
||||
/* 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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue