Skip to content

Commit

Permalink
audio: Fixed SDL_AudioStreamGet() function parameters.
Browse files Browse the repository at this point in the history
There was a draft of this where it did audio conversion into the final buffer,
if there was enough room available past what you asked for, but that interface
got removed, so the parameters didn't make sense (and we were using the
wrong one in any case, too!).
  • Loading branch information
icculus committed Jan 6, 2017
1 parent 99fc1ef commit 992124d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/audio/SDL_audio.c
Expand Up @@ -605,7 +605,7 @@ SDL_RunAudio(void *devicep)
SDL_Delay(delay);
break;
} else {
const int got = SDL_AudioStreamGet(device->stream, device->spec.size, stream, device->spec.size);
const int got = SDL_AudioStreamGet(device->stream, stream, device->spec.size);
SDL_assert((got < 0) || (got == device->spec.size));
if (got != device->spec.size) {
SDL_memset(stream, device->spec.silence, device->spec.size);
Expand Down Expand Up @@ -702,7 +702,7 @@ 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->callbackspec.size, device->fake_stream, device->fake_stream_len);
const int got = SDL_AudioStreamGet(device->stream, device->fake_stream, 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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/SDL_audio_c.h
Expand Up @@ -87,7 +87,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, const Uint32 len);

/* get converted/resampled data from the stream */
int SDL_AudioStreamGet(SDL_AudioStream *stream, Uint32 len, void *buf, const Uint32 buflen);
int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, const Uint32 len);

/* clear any pending data in the stream without converting it. */
void SDL_AudioStreamClear(SDL_AudioStream *stream);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/SDL_audiocvt.c
Expand Up @@ -832,7 +832,7 @@ SDL_AudioStreamClear(SDL_AudioStream *stream)

/* get converted/resampled data from the stream */
int
SDL_AudioStreamGet(SDL_AudioStream *stream, Uint32 len, void *buf, const Uint32 buflen)
SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, const Uint32 len)
{
if (!stream) {
return SDL_InvalidParamError("stream");
Expand All @@ -844,7 +844,7 @@ SDL_AudioStreamGet(SDL_AudioStream *stream, Uint32 len, void *buf, const Uint32
return SDL_SetError("Can't request partial sample frames");
}

return (int) SDL_ReadFromDataQueue(stream->queue, buf, buflen);
return (int) SDL_ReadFromDataQueue(stream->queue, buf, len);
}

/* number of converted/resampled bytes available */
Expand Down
4 changes: 2 additions & 2 deletions src/audio/emscripten/SDL_emscriptenaudio.c
Expand Up @@ -77,7 +77,7 @@ HandleAudioProcess(_THIS)
}
}

got = SDL_AudioStreamGet(this->stream, this->spec.size, this->fake_stream, this->spec.size);
got = SDL_AudioStreamGet(this->stream, this->fake_stream, 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);
Expand Down Expand Up @@ -130,7 +130,7 @@ HandleCaptureProcess(_THIS)
}

while (SDL_AudioStreamAvailable(this->stream) >= stream_len) {
const int got = SDL_AudioStreamGet(this->stream, stream_len, this->fake_stream, stream_len);
const int got = SDL_AudioStreamGet(this->stream, this->fake_stream, stream_len);
SDL_assert((got < 0) || (got == stream_len));
if (got != stream_len) {
SDL_memset(this->fake_stream, this->callbackspec.silence, stream_len);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/haiku/SDL_haikuaudio.cc
Expand Up @@ -77,7 +77,7 @@ FillSound(void *device, void *stream, size_t len,
}
}

const int got = SDL_AudioStreamGet(audio->stream, ilen, stream, ilen);
const int got = SDL_AudioStreamGet(audio->stream, stream, ilen);
SDL_assert((got < 0) || (got == ilen));
if (got != ilen) {
SDL_memset(stream, audio->spec.silence, len);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/nacl/SDL_naclaudio.c
Expand Up @@ -78,7 +78,7 @@ static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta
}
}

const int got = SDL_AudioStreamGet(_this->stream, len, stream, len);
const int got = SDL_AudioStreamGet(_this->stream, stream, len);
SDL_assert((got < 0) || (got == len));
if (got != len) {
SDL_memset(stream, _this->spec.silence, len);
Expand Down

0 comments on commit 992124d

Please sign in to comment.