From 75dacdb99b3846d6087121cc03cefe7e04cd2495 Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Fri, 18 Jul 2014 14:10:45 -0700 Subject: [PATCH 01/17] Dont redeclare DBusMessage* msg; --- src/core/linux/SDL_ibus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index a91d31b838732..9583b098c70f0 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -331,10 +331,10 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) } if(result){ - DBusMessage *msg = dbus->message_new_method_call(IBUS_SERVICE, - input_ctx_path, - IBUS_INPUT_INTERFACE, - "SetCapabilities"); + msg = dbus->message_new_method_call(IBUS_SERVICE, + input_ctx_path, + IBUS_INPUT_INTERFACE, + "SetCapabilities"); if(msg){ Uint32 caps = IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT; dbus->message_append_args(msg, From 987c3355518a5a7da4f28edc009d6c33c2a703ac Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 22 Jul 2014 23:12:21 -0400 Subject: [PATCH 02/17] Clarifying hard-to-understand piece of code. --- src/audio/SDL_audio.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index af8247c294689..8791d29ec7f4b 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -205,22 +205,34 @@ SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture) return -1; } +static SDL_INLINE SDL_bool +is_in_audio_device_thread(SDL_AudioDevice * device) +{ + /* The device thread locks the same mutex, but not through the public API. + This check is in case the application, in the audio callback, + tries to lock the thread that we've already locked from the + device thread...just in case we only have non-recursive mutexes. */ + if (device->thread && (SDL_ThreadID() == device->threadid)) { + return SDL_TRUE; + } + + return SDL_FALSE; +} + static void SDL_AudioLockDevice_Default(SDL_AudioDevice * device) { - if (device->thread && (SDL_ThreadID() == device->threadid)) { - return; + if (!is_in_audio_device_thread(device)) { + SDL_LockMutex(device->mixer_lock); } - SDL_LockMutex(device->mixer_lock); } static void SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device) { - if (device->thread && (SDL_ThreadID() == device->threadid)) { - return; + if (!is_in_audio_device_thread(device)) { + SDL_UnlockMutex(device->mixer_lock); } - SDL_UnlockMutex(device->mixer_lock); } From dfc7535ff7e4e975c41619e64ee3f75a80fe308d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 26 Jul 2014 16:52:26 -0700 Subject: [PATCH 03/17] Fixed bug 2657 - Memory leak in GL_CreateTexture function Nitz In GL_CreateTexture function: if (GL_CheckError("glGenTexures()", renderer) < 0) { SDL_free(data); return -1; } Here only data is getting free but data->pixels getting leak. So have to free data->pixels before free data. --- src/render/opengl/SDL_render_gl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index a23d4f03bb143..e1c78cb8ba179 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -688,6 +688,9 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_CheckError("", renderer); renderdata->glGenTextures(1, &data->texture); if (GL_CheckError("glGenTexures()", renderer) < 0) { + if (data->pixels) { + SDL_free(data->pixels); + } SDL_free(data); return -1; } From f30e120aa9e89e2a3f56e462f0f4d230469739c2 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 22 Jul 2014 21:41:49 -0400 Subject: [PATCH 04/17] Added audio device buffer queueing API. --- .hgignore | 1 + include/SDL_audio.h | 107 ++++++++++++++- src/audio/SDL_audio.c | 209 ++++++++++++++++++++++++++++-- src/audio/SDL_sysaudio.h | 26 ++++ src/dynapi/SDL_dynapi_overrides.h | 3 + src/dynapi/SDL_dynapi_procs.h | 3 + test/Makefile.in | 4 + test/README | 1 + test/loopwavequeue.c | 127 ++++++++++++++++++ 9 files changed, 469 insertions(+), 12 deletions(-) create mode 100644 test/loopwavequeue.c diff --git a/.hgignore b/.hgignore index e61b7d96a4acf..c16de75952517 100644 --- a/.hgignore +++ b/.hgignore @@ -73,6 +73,7 @@ test/Makefile test/SDL2.dll test/checkkeys test/loopwave +test/loopwavequeue test/testatomic test/testaudioinfo test/testautomation diff --git a/include/SDL_audio.h b/include/SDL_audio.h index 4c987d5110435..5c04b0bf476ee 100644 --- a/include/SDL_audio.h +++ b/include/SDL_audio.h @@ -155,6 +155,9 @@ typedef Uint16 SDL_AudioFormat; * * Once the callback returns, the buffer will no longer be valid. * Stereo samples are stored in a LRLRLR ordering. + * + * You can choose to avoid callbacks and use SDL_QueueAudio() instead, if + * you like. Just open your audio device with a NULL callback. */ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, int len); @@ -171,8 +174,8 @@ typedef struct SDL_AudioSpec Uint16 samples; /**< Audio buffer size in samples (power of 2) */ Uint16 padding; /**< Necessary for some compile environments */ Uint32 size; /**< Audio buffer size in bytes (calculated) */ - SDL_AudioCallback callback; - void *userdata; + SDL_AudioCallback callback; /**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). */ + void *userdata; /**< Userdata passed to callback (ignored for NULL callbacks). */ } SDL_AudioSpec; @@ -273,9 +276,11 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); * to the audio buffer, and the length in bytes of the audio buffer. * This function usually runs in a separate thread, and so you should * protect data structures that it accesses by calling SDL_LockAudio() - * and SDL_UnlockAudio() in your code. + * and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL + * pointer here, and call SDL_QueueAudio() with some frequency, to queue + * more audio samples to be played. * - \c desired->userdata is passed as the first parameter to your callback - * function. + * function. If you passed a NULL callback, this value is ignored. * * The audio device starts out playing silence when it's opened, and should * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready @@ -474,6 +479,100 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, SDL_AudioFormat format, Uint32 len, int volume); +/** + * Queue more audio on non-callback devices. + * + * SDL offers two ways to feed audio to the device: you can either supply a + * callback that SDL triggers with some frequency to obtain more audio + * (pull method), or you can supply no callback, and then SDL will expect + * you to supply data at regular intervals (push method) with this function. + * + * There are no limits on the amount of data you can queue, short of + * exhaustion of address space. Queued data will drain to the device as + * necessary without further intervention from you. If the device needs + * audio but there is not enough queued, it will play silence to make up + * the difference. This means you will have skips in your audio playback + * if you aren't routinely queueing sufficient data. + * + * This function copies the supplied data, so you are safe to free it when + * the function returns. This function is thread-safe, but queueing to the + * same device from two threads at once does not promise which buffer will + * be queued first. + * + * You may not queue audio on a device that is using an application-supplied + * callback; doing so returns an error. You have to use the audio callback + * or queue audio with this function, but not both. + * + * You should not call SDL_LockAudio() on the device before queueing; SDL + * handles locking internally for this function. + * + * \param dev The device ID to which we will queue audio. + * \param data The data to queue to the device for later playback. + * \param len The number of bytes (not samples!) to which (data) points. + * \return zero on success, -1 on error. + * + * \sa SDL_GetQueuedAudioSize + * \sa SDL_ClearQueuedAudio + */ +extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len); + +/** + * Get the number of bytes of still-queued audio. + * + * This is the number of bytes that have been queued for playback with + * SDL_QueueAudio(), but have not yet been sent to the hardware. + * + * Once we've sent it to the hardware, this function can not decide the exact + * byte boundary of what has been played. It's possible that we just gave the + * hardware several kilobytes right before you called this function, but it + * hasn't played any of it yet, or maybe half of it, etc. + * + * You may not queue audio on a device that is using an application-supplied + * callback; calling this function on such a device always returns 0. + * You have to use the audio callback or queue audio with SDL_QueueAudio(), + * but not both. + * + * You should not call SDL_LockAudio() on the device before querying; SDL + * handles locking internally for this function. + * + * \param dev The device ID of which we will query queued audio size. + * \return Number of bytes (not samples!) of queued audio. + * + * \sa SDL_QueueAudio + * \sa SDL_ClearQueuedAudio + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev); + +/** + * Drop any queued audio data waiting to be sent to the hardware. + * + * Immediately after this call, SDL_GetQueuedAudioSize() will return 0 and + * the hardware will start playing silence if more audio isn't queued. + * + * This will not prevent playback of queued audio that's already been sent + * to the hardware, as we can not undo that, so expect there to be some + * fraction of a second of audio that might still be heard. This can be + * useful if you want to, say, drop any pending music during a level change + * in your game. + * + * You may not queue audio on a device that is using an application-supplied + * callback; calling this function on such a device is always a no-op. + * You have to use the audio callback or queue audio with SDL_QueueAudio(), + * but not both. + * + * You should not call SDL_LockAudio() on the device before clearing the + * queue; SDL handles locking internally for this function. + * + * This function always succeeds and thus returns void. + * + * \param dev The device ID of which to clear the audio queue. + * + * \sa SDL_QueueAudio + * \sa SDL_GetQueuedAudioSize + */ +extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev); + + /** * \name Audio lock functions * diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 8791d29ec7f4b..a788c89a2de83 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -324,6 +324,181 @@ SDL_StreamDeinit(SDL_AudioStreamer * stream) } #endif + +/* buffer queueing support... */ + +/* this expects that you managed thread safety elsewhere. */ +static void +free_audio_queue(SDL_AudioBufferQueue *buffer) +{ + while (buffer) { + SDL_AudioBufferQueue *next = buffer->next; + SDL_free(buffer); + buffer = next; + } +} + +static void SDLCALL +SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int _len) +{ + /* this function always holds the mixer lock before being called. */ + Uint32 len = (Uint32) _len; + SDL_AudioDevice *device = (SDL_AudioDevice *) userdata; + SDL_AudioBufferQueue *buffer; + + SDL_assert(device != NULL); /* this shouldn't ever happen, right?! */ + SDL_assert(_len >= 0); /* this shouldn't ever happen, right?! */ + + while ((len > 0) && ((buffer = device->buffer_queue_head) != NULL)) { + const Uint32 avail = buffer->datalen - buffer->startpos; + const Uint32 cpy = SDL_min(len, avail); + SDL_assert(device->queued_bytes >= avail); + + SDL_memcpy(stream, buffer->data + buffer->startpos, cpy); + buffer->startpos += cpy; + stream += cpy; + device->queued_bytes -= cpy; + len -= cpy; + + if (buffer->startpos == buffer->datalen) { /* packet is done, put it in the pool. */ + device->buffer_queue_head = buffer->next; + SDL_assert((buffer->next != NULL) || (buffer == device->buffer_queue_tail)); + buffer->next = device->buffer_queue_pool; + device->buffer_queue_pool = buffer; + } + } + + SDL_assert((device->buffer_queue_head != NULL) == (device->queued_bytes != 0)); + + if (len > 0) { /* fill any remaining space in the stream with silence. */ + SDL_assert(device->buffer_queue_head == NULL); + SDL_memset(stream, device->spec.silence, len); + } + + if (device->buffer_queue_head == NULL) { + device->buffer_queue_tail = NULL; /* in case we drained the queue entirely. */ + } +} + +int +SDL_QueueAudio(SDL_AudioDeviceID devid, const void *_data, Uint32 len) +{ + SDL_AudioDevice *device = get_audio_device(devid); + const Uint8 *data = (const Uint8 *) _data; + SDL_AudioBufferQueue *orighead; + SDL_AudioBufferQueue *origtail; + Uint32 origlen; + Uint32 datalen; + + if (!device) { + return -1; /* get_audio_device() will have set the error state */ + } + + if (device->spec.callback != SDL_BufferQueueDrainCallback) { + return SDL_SetError("Audio device has a callback, queueing not allowed"); + } + + current_audio.impl.LockDevice(device); + + orighead = device->buffer_queue_head; + origtail = device->buffer_queue_tail; + origlen = origtail ? origtail->datalen : 0; + + while (len > 0) { + SDL_AudioBufferQueue *packet = device->buffer_queue_tail; + SDL_assert(!packet || (packet->datalen <= SDL_AUDIOBUFFERQUEUE_PACKETLEN)); + if (!packet || (packet->datalen >= SDL_AUDIOBUFFERQUEUE_PACKETLEN)) { + /* tail packet missing or completely full; we need a new packet. */ + packet = device->buffer_queue_pool; + if (packet != NULL) { + /* we have one available in the pool. */ + device->buffer_queue_pool = packet->next; + } else { + /* Have to allocate a new one! */ + packet = (SDL_AudioBufferQueue *) SDL_malloc(sizeof (SDL_AudioBufferQueue)); + if (packet == NULL) { + /* uhoh, reset so we've queued nothing new, free what we can. */ + if (!origtail) { + packet = device->buffer_queue_head; /* whole queue. */ + } else { + packet = origtail->next; /* what we added to existing queue. */ + origtail->next = NULL; + origtail->datalen = origlen; + } + device->buffer_queue_head = orighead; + device->buffer_queue_tail = origtail; + device->buffer_queue_pool = NULL; + + current_audio.impl.UnlockDevice(device); + + free_audio_queue(packet); /* give back what we can. */ + + return SDL_OutOfMemory(); + } + } + packet->datalen = 0; + packet->startpos = 0; + packet->next = NULL; + + SDL_assert((device->buffer_queue_head != NULL) == (device->queued_bytes != 0)); + if (device->buffer_queue_tail == NULL) { + device->buffer_queue_head = packet; + } else { + device->buffer_queue_tail->next = packet; + } + device->buffer_queue_tail = packet; + } + + datalen = SDL_min(len, SDL_AUDIOBUFFERQUEUE_PACKETLEN - packet->datalen); + SDL_memcpy(packet->data + packet->datalen, data, datalen); + data += datalen; + len -= datalen; + packet->datalen += datalen; + device->queued_bytes += datalen; + } + + current_audio.impl.UnlockDevice(device); + + return 0; +} + +Uint32 +SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid) +{ + /* this happens to work for non-queueing devices, since we memset() + the device to zero at init time, and these devices should return 0. */ + Uint32 retval = 0; + SDL_AudioDevice *device = get_audio_device(devid); + if (device) { + current_audio.impl.LockDevice(device); + retval = device->queued_bytes; + current_audio.impl.UnlockDevice(device); + } + + return retval; +} + +void +SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) +{ + SDL_AudioDevice *device = get_audio_device(devid); + SDL_AudioBufferQueue *buffer = NULL; + if (!device) { + return; /* nothing to do. */ + } + + /* Blank out the device and release the mutex. Free it afterwards. */ + current_audio.impl.LockDevice(device); + buffer = device->buffer_queue_head; + device->buffer_queue_tail = NULL; + device->buffer_queue_head = NULL; + device->queued_bytes = 0; + current_audio.impl.UnlockDevice(device); + + free_audio_queue(buffer); +} + + #if defined(__ANDROID__) #include #endif @@ -800,6 +975,10 @@ close_audio_device(SDL_AudioDevice * device) current_audio.impl.CloseDevice(device); device->opened = 0; } + + free_audio_queue(device->buffer_queue_head); + free_audio_queue(device->buffer_queue_pool); + SDL_FreeAudioMem(device); } @@ -814,11 +993,6 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) { SDL_memcpy(prepared, orig, sizeof(SDL_AudioSpec)); - if (orig->callback == NULL) { - SDL_SetError("SDL_OpenAudio() passed a NULL callback"); - return 0; - } - if (orig->freq == 0) { const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY"); if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) { @@ -871,7 +1045,6 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) return 1; } - static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, const SDL_AudioSpec * desired, SDL_AudioSpec * obtained, @@ -950,7 +1123,7 @@ open_audio_device(const char *devname, int iscapture, SDL_OutOfMemory(); return 0; } - SDL_memset(device, '\0', sizeof(SDL_AudioDevice)); + SDL_zerop(device); device->spec = *obtained; device->enabled = 1; device->paused = 1; @@ -968,8 +1141,9 @@ open_audio_device(const char *devname, int iscapture, /* force a device detection if we haven't done one yet. */ if ( ((iscapture) && (current_audio.inputDevices == NULL)) || - ((!iscapture) && (current_audio.outputDevices == NULL)) ) + ((!iscapture) && (current_audio.outputDevices == NULL)) ) { SDL_GetNumAudioDevices(iscapture); + } if (current_audio.impl.OpenDevice(device, devname, iscapture) < 0) { close_audio_device(device); @@ -1043,6 +1217,25 @@ open_audio_device(const char *devname, int iscapture, } } + if (device->spec.callback == NULL) { /* use buffer queueing? */ + /* pool a few packets to start. Enough for two callbacks. */ + const int packetlen = SDL_AUDIOBUFFERQUEUE_PACKETLEN; + const int wantbytes = ((device->convert.needed) ? device->convert.len : device->spec.size) * 2; + const int wantpackets = (wantbytes / packetlen) + ((wantbytes % packetlen) ? packetlen : 0); + for (i = 0; i < wantpackets; i++) { + SDL_AudioBufferQueue *packet = (SDL_AudioBufferQueue *) SDL_malloc(sizeof (SDL_AudioBufferQueue)); + if (packet) { /* don't care if this fails, we'll deal later. */ + packet->datalen = 0; + packet->startpos = 0; + packet->next = device->buffer_queue_pool; + device->buffer_queue_pool = packet; + } + } + + device->spec.callback = SDL_BufferQueueDrainCallback; + device->spec.userdata = device; + } + /* Find an available device ID and store the structure... */ for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) { if (open_devices[id] == NULL) { diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 9fe31c807ea24..c1810b4326647 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -33,6 +33,26 @@ typedef struct SDL_AudioDevice SDL_AudioDevice; /* Used by audio targets during DetectDevices() */ typedef void (*SDL_AddAudioDevice)(const char *name); +/* This is the size of a packet when using SDL_QueueAudio(). We allocate + these as necessary and pool them, under the assumption that we'll + eventually end up with a handful that keep recycling, meeting whatever + the app needs. We keep packing data tightly as more arrives to avoid + wasting space, and if we get a giant block of data, we'll split them + into multiple packets behind the scenes. My expectation is that most + apps will have 2-3 of these in the pool. 8k should cover most needs, but + if this is crippling for some embedded system, we can #ifdef this. + The system preallocates enough packets for 2 callbacks' worth of data. */ +#define SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024) + +/* Used by apps that queue audio instead of using the callback. */ +typedef struct SDL_AudioBufferQueue +{ + Uint8 data[SDL_AUDIOBUFFERQUEUE_PACKETLEN]; /* packet data. */ + Uint32 datalen; /* bytes currently in use in this packet. */ + Uint32 startpos; /* bytes currently consumed in this packet. */ + struct SDL_AudioBufferQueue *next; /* next item in linked list. */ +} SDL_AudioBufferQueue; + typedef struct SDL_AudioDriverImpl { void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn); @@ -119,6 +139,12 @@ struct SDL_AudioDevice SDL_Thread *thread; SDL_threadID threadid; + /* Queued buffers (if app not using callback). */ + SDL_AudioBufferQueue *buffer_queue_head; /* device fed from here. */ + SDL_AudioBufferQueue *buffer_queue_tail; /* queue fills to here. */ + SDL_AudioBufferQueue *buffer_queue_pool; /* these are unused packets. */ + Uint32 queued_bytes; /* number of bytes of audio data in the queue. */ + /* * * */ /* Data private to this driver */ struct SDL_PrivateAudioData *hidden; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 79d6e8ba3fbdd..8bcde6312d33e 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -588,3 +588,6 @@ #define SDL_SetWindowHitTest SDL_SetWindowHitTest_REAL #define SDL_GetGlobalMouseState SDL_GetGlobalMouseState_REAL #define SDL_HasAVX2 SDL_HasAVX2_REAL +#define SDL_QueueAudio SDL_QueueAudio_REAL +#define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL +#define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 0112769407737..c41cdc9f027c0 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -620,3 +620,6 @@ SDL_DYNAPI_PROC(int,SDL_CaptureMouse,(SDL_bool a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetWindowHitTest,(SDL_Window *a, SDL_HitTest b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(Uint32,SDL_GetGlobalMouseState,(int *a, int *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX2,(void),(),return) +SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c),(a,b,c),return) +SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return) +SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),) diff --git a/test/Makefile.in b/test/Makefile.in index bc988556d13ee..79edbc31afe2f 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -10,6 +10,7 @@ LIBS = @LIBS@ TARGETS = \ checkkeys$(EXE) \ loopwave$(EXE) \ + loopwavequeue$(EXE) \ testatomic$(EXE) \ testaudioinfo$(EXE) \ testautomation$(EXE) \ @@ -71,6 +72,9 @@ checkkeys$(EXE): $(srcdir)/checkkeys.c loopwave$(EXE): $(srcdir)/loopwave.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) +loopwavequeue$(EXE): $(srcdir)/loopwavequeue.c + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + testresample$(EXE): $(srcdir)/testresample.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) diff --git a/test/README b/test/README index b820a88d7a92d..6ce361674dfc8 100644 --- a/test/README +++ b/test/README @@ -3,6 +3,7 @@ These are test programs for the SDL library: checkkeys Watch the key events to check the keyboard loopwave Audio test -- loop playing a WAV file + loopwavequeue Audio test -- loop playing a WAV file with SDL_QueueAudio testaudioinfo Lists audio device capabilities testcdrom Sample audio CD control program testerror Tests multi-threaded error handling diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c new file mode 100644 index 0000000000000..a70e516dd6d6d --- /dev/null +++ b/test/loopwavequeue.c @@ -0,0 +1,127 @@ +/* + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely. +*/ + +/* Program to load a wave file and loop playing it using SDL sound queueing */ + +#include +#include + +#if HAVE_SIGNAL_H +#include +#endif + +#include "SDL.h" + +struct +{ + SDL_AudioSpec spec; + Uint8 *sound; /* Pointer to wave data */ + Uint32 soundlen; /* Length of wave data */ + int soundpos; /* Current play position */ +} wave; + + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + SDL_Quit(); + exit(rc); +} + +static int done = 0; +void +poked(int sig) +{ + done = 1; +} + +int +main(int argc, char *argv[]) +{ + int i; + char filename[4096]; + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + /* 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); + } + + if (argc > 1) { + SDL_strlcpy(filename, argv[1], sizeof(filename)); + } else { + SDL_strlcpy(filename, "sample.wav", sizeof(filename)); + } + /* Load the wave file into memory */ + if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); + quit(1); + } + + wave.spec.callback = NULL; /* we'll push audio. */ + +#if HAVE_SIGNAL_H + /* Set the signals */ +#ifdef SIGHUP + signal(SIGHUP, poked); +#endif + signal(SIGINT, poked); +#ifdef SIGQUIT + signal(SIGQUIT, poked); +#endif + signal(SIGTERM, poked); +#endif /* HAVE_SIGNAL_H */ + + /* Initialize fillerup() variables */ + if (SDL_OpenAudio(&wave.spec, NULL) < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); + SDL_FreeWAV(wave.sound); + quit(2); + } + + /*static x[99999]; SDL_QueueAudio(1, x, sizeof (x));*/ + + /* Let the audio run */ + SDL_PauseAudio(0); + + /* 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. */ + + while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) + { + /* 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? */ + if (SDL_QueueAudio(1, wave.sound, wave.soundlen) == 0) { + 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_Delay(100); /* let it play for awhile. */ + } + + /* Clean up on signal */ + SDL_CloseAudio(); + SDL_FreeWAV(wave.sound); + SDL_Quit(); + return 0; +} + +/* vi: set ts=4 sw=4 expandtab: */ From 5c6c86912d6bea66391ea7d8683d7ea8d54c2b66 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 27 Jul 2014 17:43:36 -0700 Subject: [PATCH 05/17] Fixed uninitialized variable in some cases --- src/render/software/SDL_draw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/software/SDL_draw.h b/src/render/software/SDL_draw.h index fff462e6df5b6..2bd8f94c9a9fc 100644 --- a/src/render/software/SDL_draw.h +++ b/src/render/software/SDL_draw.h @@ -51,7 +51,7 @@ do { \ #define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \ do { \ - unsigned sr, sg, sb, sa; \ + unsigned sr, sg, sb, sa = 0xFF; \ getpixel; \ sr = DRAW_MUL(inva, sr) + r; \ sg = DRAW_MUL(inva, sg) + g; \ From a0b68e817d15022d0824e4ac27bda1913d092b06 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 27 Jul 2014 17:44:10 -0700 Subject: [PATCH 06/17] Fixed bug 2537 - _allmul in SDL_lib.c is not working properly --- src/stdlib/SDL_stdlib.c | 67 ++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index c5f5e9d876f71..b1de63d2a8a72 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -370,44 +370,35 @@ _ftol2_sse() _ftol(); } -/* 64-bit math operators for 32-bit systems */ -void -__declspec(naked) -_allmul() -{ - /* *INDENT-OFF* */ - __asm { - push ebp - mov ebp,esp - push edi - push esi - push ebx - sub esp,0Ch - mov eax,dword ptr [ebp+10h] - mov edi,dword ptr [ebp+8] - mov ebx,eax - mov esi,eax - sar esi,1Fh - mov eax,dword ptr [ebp+8] - mul ebx - imul edi,esi - mov ecx,edx - mov dword ptr [ebp-18h],eax - mov edx,dword ptr [ebp+0Ch] - add ecx,edi - imul ebx,edx - mov eax,dword ptr [ebp-18h] - lea ebx,[ebx+ecx] - mov dword ptr [ebp-14h],ebx - mov edx,dword ptr [ebp-14h] - add esp,0Ch - pop ebx - pop esi - pop edi - pop ebp - ret 10h - } - /* *INDENT-ON* */ +/* 64-bit math operators for 32-bit systems */ +void +__declspec(naked) +_allmul() +{ + /* *INDENT-OFF* */ + __asm { + mov eax, dword ptr[esp+8] + mov ecx, dword ptr[esp+10h] + or ecx, eax + mov ecx, dword ptr[esp+0Ch] + jne hard + mov eax, dword ptr[esp+4] + mul ecx + ret 10h +hard: + push ebx + mul ecx + mov ebx, eax + mov eax, dword ptr[esp+8] + mul dword ptr[esp+14h] + add ebx, eax + mov eax, dword ptr[esp+8] + mul ecx + add edx, ebx + pop ebx + ret 10h + } + /* *INDENT-ON* */ } void From 2230df55259da1567ffb2011c9b41676da15c76a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 27 Jul 2014 19:52:52 -0400 Subject: [PATCH 07/17] Remove dependency on C runtime from Windows SDLmain. --- src/main/windows/SDL_windows_main.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index 8c8ccab6b9442..f7cdbdbc285d3 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -10,9 +10,6 @@ /* Include this so we define UNICODE properly */ #include "../../core/windows/SDL_windows.h" -#include -#include - /* Include the SDL main definition header */ #include "SDL.h" #include "SDL_main.h" @@ -103,23 +100,11 @@ ParseCommandLine(char *cmdline, char **argv) return (argc); } -/* Show an error message */ -static void -ShowError(const char *title, const char *message) -{ -/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ -#ifdef USE_MESSAGEBOX - MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK); -#else - fprintf(stderr, "%s: %s\n", title, message); -#endif -} - /* Pop up an out of memory message, returns to Windows */ static BOOL OutOfMemory(void) { - ShowError("Fatal Error", "Out of memory - aborting"); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL); return FALSE; } @@ -132,18 +117,10 @@ OutOfMemory(void) int console_main(int argc, char *argv[]) { - int status; - SDL_SetMainReady(); /* Run the application main() code */ - status = SDL_main(argc, argv); - - /* Exit cleanly, calling atexit() functions */ - exit(status); - - /* Hush little compiler, don't you cry... */ - return 0; + return SDL_main(argc, argv); } /* This is where execution begins [windowed apps] */ From 164de2325e4c00a06e228fd5c9bfa2812d19efac Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 27 Jul 2014 19:56:53 -0700 Subject: [PATCH 08/17] Turned on OmitDefaultLibName for SDL, SDLmain and SDLtest --- VisualC/SDL/SDL_VS2008.vcproj | 4 + VisualC/SDL/SDL_VS2010.vcxproj | 6 +- VisualC/SDL/SDL_VS2012.vcxproj | 6 +- VisualC/SDL/SDL_VS2013.vcxproj | 4 + VisualC/SDLmain/SDLmain_VS2008.vcproj | 4 + VisualC/SDLmain/SDLmain_VS2010.vcxproj | 330 +++++++++++++------------ VisualC/SDLmain/SDLmain_VS2012.vcxproj | 6 +- VisualC/SDLmain/SDLmain_VS2013.vcxproj | 4 + VisualC/SDLtest/SDLtest_VS2008.vcproj | 4 + VisualC/SDLtest/SDLtest_VS2010.vcxproj | 6 +- VisualC/SDLtest/SDLtest_VS2012.vcxproj | 6 +- VisualC/SDLtest/SDLtest_VS2013.vcxproj | 4 + 12 files changed, 216 insertions(+), 168 deletions(-) diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj index 53db16dd513c7..bf33777c30db4 100644 --- a/VisualC/SDL/SDL_VS2008.vcproj +++ b/VisualC/SDL/SDL_VS2008.vcproj @@ -61,6 +61,7 @@ Detect64BitPortabilityProblems="false" DebugInformationFormat="4" CompileAs="0" + OmitDefaultLibName="true" /> Default false StreamingSIMDExtensions + true _DEBUG;%(PreprocessorDefinitions) @@ -127,6 +128,7 @@ Level3 ProgramDatabase false + true _DEBUG;%(PreprocessorDefinitions) @@ -167,6 +169,7 @@ false ProgramDatabase StreamingSIMDExtensions + true NDEBUG;%(PreprocessorDefinitions) @@ -203,6 +206,7 @@ Level3 false ProgramDatabase + true NDEBUG;%(PreprocessorDefinitions) @@ -510,4 +514,4 @@ - + \ No newline at end of file diff --git a/VisualC/SDL/SDL_VS2012.vcxproj b/VisualC/SDL/SDL_VS2012.vcxproj index 1a1350890cb8a..1dade200d1482 100644 --- a/VisualC/SDL/SDL_VS2012.vcxproj +++ b/VisualC/SDL/SDL_VS2012.vcxproj @@ -98,6 +98,7 @@ Default false StreamingSIMDExtensions + true _DEBUG;%(PreprocessorDefinitions) @@ -131,6 +132,7 @@ Level3 ProgramDatabase false + true _DEBUG;%(PreprocessorDefinitions) @@ -171,6 +173,7 @@ false ProgramDatabase StreamingSIMDExtensions + true NDEBUG;%(PreprocessorDefinitions) @@ -207,6 +210,7 @@ Level3 false ProgramDatabase + true NDEBUG;%(PreprocessorDefinitions) @@ -514,4 +518,4 @@ - + \ No newline at end of file diff --git a/VisualC/SDL/SDL_VS2013.vcxproj b/VisualC/SDL/SDL_VS2013.vcxproj index 1ef810e4978a1..89dbc00a9777b 100644 --- a/VisualC/SDL/SDL_VS2013.vcxproj +++ b/VisualC/SDL/SDL_VS2013.vcxproj @@ -98,6 +98,7 @@ Default false StreamingSIMDExtensions + true _DEBUG;%(PreprocessorDefinitions) @@ -131,6 +132,7 @@ Level3 ProgramDatabase false + true _DEBUG;%(PreprocessorDefinitions) @@ -171,6 +173,7 @@ false ProgramDatabase StreamingSIMDExtensions + true NDEBUG;%(PreprocessorDefinitions) @@ -207,6 +210,7 @@ Level3 false ProgramDatabase + true NDEBUG;%(PreprocessorDefinitions) diff --git a/VisualC/SDLmain/SDLmain_VS2008.vcproj b/VisualC/SDLmain/SDLmain_VS2008.vcproj index 1f707c9ea9247..33c24171a6788 100644 --- a/VisualC/SDLmain/SDLmain_VS2008.vcproj +++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj @@ -56,6 +56,7 @@ SuppressStartupBanner="true" DebugInformationFormat="1" CompileAs="0" + OmitDefaultLibName="true" /> - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - SDL2main - {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} - - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - - - - - OnlyExplicitInline - ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreadedDLL - true - - - Level3 - true - Default - OldStyle - false - - - true - - - - - X64 - - - OnlyExplicitInline - ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreadedDLL - true - - - Level3 - true - Default - OldStyle - false - - - true - - - - - - Disabled - ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - true - OldStyle - Default - false - - - true - - - - - X64 - - - Disabled - ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - true - OldStyle - Default - false - - - true - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + SDL2main + {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} + + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + MultiByte + + + StaticLibrary + false + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)\$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)\$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)\$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)\$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + + + OnlyExplicitInline + ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + + Level3 + true + Default + OldStyle + false + true + + + true + + + + + X64 + + + OnlyExplicitInline + ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + + + Level3 + true + Default + OldStyle + false + true + + + true + + + + + + Disabled + ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + + + Level3 + true + OldStyle + Default + false + true + + + true + + + + + X64 + + + Disabled + ..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + + + Level3 + true + OldStyle + Default + false + true + + + true + + + + + + + + \ No newline at end of file diff --git a/VisualC/SDLmain/SDLmain_VS2012.vcxproj b/VisualC/SDLmain/SDLmain_VS2012.vcxproj index 3caa8b725f97a..c6c65d233c455 100644 --- a/VisualC/SDLmain/SDLmain_VS2012.vcxproj +++ b/VisualC/SDLmain/SDLmain_VS2012.vcxproj @@ -91,6 +91,7 @@ Default OldStyle false + true true @@ -114,6 +115,7 @@ Default OldStyle false + true true @@ -133,6 +135,7 @@ OldStyle Default false + true true @@ -154,6 +157,7 @@ OldStyle Default false + true true @@ -165,4 +169,4 @@ - + \ No newline at end of file diff --git a/VisualC/SDLmain/SDLmain_VS2013.vcxproj b/VisualC/SDLmain/SDLmain_VS2013.vcxproj index 3f5c004cd17f1..3b90f23f7b3d0 100644 --- a/VisualC/SDLmain/SDLmain_VS2013.vcxproj +++ b/VisualC/SDLmain/SDLmain_VS2013.vcxproj @@ -91,6 +91,7 @@ Default OldStyle false + true true @@ -114,6 +115,7 @@ Default OldStyle false + true true @@ -133,6 +135,7 @@ OldStyle Default false + true true @@ -154,6 +157,7 @@ OldStyle Default false + true true diff --git a/VisualC/SDLtest/SDLtest_VS2008.vcproj b/VisualC/SDLtest/SDLtest_VS2008.vcproj index 97f09a6138d17..ccaabe2d2f0f4 100644 --- a/VisualC/SDLtest/SDLtest_VS2008.vcproj +++ b/VisualC/SDLtest/SDLtest_VS2008.vcproj @@ -56,6 +56,7 @@ SuppressStartupBanner="true" DebugInformationFormat="1" CompileAs="0" + OmitDefaultLibName="true" /> Default OldStyle false + true true @@ -110,6 +111,7 @@ Default OldStyle false + true true @@ -129,6 +131,7 @@ OldStyle Default false + true true @@ -150,6 +153,7 @@ OldStyle Default false + true true @@ -189,4 +193,4 @@ - + \ No newline at end of file diff --git a/VisualC/SDLtest/SDLtest_VS2012.vcxproj b/VisualC/SDLtest/SDLtest_VS2012.vcxproj index b60e4bc7dab60..256bbf2fc37f8 100644 --- a/VisualC/SDLtest/SDLtest_VS2012.vcxproj +++ b/VisualC/SDLtest/SDLtest_VS2012.vcxproj @@ -91,6 +91,7 @@ Default OldStyle false + true true @@ -114,6 +115,7 @@ Default OldStyle false + true true @@ -133,6 +135,7 @@ OldStyle Default false + true true @@ -154,6 +157,7 @@ OldStyle Default false + true true @@ -193,4 +197,4 @@ - + \ No newline at end of file diff --git a/VisualC/SDLtest/SDLtest_VS2013.vcxproj b/VisualC/SDLtest/SDLtest_VS2013.vcxproj index 683a584079ce7..a515ab084840d 100644 --- a/VisualC/SDLtest/SDLtest_VS2013.vcxproj +++ b/VisualC/SDLtest/SDLtest_VS2013.vcxproj @@ -91,6 +91,7 @@ Default OldStyle false + true true @@ -114,6 +115,7 @@ Default OldStyle false + true true @@ -133,6 +135,7 @@ OldStyle Default false + true true @@ -154,6 +157,7 @@ OldStyle Default false + true true From 0c09ce2b349421eb650914c57b411f04cae2d43c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 28 Jul 2014 10:54:25 -0400 Subject: [PATCH 09/17] Changed local var names in SDL assert macro. Otherwise, if someone added an assert to a function that has a variable named "state", the compiler might warn about shadowing a local. --- include/SDL_assert.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/SDL_assert.h b/include/SDL_assert.h index c8a944d9cf076..94d998770c293 100644 --- a/include/SDL_assert.h +++ b/include/SDL_assert.h @@ -141,16 +141,13 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, #define SDL_enabled_assert(condition) \ do { \ while ( !(condition) ) { \ - static struct SDL_assert_data assert_data = { \ + static struct SDL_assert_data sdl_assert_data = { \ 0, 0, #condition, 0, 0, 0, 0 \ }; \ - const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \ - SDL_FUNCTION, \ - SDL_FILE, \ - SDL_LINE); \ - if (state == SDL_ASSERTION_RETRY) { \ + const SDL_assert_state sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ + if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ continue; /* go again. */ \ - } else if (state == SDL_ASSERTION_BREAK) { \ + } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ SDL_TriggerBreakpoint(); \ } \ break; /* not retrying. */ \ From f982d0878429a5634972353281dca24a54b99343 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Tue, 29 Jul 2014 09:20:12 -0300 Subject: [PATCH 10/17] Rearrange documentation 1) Moves all READMEs to docs/ 2) Renames them to *.md, adds some Markdown with the idea to add a lot more 3) Moves the doxyfile config to doc/ and makes it parse the headers at ../include as well as the md files in docs. 4) Skips SDL_opengl*.h headers from the docs 5) Minor fixes to doxyfile --- README-SDL.txt => doc/README-SDL.md | 0 README-android.txt => doc/README-android.md | 3 +- README-cmake.txt => doc/README-cmake.md | 4 +- README-directfb.txt => doc/README-directfb.md | 3 +- README-dynapi.txt => doc/README-dynapi.md | 1 - README-gesture.txt => doc/README-gesture.md | 1 - README-hg.txt => doc/README-hg.md | 3 + README-ios.txt => doc/README-ios.md | 3 + README-linux.txt => doc/README-linux.md | 3 +- README-macosx.txt => doc/README-macosx.md | 3 +- README-nacl.txt => doc/README-nacl.md | 3 +- README-pandora.txt => doc/README-pandora.md | 5 +- .../README-platforms.md | 3 + README-porting.txt => doc/README-porting.md | 2 + README-psp.txt => doc/README-psp.md | 2 + .../README-raspberrypi.md | 3 +- README-touch.txt => doc/README-touch.md | 1 + README-wince.txt => doc/README-wince.md | 2 + README-windows.txt => doc/README-windows.md | 3 +- README-winrt.txt => doc/README-winrt.md | 3 +- README.txt => doc/README.md | 104 +++++++++++------- {include => doc}/doxyfile | 24 ++-- include/SDL.h | 35 ------ 23 files changed, 106 insertions(+), 108 deletions(-) rename README-SDL.txt => doc/README-SDL.md (100%) rename README-android.txt => doc/README-android.md (97%) rename README-cmake.txt => doc/README-cmake.md (86%) rename README-directfb.txt => doc/README-directfb.md (95%) rename README-dynapi.txt => doc/README-dynapi.md (98%) rename README-gesture.txt => doc/README-gesture.md (96%) rename README-hg.txt => doc/README-hg.md (95%) rename README-ios.txt => doc/README-ios.md (97%) rename README-linux.txt => doc/README-linux.md (96%) rename README-macosx.txt => doc/README-macosx.md (96%) rename README-nacl.txt => doc/README-nacl.md (97%) rename README-pandora.txt => doc/README-pandora.md (89%) rename README-platforms.txt => doc/README-platforms.md (93%) rename README-porting.txt => doc/README-porting.md (96%) rename README-psp.txt => doc/README-psp.md (92%) rename README-raspberrypi.txt => doc/README-raspberrypi.md (96%) rename README-touch.txt => doc/README-touch.md (97%) rename README-wince.txt => doc/README-wince.md (90%) rename README-windows.txt => doc/README-windows.md (94%) rename README-winrt.txt => doc/README-winrt.md (93%) rename README.txt => doc/README.md (54%) rename {include => doc}/doxyfile (99%) diff --git a/README-SDL.txt b/doc/README-SDL.md similarity index 100% rename from README-SDL.txt rename to doc/README-SDL.md diff --git a/README-android.txt b/doc/README-android.md similarity index 97% rename from README-android.txt rename to doc/README-android.md index 3275a1111f1c2..c061f95a73e75 100644 --- a/README-android.txt +++ b/doc/README-android.md @@ -1,5 +1,4 @@ -================================================================================ -Simple DirectMedia Layer for Android +Android ================================================================================ Requirements: diff --git a/README-cmake.txt b/doc/README-cmake.md similarity index 86% rename from README-cmake.txt rename to doc/README-cmake.md index 63c762b53bd4b..b5daad9084159 100644 --- a/README-cmake.txt +++ b/doc/README-cmake.md @@ -1,6 +1,6 @@ +CMake ================================================================================ -CMake build system for SDL (www.cmake.org) -================================================================================ +(www.cmake.org) SDL's build system was traditionally based on autotools. Over time, this approach has suffered from several issues across the different supported diff --git a/README-directfb.txt b/doc/README-directfb.md similarity index 95% rename from README-directfb.txt rename to doc/README-directfb.md index e358278ca6ba0..a7b542fa3923f 100644 --- a/README-directfb.txt +++ b/doc/README-directfb.md @@ -1,4 +1,5 @@ -SDL on DirectFB +DirectFB +======== Supports: diff --git a/README-dynapi.txt b/doc/README-dynapi.md similarity index 98% rename from README-dynapi.txt rename to doc/README-dynapi.md index e28ac59b744a6..5669fd76e7745 100644 --- a/README-dynapi.txt +++ b/doc/README-dynapi.md @@ -1,4 +1,3 @@ -================================================================================ Dynamic API ================================================================================ Originally posted by Ryan at https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U diff --git a/README-gesture.txt b/doc/README-gesture.md similarity index 96% rename from README-gesture.txt rename to doc/README-gesture.md index c2cad7be5b8fe..fc8a093c72e4f 100644 --- a/README-gesture.txt +++ b/doc/README-gesture.md @@ -1,4 +1,3 @@ -=========================================================================== Dollar Gestures =========================================================================== SDL Provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures. diff --git a/README-hg.txt b/doc/README-hg.md similarity index 95% rename from README-hg.txt rename to doc/README-hg.md index 32fb8f99d17ac..27396327c7177 100644 --- a/README-hg.txt +++ b/doc/README-hg.md @@ -1,3 +1,6 @@ +Mercurial +========= + The latest development version of SDL is available via Mercurial. Mercurial allows you to get up-to-the-minute fixes and enhancements; as a developer works on a source tree, you can use "hg" to mirror that diff --git a/README-ios.txt b/doc/README-ios.md similarity index 97% rename from README-ios.txt rename to doc/README-ios.md index 4e6ca0eb9bcd4..62ec395d545a4 100644 --- a/README-ios.txt +++ b/doc/README-ios.md @@ -1,3 +1,6 @@ +iOS +====== + ============================================================================== Building the Simple DirectMedia Layer for iPhone OS 5.1 ============================================================================== diff --git a/README-linux.txt b/doc/README-linux.md similarity index 96% rename from README-linux.txt rename to doc/README-linux.md index f3f2fb8d80cf6..d9cf40fb99c39 100644 --- a/README-linux.txt +++ b/doc/README-linux.md @@ -1,5 +1,4 @@ -================================================================================ -Simple DirectMedia Layer for Linux +Linux ================================================================================ By default SDL will only link against glibc, the rest of the features will be diff --git a/README-macosx.txt b/doc/README-macosx.md similarity index 96% rename from README-macosx.txt rename to doc/README-macosx.md index 895b9d142f95f..ca6b7ee12296f 100644 --- a/README-macosx.txt +++ b/doc/README-macosx.md @@ -1,5 +1,4 @@ -============================================================================== -Using the Simple DirectMedia Layer with Mac OS X +Mac OS X ============================================================================== These instructions are for people using Apple's Mac OS X (pronounced diff --git a/README-nacl.txt b/doc/README-nacl.md similarity index 97% rename from README-nacl.txt rename to doc/README-nacl.md index d868e918080b3..b664f05ee7c8b 100644 --- a/README-nacl.txt +++ b/doc/README-nacl.md @@ -1,5 +1,4 @@ -================================================================================ -Simple DirectMedia Layer for Native Client +Native Client ================================================================================ Requirements: diff --git a/README-pandora.txt b/doc/README-pandora.md similarity index 89% rename from README-pandora.txt rename to doc/README-pandora.md index f70ed6725f0b6..e50e0c279642e 100644 --- a/README-pandora.txt +++ b/doc/README-pandora.md @@ -1,6 +1,7 @@ -SDL 2.0 with open pandora console support ( http://openpandora.org/ ) +Pandora ===================================================================== - + +( http://openpandora.org/ ) - A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES support to work on the pandora under the framebuffer. This driver do not have input support for now, so if you use it you will have to add your own control code. diff --git a/README-platforms.txt b/doc/README-platforms.md similarity index 93% rename from README-platforms.txt rename to doc/README-platforms.md index 1fe2c87ee586c..3f1950a91cc19 100644 --- a/README-platforms.txt +++ b/doc/README-platforms.md @@ -1,3 +1,6 @@ +Platforms +========= + This is a list of the platforms SDL supports, and who maintains them. diff --git a/README-porting.txt b/doc/README-porting.md similarity index 96% rename from README-porting.txt rename to doc/README-porting.md index bea194a4a5a89..d93c65bd39405 100644 --- a/README-porting.txt +++ b/doc/README-porting.md @@ -1,3 +1,5 @@ +Porting +======= * Porting To A New Platform diff --git a/README-psp.txt b/doc/README-psp.md similarity index 92% rename from README-psp.txt rename to doc/README-psp.md index e9e32ea5c4dfb..41fc9040aaa65 100644 --- a/README-psp.txt +++ b/doc/README-psp.md @@ -1,3 +1,5 @@ +PSP +====== SDL port for the Sony PSP contributed by Captian Lex diff --git a/README-raspberrypi.txt b/doc/README-raspberrypi.md similarity index 96% rename from README-raspberrypi.txt rename to doc/README-raspberrypi.md index 22b4bbc9ee722..de920cce1c47b 100644 --- a/README-raspberrypi.txt +++ b/doc/README-raspberrypi.md @@ -1,5 +1,4 @@ -================================================================================ -SDL2 for Raspberry Pi +Raspberry Pi ================================================================================ Requirements: diff --git a/README-touch.txt b/doc/README-touch.md similarity index 97% rename from README-touch.txt rename to doc/README-touch.md index 07823c93438f8..5850b4f8ff56c 100644 --- a/README-touch.txt +++ b/doc/README-touch.md @@ -1,3 +1,4 @@ +Touch =========================================================================== System Specific Notes =========================================================================== diff --git a/README-wince.txt b/doc/README-wince.md similarity index 90% rename from README-wince.txt rename to doc/README-wince.md index b7fd3f12fec8f..c543ed65ddf1c 100644 --- a/README-wince.txt +++ b/doc/README-wince.md @@ -1,3 +1,5 @@ +WinCE +===== Windows CE is no longer supported by SDL. diff --git a/README-windows.txt b/doc/README-windows.md similarity index 94% rename from README-windows.txt rename to doc/README-windows.md index 7f9c4a35f205f..076b1556e84ac 100644 --- a/README-windows.txt +++ b/doc/README-windows.md @@ -1,5 +1,4 @@ -================================================================================ -Simple DirectMedia Layer for Windows +Windows ================================================================================ ================================================================================ diff --git a/README-winrt.txt b/doc/README-winrt.md similarity index 93% rename from README-winrt.txt rename to doc/README-winrt.md index efc181b29d8d0..ee3a30327c758 100644 --- a/README-winrt.txt +++ b/doc/README-winrt.md @@ -1,5 +1,4 @@ -================================================================================ -Simple DirectMedia Layer for WinRT +WinRT ================================================================================ SDL/WinRT layer allows SDL2-based applications to run on many of Microsoft's diff --git a/README.txt b/doc/README.md similarity index 54% rename from README.txt rename to doc/README.md index 735637b948d92..d538dca0df163 100644 --- a/README.txt +++ b/doc/README.md @@ -1,42 +1,62 @@ - - Simple DirectMedia Layer - - (SDL) - - Version 2.0 - ---- -http://www.libsdl.org/ - -Simple DirectMedia Layer is a cross-platform development library designed -to provide low level access to audio, keyboard, mouse, joystick, and graphics -hardware via OpenGL and Direct3D. It is used by video playback software, -emulators, and popular games including Valve's award winning catalog -and many Humble Bundle games. - -SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. -Support for other platforms may be found in the source code. - -SDL is written in C, works natively with C++, and there are bindings -available for several other languages, including C# and Python. - -This library is distributed under the zlib license, which can be found -in the file "COPYING.txt". - -The best way to learn how to use SDL is to check out the header files in -the "include" subdirectory and the programs in the "test" subdirectory. -The header files and test programs are well commented and always up to date. -More documentation and FAQs are available online at: - http://wiki.libsdl.org/ - -If you need help with the library, or just want to discuss SDL related -issues, you can join the developers mailing list: - http://www.libsdl.org/mailing-list.php - -If you want to report bugs or contribute patches, please submit them to -bugzilla: - http://bugzilla.libsdl.org/ - -Enjoy! - Sam Lantinga (slouken@libsdl.org) - +Simple DirectMedia Layer {#mainpage} +======================== + + (SDL) + + Version 2.0 + +--- +http://www.libsdl.org/ + +Simple DirectMedia Layer is a cross-platform development library designed +to provide low level access to audio, keyboard, mouse, joystick, and graphics +hardware via OpenGL and Direct3D. It is used by video playback software, +emulators, and popular games including Valve's award winning catalog +and many Humble Bundle games. 42 + +SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. +Support for other platforms may be found in the source code. + +SDL is written in C, works natively with C++, and there are bindings +available for several other languages, including C# and Python. + +This library is distributed under the zlib license, which can be found +in the file "COPYING.txt". + +The best way to learn how to use SDL is to check out the header files in +the "include" subdirectory and the programs in the "test" subdirectory. +The header files and test programs are well commented and always up to date. + +More documentation and FAQs are available online at [the wiki](http://wiki.libsdl.org/) + +- [Android](README-android.md) +- [CMake](README-cmake.md) +- [DirectFB](README-directfb.md) +- [DynAPI](README-dynapi.md) +- [Gesture](README-gesture.md) +- [Mercurial](README-hg.md) +- [iOS](README-ios.md) +- [Linux](README-linux.md) +- [OS X](README-macosx.md) +- [Native Client](README-nacl.md) +- [Pandora](README-pandora.md) +- [Supported Platforms](README-platforms.md) +- [Porting information](README-porting.md) +- [PSP](README-psp.md) +- [Raspberry Pi](README-raspberrypi.md) +- [Touch](README-touch.md) +- [WinCE](README-wince.md) +- [Windows](README-windows.md) +- [WinRT](README-winrt.md) + +If you need help with the library, or just want to discuss SDL related +issues, you can join the [developers mailing list](http://www.libsdl.org/mailing-list.php) + +If you want to report bugs or contribute patches, please submit them to +[bugzilla](http://bugzilla.libsdl.org/) + +Enjoy! + + +Sam Lantinga + diff --git a/include/doxyfile b/doc/doxyfile similarity index 99% rename from include/doxyfile rename to doc/doxyfile index 495dbc19bca22..151fa896a30aa 100644 --- a/include/doxyfile +++ b/doc/doxyfile @@ -38,7 +38,7 @@ PROJECT_NUMBER = 2.0.0 # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = . +OUTPUT_DIRECTORY = ./output # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -569,7 +569,7 @@ WARN_LOGFILE = ./doxygen_warn.txt # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = . +INPUT = . ../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -618,7 +618,8 @@ FILE_PATTERNS = *.c \ *.vhd \ *.vhdl \ *.h.in \ - *.h.default + *.h.default \ + *.md # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. @@ -630,12 +631,15 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = ../doxy \ - ../test \ - ../Xcode \ - ../VisualC \ - ../VisualCE \ - ../Xcode-iOS +EXCLUDE = ../include/SDL_opengles2_gl2ext.h \ + ../include/SDL_opengles2_gl2platform.h \ + ../include/SDL_opengles2_khrplatform.h \ + ../include/SDL_opengl_glext.h \ + ../include/SDL_opengles2_gl2.h \ + ../include/SDL_opengles2.h \ + ../include/SDL_opengles.h \ + ../include/SDL_opengl.h \ + # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded @@ -1271,7 +1275,7 @@ SEARCH_INCLUDES = YES # contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the diff --git a/include/SDL.h b/include/SDL.h index 206214753b39f..703dc3d946ce0 100644 --- a/include/SDL.h +++ b/include/SDL.h @@ -25,41 +25,6 @@ * Main include header for the SDL library */ -/** - * \mainpage Simple DirectMedia Layer (SDL) - * - * http://www.libsdl.org/ - * - * \section intro_sec Introduction - * - * Simple DirectMedia Layer is a cross-platform development library designed - * to provide low level access to audio, keyboard, mouse, joystick, and - * graphics hardware via OpenGL and Direct3D. It is used by video playback - * software, emulators, and popular games including Valve's award winning - * catalog and many Humble Bundle games. - * - * SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. - * Support for other platforms may be found in the source code. - * - * SDL is written in C, works natively with C++, and there are bindings - * available for several other languages, including C# and Python. - * - * This library is distributed under the zlib license, which can be found - * in the file "COPYING.txt". - * - * The best way to learn how to use SDL is to check out the header files in - * the "include" subdirectory and the programs in the "test" subdirectory. - * The header files and test programs are well commented and always up to date. - * More documentation and FAQs are available online at: - * http://wiki.libsdl.org/ - * - * If you need help with the library, or just want to discuss SDL related - * issues, you can join the developers mailing list: - * http://www.libsdl.org/mailing-list.php - * - * Enjoy! - * Sam Lantinga (slouken@libsdl.org) - */ #ifndef _SDL_H #define _SDL_H From e76fecc4ed1c21ec097dc08fc848e577ee31c088 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 29 Jul 2014 08:04:15 -0700 Subject: [PATCH 11/17] Moved documentation to docs, recreated a simple README.txt, fixed build --- INSTALL.txt | 8 ++++---- doc/README-SDL.md => README-SDL.txt | 0 README.txt | 21 +++++++++++++++++++++ {doc => docs}/README-android.md | 0 {doc => docs}/README-cmake.md | 0 {doc => docs}/README-directfb.md | 0 {doc => docs}/README-dynapi.md | 0 {doc => docs}/README-gesture.md | 0 {doc => docs}/README-hg.md | 0 {doc => docs}/README-ios.md | 0 {doc => docs}/README-linux.md | 0 {doc => docs}/README-macosx.md | 0 {doc => docs}/README-nacl.md | 0 {doc => docs}/README-pandora.md | 0 {doc => docs}/README-platforms.md | 0 {doc => docs}/README-porting.md | 0 {doc => docs}/README-psp.md | 0 {doc => docs}/README-raspberrypi.md | 0 {doc => docs}/README-touch.md | 0 {doc => docs}/README-wince.md | 0 {doc => docs}/README-windows.md | 0 {doc => docs}/README-winrt.md | 0 {doc => docs}/README.md | 0 {doc => docs}/doxyfile | 0 24 files changed, 25 insertions(+), 4 deletions(-) rename doc/README-SDL.md => README-SDL.txt (100%) create mode 100644 README.txt rename {doc => docs}/README-android.md (100%) rename {doc => docs}/README-cmake.md (100%) rename {doc => docs}/README-directfb.md (100%) rename {doc => docs}/README-dynapi.md (100%) rename {doc => docs}/README-gesture.md (100%) rename {doc => docs}/README-hg.md (100%) rename {doc => docs}/README-ios.md (100%) rename {doc => docs}/README-linux.md (100%) rename {doc => docs}/README-macosx.md (100%) rename {doc => docs}/README-nacl.md (100%) rename {doc => docs}/README-pandora.md (100%) rename {doc => docs}/README-platforms.md (100%) rename {doc => docs}/README-porting.md (100%) rename {doc => docs}/README-psp.md (100%) rename {doc => docs}/README-raspberrypi.md (100%) rename {doc => docs}/README-touch.md (100%) rename {doc => docs}/README-wince.md (100%) rename {doc => docs}/README-windows.md (100%) rename {doc => docs}/README-winrt.md (100%) rename {doc => docs}/README.md (100%) rename {doc => docs}/doxyfile (100%) diff --git a/INSTALL.txt b/INSTALL.txt index ce77664c99459..2df10bdd70bb8 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -9,7 +9,7 @@ To compile and install SDL: * Run './configure; make; make install' Mac OS X with Xcode: - * Read README-macosx.txt + * Read docs/README-macosx.md Mac OS X from the command line: * Run './configure; make; make install' @@ -18,13 +18,13 @@ To compile and install SDL: * Run './configure; make; make install' Android: - * Read README-android.txt + * Read docs/README-android.md iOS: - * Read README-ios.txt + * Read docs/README-ios.md Using Cmake: - * Read README-cmake.txt + * Read docs/README-cmake.md 2. Look at the example programs in ./test, and check out the online documentation at http://wiki.libsdl.org/ diff --git a/doc/README-SDL.md b/README-SDL.txt similarity index 100% rename from doc/README-SDL.md rename to README-SDL.txt diff --git a/README.txt b/README.txt new file mode 100644 index 0000000000000..84c335c2bd44a --- /dev/null +++ b/README.txt @@ -0,0 +1,21 @@ + + Simple DirectMedia Layer + + (SDL) + + Version 2.0 + +--- +http://www.libsdl.org/ + +Simple DirectMedia Layer is a cross-platform development library designed +to provide low level access to audio, keyboard, mouse, joystick, and graphics +hardware via OpenGL and Direct3D. It is used by video playback software, +emulators, and popular games including Valve's award winning catalog +and many Humble Bundle games. + +More extensive documentation is available in the docs directory, starting +with README.md + +Enjoy! + Sam Lantinga (slouken@libsdl.org) diff --git a/doc/README-android.md b/docs/README-android.md similarity index 100% rename from doc/README-android.md rename to docs/README-android.md diff --git a/doc/README-cmake.md b/docs/README-cmake.md similarity index 100% rename from doc/README-cmake.md rename to docs/README-cmake.md diff --git a/doc/README-directfb.md b/docs/README-directfb.md similarity index 100% rename from doc/README-directfb.md rename to docs/README-directfb.md diff --git a/doc/README-dynapi.md b/docs/README-dynapi.md similarity index 100% rename from doc/README-dynapi.md rename to docs/README-dynapi.md diff --git a/doc/README-gesture.md b/docs/README-gesture.md similarity index 100% rename from doc/README-gesture.md rename to docs/README-gesture.md diff --git a/doc/README-hg.md b/docs/README-hg.md similarity index 100% rename from doc/README-hg.md rename to docs/README-hg.md diff --git a/doc/README-ios.md b/docs/README-ios.md similarity index 100% rename from doc/README-ios.md rename to docs/README-ios.md diff --git a/doc/README-linux.md b/docs/README-linux.md similarity index 100% rename from doc/README-linux.md rename to docs/README-linux.md diff --git a/doc/README-macosx.md b/docs/README-macosx.md similarity index 100% rename from doc/README-macosx.md rename to docs/README-macosx.md diff --git a/doc/README-nacl.md b/docs/README-nacl.md similarity index 100% rename from doc/README-nacl.md rename to docs/README-nacl.md diff --git a/doc/README-pandora.md b/docs/README-pandora.md similarity index 100% rename from doc/README-pandora.md rename to docs/README-pandora.md diff --git a/doc/README-platforms.md b/docs/README-platforms.md similarity index 100% rename from doc/README-platforms.md rename to docs/README-platforms.md diff --git a/doc/README-porting.md b/docs/README-porting.md similarity index 100% rename from doc/README-porting.md rename to docs/README-porting.md diff --git a/doc/README-psp.md b/docs/README-psp.md similarity index 100% rename from doc/README-psp.md rename to docs/README-psp.md diff --git a/doc/README-raspberrypi.md b/docs/README-raspberrypi.md similarity index 100% rename from doc/README-raspberrypi.md rename to docs/README-raspberrypi.md diff --git a/doc/README-touch.md b/docs/README-touch.md similarity index 100% rename from doc/README-touch.md rename to docs/README-touch.md diff --git a/doc/README-wince.md b/docs/README-wince.md similarity index 100% rename from doc/README-wince.md rename to docs/README-wince.md diff --git a/doc/README-windows.md b/docs/README-windows.md similarity index 100% rename from doc/README-windows.md rename to docs/README-windows.md diff --git a/doc/README-winrt.md b/docs/README-winrt.md similarity index 100% rename from doc/README-winrt.md rename to docs/README-winrt.md diff --git a/doc/README.md b/docs/README.md similarity index 100% rename from doc/README.md rename to docs/README.md diff --git a/doc/doxyfile b/docs/doxyfile similarity index 100% rename from doc/doxyfile rename to docs/doxyfile From db1dd7560e29e5017d8a1309ca16fdeade7560b8 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 30 Jul 2014 09:54:01 -0400 Subject: [PATCH 12/17] XAudio2: Use XAUDIO2_VOICE_NOSAMPLESPLAYED when possible. For versions of XAudio2 with an IXAudio2SourceVoice::GetState() that offers a flags parameter, we can use XAUDIO2_VOICE_NOSAMPLESPLAYED, since we don't need this information in our current calls. According to MSDN, this makes the the call about 3x faster. --- src/audio/xaudio2/SDL_xaudio2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index a1a18df6db340..abcbdfb481856 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -241,14 +241,14 @@ XAUDIO2_WaitDone(_THIS) SDL_assert(!this->enabled); /* flag that stops playing. */ IXAudio2SourceVoice_Discontinuity(source); #if SDL_XAUDIO2_WIN8 - IXAudio2SourceVoice_GetState(source, &state, 0); + IXAudio2SourceVoice_GetState(source, &state, XAUDIO2_VOICE_NOSAMPLESPLAYED); #else IXAudio2SourceVoice_GetState(source, &state); #endif while (state.BuffersQueued > 0) { SDL_SemWait(this->hidden->semaphore); #if SDL_XAUDIO2_WIN8 - IXAudio2SourceVoice_GetState(source, &state, 0); + IXAudio2SourceVoice_GetState(source, &state, XAUDIO2_VOICE_NOSAMPLESPLAYED); #else IXAudio2SourceVoice_GetState(source, &state); #endif From e5d49c20331e85ad0a05999d5c6146e34c93f545 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 30 Jul 2014 11:08:31 -0400 Subject: [PATCH 13/17] Added a GetPendingBytes method to the audio backend. This will (eventually) make SDL_GetQueuedAudioSize() more accurate, and thus reduce latency. Right now this isn't implemented anywhere, so we assume data fed to the audio callback is consumed by the hardware and immediately played to completion. --- src/audio/SDL_audio.c | 9 ++++++++- src/audio/SDL_sysaudio.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index a788c89a2de83..804138c5bc8af 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -178,6 +178,12 @@ SDL_AudioPlayDevice_Default(_THIS) { /* no-op. */ } +static int +SDL_AudioGetPendingBytes_Default(_THIS) +{ + return 0; +} + static Uint8 * SDL_AudioGetDeviceBuf_Default(_THIS) { @@ -253,6 +259,7 @@ finalize_audio_entry_points(void) FILL_STUB(ThreadInit); FILL_STUB(WaitDevice); FILL_STUB(PlayDevice); + FILL_STUB(GetPendingBytes); FILL_STUB(GetDeviceBuf); FILL_STUB(WaitDone); FILL_STUB(CloseDevice); @@ -471,7 +478,7 @@ SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid) SDL_AudioDevice *device = get_audio_device(devid); if (device) { current_audio.impl.LockDevice(device); - retval = device->queued_bytes; + retval = device->queued_bytes + current_audio.impl.GetPendingBytes(device); current_audio.impl.UnlockDevice(device); } diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index c1810b4326647..4f933205d54ce 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -60,6 +60,7 @@ typedef struct SDL_AudioDriverImpl void (*ThreadInit) (_THIS); /* Called by audio thread at start */ void (*WaitDevice) (_THIS); void (*PlayDevice) (_THIS); + int (*GetPendingBytes) (_THIS); Uint8 *(*GetDeviceBuf) (_THIS); void (*WaitDone) (_THIS); void (*CloseDevice) (_THIS); From c5b21ea6c10defa5b22debdd56f46019f74c0a4e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 30 Jul 2014 11:11:48 -0400 Subject: [PATCH 14/17] SDL_GetQueuedAudioSize() shouldn't grab lock when not set up for queueing. --- src/audio/SDL_audio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 804138c5bc8af..7559d6ca46e80 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -472,11 +472,11 @@ SDL_QueueAudio(SDL_AudioDeviceID devid, const void *_data, Uint32 len) Uint32 SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid) { - /* this happens to work for non-queueing devices, since we memset() - the device to zero at init time, and these devices should return 0. */ Uint32 retval = 0; SDL_AudioDevice *device = get_audio_device(devid); - if (device) { + + /* Nothing to do unless we're set up for queueing. */ + if (device && (device->spec.callback == SDL_BufferQueueDrainCallback)) { current_audio.impl.LockDevice(device); retval = device->queued_bytes + current_audio.impl.GetPendingBytes(device); current_audio.impl.UnlockDevice(device); From c0f9a57f715f7237b5ea05ca079dd9fe84c3083f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 30 Jul 2014 14:12:54 -0400 Subject: [PATCH 15/17] Fixed comment typo. --- src/audio/xaudio2/SDL_xaudio2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index abcbdfb481856..6fef7f21935e0 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -58,7 +58,7 @@ /* The configure script already did any necessary checking */ # define SDL_XAUDIO2_HAS_SDK 1 #elif defined(__WINRT__) -/* WinRT always has access to the .the XAudio 2 SDK */ +/* WinRT always has access to the the XAudio 2 SDK */ # define SDL_XAUDIO2_HAS_SDK #else /* XAudio2 exists as of the March 2008 DirectX SDK From 5b780063e1d96930279bef3d17e3f58f8e6469c0 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 30 Jul 2014 14:14:19 -0400 Subject: [PATCH 16/17] Make SDL_SysWMinfo usable on Mac/iOS with ARC enabled (thanks, Alex!). Fixes Bugzilla #2641. --- include/SDL_syswm.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 715f2c0583a13..c81cd48decba5 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -208,13 +208,21 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_COCOA) struct { - NSWindow *window; /* The Cocoa window */ +#if defined(__OBJC__) && __has_feature(objc_arc) + NSWindow __unsafe_unretained *window; /* The Cocoa window */ +#else + NSWindow *window; /* The Cocoa window */ +#endif } cocoa; #endif #if defined(SDL_VIDEO_DRIVER_UIKIT) struct { - UIWindow *window; /* The UIKit window */ +#if defined(__OBJC__) && __has_feature(objc_arc) + UIWindow __unsafe_unretained *window; /* The UIKit window */ +#else + UIWindow *window; /* The UIKit window */ +#endif } uikit; #endif #if defined(SDL_VIDEO_DRIVER_WAYLAND) From 75529476541b141f9884a5a119cfc76f5acf0e9d Mon Sep 17 00:00:00 2001 From: Alfred Reynolds Date: Wed, 30 Jul 2014 17:45:52 -0700 Subject: [PATCH 17/17] SDL - fix re-entrancy into SDL_UpdateFullscreenMode under OSX. During HideWindow we get a RESTORED event which then turns fullscreen back on causing a hang in Cocoa_SetWindowFullscreenSpace waiting for the fullscreen transition to finish. --- src/video/SDL_sysvideo.h | 1 + src/video/SDL_video.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 992b4f364004c..f552cb5b9960a 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -93,6 +93,7 @@ struct SDL_Window SDL_Surface *surface; SDL_bool surface_valid; + SDL_bool is_hiding; SDL_bool is_destroying; SDL_WindowShaper *shaper; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index e50edc1bd8d08..0c92a872da3fc 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1105,6 +1105,10 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) CHECK_WINDOW_MAGIC(window,); + /* if we are in the process of hiding don't go back to fullscreen */ + if ( window->is_hiding && fullscreen ) + return; + #ifdef __MACOSX__ if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) { window->last_fullscreen_flags = window->flags; @@ -1833,11 +1837,13 @@ SDL_HideWindow(SDL_Window * window) return; } + window->is_hiding = SDL_TRUE; SDL_UpdateFullscreenMode(window, SDL_FALSE); if (_this->HideWindow) { _this->HideWindow(_this, window); } + window->is_hiding = SDL_FALSE; SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIDDEN, 0, 0); }