Skip to content
Permalink
Browse files

audio: Only allocate fake_stream if we're using the standard audio th…

…reads.
  • Loading branch information
icculus committed Aug 9, 2016
1 parent be8d7a4 commit a05bde217000c628ffb16100b8f1a507a118ecb7
Showing with 14 additions and 14 deletions.
  1. +14 −14 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];

0 comments on commit a05bde2

Please sign in to comment.