audio: rename fake_stream to work_buffer. It's more than an alternative for when the OS can't provide a DMA buffer, now.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 938e2b7..4dc3cf2 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -568,16 +568,16 @@ SDL_RunAudio(void *devicep)
stream = current_audio.impl.GetDeviceBuf(device);
} else {
/* if the device isn't enabled, we still write to the
- fake_stream, so the app's callback will fire with
+ work_buffer, so the app's callback will fire with
a regular frequency, in case they depend on that
for timing or progress. They can use hotplug
now to know if the device failed.
- Streaming playback uses fake_stream as a work buffer, too. */
+ Streaming playback uses work_buffer, too. */
stream = NULL;
}
if (stream == NULL) {
- stream = device->fake_stream;
+ stream = device->work_buffer;
}
if ( SDL_AtomicGet(&device->enabled) ) {
@@ -614,7 +614,7 @@ SDL_RunAudio(void *devicep)
current_audio.impl.WaitDevice(device);
}
}
- } else if (stream == device->fake_stream) {
+ } else if (stream == device->work_buffer) {
/* nothing to do; pause like we queued a buffer to play. */
SDL_Delay(delay);
} else { /* writing directly to the device. */
@@ -670,8 +670,8 @@ SDL_CaptureAudio(void *devicep)
/* Fill the current buffer with sound */
still_need = stream_len;
- /* just use the "fake" stream to hold data read from the device. */
- stream = device->fake_stream;
+ /* Use the work_buffer to hold data read from the device. */
+ stream = device->work_buffer;
SDL_assert(stream != NULL);
ptr = stream;
@@ -702,16 +702,16 @@ SDL_CaptureAudio(void *devicep)
SDL_AudioStreamPut(device->stream, stream, stream_len);
while (SDL_AudioStreamAvailable(device->stream) >= ((int) device->callbackspec.size)) {
- const int got = SDL_AudioStreamGet(device->stream, device->fake_stream, device->callbackspec.size);
+ const int got = SDL_AudioStreamGet(device->stream, device->work_buffer, device->callbackspec.size);
SDL_assert((got < 0) || (got == device->callbackspec.size));
if (got != device->callbackspec.size) {
- SDL_memset(device->fake_stream, device->spec.silence, device->callbackspec.size);
+ SDL_memset(device->work_buffer, device->spec.silence, device->callbackspec.size);
}
/* !!! FIXME: this should be LockDevice. */
SDL_LockMutex(device->mixer_lock);
if (!SDL_AtomicGet(&device->paused)) {
- callback(udata, device->fake_stream, device->callbackspec.size);
+ callback(udata, device->work_buffer, device->callbackspec.size);
}
SDL_UnlockMutex(device->mixer_lock);
}
@@ -958,7 +958,7 @@ close_audio_device(SDL_AudioDevice * device)
SDL_DestroyMutex(device->mixer_lock);
}
- SDL_free(device->fake_stream);
+ SDL_free(device->work_buffer);
SDL_FreeAudioStream(device->stream);
if (device->hidden != NULL) {
@@ -1243,16 +1243,15 @@ open_audio_device(const char *devname, int iscapture,
device->spec.userdata = device;
}
- /* !!! FIXME: rename this from fake_stream */
/* Allocate a scratch audio buffer */
- device->fake_stream_len = build_stream ? device->callbackspec.size : 0;
- if (device->spec.size > device->fake_stream_len) {
- device->fake_stream_len = device->spec.size;
+ device->work_buffer_len = build_stream ? device->callbackspec.size : 0;
+ if (device->spec.size > device->work_buffer_len) {
+ device->work_buffer_len = device->spec.size;
}
- SDL_assert(device->fake_stream_len > 0);
+ SDL_assert(device->work_buffer_len > 0);
- device->fake_stream = (Uint8 *) SDL_malloc(device->fake_stream_len);
- if (device->fake_stream == NULL) {
+ device->work_buffer = (Uint8 *) SDL_malloc(device->work_buffer_len);
+ if (device->work_buffer == NULL) {
close_audio_device(device);
SDL_OutOfMemory();
return 0;
diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
index e62aecf..ca93eb2 100644
--- a/src/audio/SDL_sysaudio.h
+++ b/src/audio/SDL_sysaudio.h
@@ -146,11 +146,11 @@ struct SDL_AudioDevice
SDL_atomic_t paused;
SDL_bool iscapture;
- /* Fake audio buffer for when the audio hardware is busy */
- Uint8 *fake_stream;
+ /* Scratch buffer used in the bridge between SDL and the user callback. */
+ Uint8 *work_buffer;
- /* Size, in bytes, of fake_stream. */
- Uint32 fake_stream_len;
+ /* Size, in bytes, of work_buffer. */
+ Uint32 work_buffer_len;
/* A mutex for locking the mixing buffers */
SDL_mutex *mixer_lock;
diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c
index f920de8..8d09c3f 100644
--- a/src/audio/emscripten/SDL_emscriptenaudio.c
+++ b/src/audio/emscripten/SDL_emscriptenaudio.c
@@ -65,26 +65,26 @@ HandleAudioProcess(_THIS)
if (this->stream == NULL) { /* no conversion necessary. */
SDL_assert(this->spec.size == stream_len);
- callback(this->spec.userdata, this->fake_stream, stream_len);
+ callback(this->spec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */
int got;
while (SDL_AudioStreamAvailable(this->stream) < ((int) this->spec.size)) {
- callback(this->spec.userdata, this->fake_stream, stream_len);
- if (SDL_AudioStreamPut(this->stream, this->fake_stream, stream_len) == -1) {
+ callback(this->spec.userdata, this->work_buffer, stream_len);
+ if (SDL_AudioStreamPut(this->stream, this->work_buffer, stream_len) == -1) {
SDL_AudioStreamClear(this->stream);
SDL_AtomicSet(&this->enabled, 0);
break;
}
}
- got = SDL_AudioStreamGet(this->stream, this->fake_stream, this->spec.size);
+ got = SDL_AudioStreamGet(this->stream, this->work_buffer, this->spec.size);
SDL_assert((got < 0) || (got == this->spec.size));
if (got != this->spec.size) {
- SDL_memset(this->fake_stream, this->spec.silence, this->spec.size);
+ SDL_memset(this->work_buffer, this->spec.silence, this->spec.size);
}
}
- FeedAudioDevice(this, this->fake_stream, this->spec.size);
+ FeedAudioDevice(this, this->work_buffer, this->spec.size);
}
static void
@@ -117,25 +117,25 @@ HandleCaptureProcess(_THIS)
}
}
}
- }, this->fake_stream, (this->spec.size / sizeof (float)) / this->spec.channels);
+ }, this->work_buffer, (this->spec.size / sizeof (float)) / this->spec.channels);
/* okay, we've got an interleaved float32 array in C now. */
if (this->stream == NULL) { /* no conversion necessary. */
SDL_assert(this->spec.size == stream_len);
- callback(this->spec.userdata, this->fake_stream, stream_len);
+ callback(this->spec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */
- if (SDL_AudioStreamPut(this->stream, this->fake_stream, this->spec.size) == -1) {
+ if (SDL_AudioStreamPut(this->stream, this->work_buffer, this->spec.size) == -1) {
SDL_AtomicSet(&this->enabled, 0);
}
while (SDL_AudioStreamAvailable(this->stream) >= stream_len) {
- const int got = SDL_AudioStreamGet(this->stream, this->fake_stream, stream_len);
+ const int got = SDL_AudioStreamGet(this->stream, this->work_buffer, stream_len);
SDL_assert((got < 0) || (got == stream_len));
if (got != stream_len) {
- SDL_memset(this->fake_stream, this->callbackspec.silence, stream_len);
+ SDL_memset(this->work_buffer, this->callbackspec.silence, stream_len);
}
- callback(this->spec.userdata, this->fake_stream, stream_len); /* Send it to the app. */
+ callback(this->spec.userdata, this->work_buffer, stream_len); /* Send it to the app. */
}
}
}
diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc
index 01d1c4c..b8a7d1a 100644
--- a/src/audio/haiku/SDL_haikuaudio.cc
+++ b/src/audio/haiku/SDL_haikuaudio.cc
@@ -69,8 +69,8 @@ FillSound(void *device, void *stream, size_t len,
const int stream_len = audio->callbackspec.size;
const int ilen = (int) len;
while (SDL_AudioStreamAvailable(audio->stream) < ilen) {
- callback(audio->spec.userdata, audio->fake_stream, stream_len);
- if (SDL_AudioStreamPut(audio->stream, audio->fake_stream, stream_len) == -1) {
+ callback(audio->spec.userdata, audio->work_buffer, stream_len);
+ if (SDL_AudioStreamPut(audio->stream, audio->work_buffer, stream_len) == -1) {
SDL_AudioStreamClear(audio->stream);
SDL_AtomicSet(&audio->enabled, 0);
break;
diff --git a/src/audio/nacl/SDL_naclaudio.c b/src/audio/nacl/SDL_naclaudio.c
index 31aba7e..5b3b429 100644
--- a/src/audio/nacl/SDL_naclaudio.c
+++ b/src/audio/nacl/SDL_naclaudio.c
@@ -70,8 +70,8 @@ static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta
} else { /* streaming/converting */
const int stream_len = _this->callbackspec.size;
while (SDL_AudioStreamAvailable(_this->stream) < len) {
- callback(_this->spec.userdata, _this->fake_stream, stream_len);
- if (SDL_AudioStreamPut(_this->stream, _this->fake_stream, stream_len) == -1) {
+ callback(_this->spec.userdata, _this->work_buffer, stream_len);
+ if (SDL_AudioStreamPut(_this->stream, _this->work_buffer, stream_len) == -1) {
SDL_AudioStreamClear(_this->stream);
SDL_AtomicSet(&_this->enabled, 0);
break;