audio: Only allocate fake_stream if we're using the standard audio threads.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index ec65d0c..6456389 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1149,7 +1149,6 @@ open_audio_device(const char *devname, int iscapture,
SDL_AudioDevice *device;
SDL_bool build_cvt;
void *handle = NULL;
- Uint32 stream_len;
int i = 0;
if (!SDL_WasInit(SDL_INIT_AUDIO)) {
@@ -1338,19 +1337,6 @@ open_audio_device(const char *devname, int iscapture,
}
}
- /* Allocate a fake audio memory buffer */
- stream_len = (device->convert.needed) ? device->convert.len_cvt : 0;
- if (device->spec.size > stream_len) {
- stream_len = device->spec.size;
- }
- SDL_assert(stream_len > 0);
- device->fake_stream = (Uint8 *) SDL_malloc(stream_len);
- if (device->fake_stream == NULL) {
- close_audio_device(device);
- SDL_OutOfMemory();
- return 0;
- }
-
if (device->spec.callback == NULL) { /* use buffer queueing? */
/* pool a few packets to start. Enough for two callbacks. */
const int packetlen = SDL_AUDIOBUFFERQUEUE_PACKETLEN;
@@ -1377,6 +1363,20 @@ open_audio_device(const char *devname, int iscapture,
if (!current_audio.impl.ProvidesOwnCallbackThread) {
/* Start the audio thread */
+ /* Allocate a fake audio buffer; only used by our internal threads. */
+ Uint32 stream_len = (device->convert.needed) ? device->convert.len_cvt : 0;
+ if (device->spec.size > stream_len) {
+ stream_len = device->spec.size;
+ }
+ SDL_assert(stream_len > 0);
+
+ device->fake_stream = (Uint8 *) SDL_malloc(stream_len);
+ if (device->fake_stream == NULL) {
+ close_audio_device(device);
+ SDL_OutOfMemory();
+ return 0;
+ }
+
/* !!! 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];