mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-09 03:16:26 +00:00
threads: Move SDL's own thread creation to a new internal API.
This allows us to set an explicit stack size (overriding the system default and the global hint an app might have set), and remove all the macro salsa for dealing with _beginthreadex and such, as internal threads always set those to NULL anyhow. I've taken some guesses on reasonable (and tiny!) stack sizes for our internal threads, but some of these might turn out to be too small in practice and need an increase. Most of them are simple functions, though.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "SDL_audio_c.h"
|
||||
#include "SDL_audiomem.h"
|
||||
#include "SDL_sysaudio.h"
|
||||
#include "../thread/SDL_systhread.h"
|
||||
|
||||
#define _THIS SDL_AudioDevice *_this
|
||||
|
||||
@@ -1191,19 +1192,15 @@ open_audio_device(const char *devname, int iscapture,
|
||||
/* Start the audio thread if necessary */
|
||||
if (!current_audio.impl.ProvidesOwnCallbackThread) {
|
||||
/* Start the audio thread */
|
||||
|
||||
/* !!! FIXME: we don't force the audio thread stack size here because it calls into user code, but maybe we should? */
|
||||
/* buffer queueing callback only needs a few bytes, so make the stack tiny. */
|
||||
char name[64];
|
||||
const size_t stacksize = (device->spec.callback == SDL_BufferQueueDrainCallback) ? 64 * 1024 : 0;
|
||||
|
||||
SDL_snprintf(name, sizeof (name), "SDLAudioDev%d", (int) device->id);
|
||||
/* !!! FIXME: this is nasty. */
|
||||
#if defined(__WIN32__) && !defined(HAVE_LIBC)
|
||||
#undef SDL_CreateThread
|
||||
#if SDL_DYNAMIC_API
|
||||
device->thread = SDL_CreateThread_REAL(SDL_RunAudio, name, device, NULL, NULL);
|
||||
#else
|
||||
device->thread = SDL_CreateThread(SDL_RunAudio, name, device, NULL, NULL);
|
||||
#endif
|
||||
#else
|
||||
device->thread = SDL_CreateThread(SDL_RunAudio, name, device);
|
||||
#endif
|
||||
device->thread = SDL_CreateThreadInternal(SDL_RunAudio, name, stacksize, device);
|
||||
|
||||
if (device->thread == NULL) {
|
||||
SDL_CloseAudioDevice(device->id);
|
||||
SDL_SetError("Couldn't create audio thread");
|
||||
|
Reference in New Issue
Block a user