SDL API renaming: SDL_audio.h

Fixes https://github.com/libsdl-org/SDL/issues/6879
main
Sam Lantinga 2022-12-27 05:32:55 -08:00
parent 9625fb2832
commit 713ba2e31a
14 changed files with 159 additions and 129 deletions

View File

@ -17,6 +17,13 @@ General:
* RW_SEEK_SET -> SDL_RW_SEEK_SET
* SDL_FreeWAV has been removed and calls can be replaced with SDL_free
* The following functions have been renamed:
* SDL_AudioStreamAvailable => SDL_GetAudioStreamAvailable
* SDL_AudioStreamClear => SDL_ClearAudioStream
* SDL_AudioStreamFlush => SDL_FlushAudioStream
* SDL_AudioStreamGet => SDL_GetAudioStreamData
* SDL_AudioStreamPut => SDL_PutAudioStreamData
* SDL_FreeAudioStream => SDL_DestroyAudioStream
* SDL_NewAudioStream => SDL_CreateAudioStream
* Removed the following functions from the API, see docs/README-migration.md for details:
* SDL_AudioInit()
* SDL_AudioQuit()

View File

@ -46,6 +46,15 @@ SDL_AudioInit() and SDL_AudioQuit() have been removed. Instead you can call SDL_
SDL_FreeWAV has been removed and calls can be replaced with SDL_free.
The following functions have been renamed:
* SDL_AudioStreamAvailable => SDL_GetAudioStreamAvailable
* SDL_AudioStreamClear => SDL_ClearAudioStream
* SDL_AudioStreamFlush => SDL_FlushAudioStream
* SDL_AudioStreamGet => SDL_GetAudioStreamData
* SDL_AudioStreamPut => SDL_PutAudioStreamData
* SDL_FreeAudioStream => SDL_DestroyAudioStream
* SDL_NewAudioStream => SDL_CreateAudioStream
## SDL_cpuinfo.h
SDL_Has3DNow() has been removed; there is no replacement.

View File

@ -941,14 +941,14 @@ typedef struct _SDL_AudioStream SDL_AudioStream;
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
* \sa SDL_PutAudioStreamData
* \sa SDL_GetAudioStreamData
* \sa SDL_GetAudioStreamAvailable
* \sa SDL_FlushAudioStream
* \sa SDL_ClearAudioStream
* \sa SDL_DestroyAudioStream
*/
extern DECLSPEC SDL_AudioStream *SDLCALL SDL_NewAudioStream(SDL_AudioFormat src_format,
extern DECLSPEC SDL_AudioStream *SDLCALL SDL_CreateAudioStream(SDL_AudioFormat src_format,
Uint8 src_channels,
int src_rate,
SDL_AudioFormat dst_format,
@ -965,14 +965,14 @@ extern DECLSPEC SDL_AudioStream *SDLCALL SDL_NewAudioStream(SDL_AudioFormat src_
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
* \sa SDL_CreateAudioStream
* \sa SDL_GetAudioStreamData
* \sa SDL_GetAudioStreamAvailable
* \sa SDL_FlushAudioStream
* \sa SDL_ClearAudioStream
* \sa SDL_DestroyAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len);
extern DECLSPEC int SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len);
/**
* Get converted/resampled data from the stream
@ -984,14 +984,14 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const vo
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
* \sa SDL_CreateAudioStream
* \sa SDL_PutAudioStreamData
* \sa SDL_GetAudioStreamAvailable
* \sa SDL_FlushAudioStream
* \sa SDL_ClearAudioStream
* \sa SDL_DestroyAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len);
extern DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len);
/**
* Get the number of converted/resampled bytes available.
@ -1002,14 +1002,14 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *bu
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
* \sa SDL_CreateAudioStream
* \sa SDL_PutAudioStreamData
* \sa SDL_GetAudioStreamData
* \sa SDL_FlushAudioStream
* \sa SDL_ClearAudioStream
* \sa SDL_DestroyAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream);
extern DECLSPEC int SDLCALL SDL_GetAudioStreamAvailable(SDL_AudioStream *stream);
/**
* Tell the stream that you're done sending data, and anything being buffered
@ -1021,42 +1021,42 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream);
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
* \sa SDL_CreateAudioStream
* \sa SDL_PutAudioStreamData
* \sa SDL_GetAudioStreamData
* \sa SDL_GetAudioStreamAvailable
* \sa SDL_ClearAudioStream
* \sa SDL_DestroyAudioStream
*/
extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream);
extern DECLSPEC int SDLCALL SDL_FlushAudioStream(SDL_AudioStream *stream);
/**
* Clear any pending data in the stream without converting it
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_FreeAudioStream
* \sa SDL_CreateAudioStream
* \sa SDL_PutAudioStreamData
* \sa SDL_GetAudioStreamData
* \sa SDL_GetAudioStreamAvailable
* \sa SDL_FlushAudioStream
* \sa SDL_DestroyAudioStream
*/
extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
extern DECLSPEC void SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
/**
* Free an audio stream
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_CreateAudioStream
* \sa SDL_PutAudioStreamData
* \sa SDL_GetAudioStreamData
* \sa SDL_GetAudioStreamAvailable
* \sa SDL_FlushAudioStream
* \sa SDL_ClearAudioStream
*/
extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
extern DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream);
#define SDL_MIX_MAXVOLUME 128

View File

@ -40,7 +40,14 @@
#ifdef SDL_ENABLE_OLD_NAMES
/* ##SDL_audio.h */
#define SDL_AudioStreamAvailable SDL_GetAudioStreamAvailable
#define SDL_AudioStreamClear SDL_ClearAudioStream
#define SDL_AudioStreamFlush SDL_FlushAudioStream
#define SDL_AudioStreamGet SDL_GetAudioStreamData
#define SDL_AudioStreamPut SDL_PutAudioStreamData
#define SDL_FreeAudioStream SDL_DestroyAudioStream
#define SDL_FreeWAV SDL_free
#define SDL_NewAudioStream SDL_CreateAudioStream
/* ##SDL_keycode.h */
#define KMOD_ALT SDL_KMOD_ALT
@ -78,7 +85,14 @@
#else /* !SDL_ENABLE_OLD_NAMES */
/* ##SDL_audio.h */
#define SDL_AudioStreamAvailable SDL_AudioStreamAvailable_renamed_SDL_GetAudioStreamAvailable
#define SDL_AudioStreamClear SDL_AudioStreamClear_renamed_SDL_ClearAudioStream
#define SDL_AudioStreamFlush SDL_AudioStreamFlush_renamed_SDL_FlushAudioStream
#define SDL_AudioStreamGet SDL_AudioStreamGet_renamed_SDL_GetAudioStreamData
#define SDL_AudioStreamPut SDL_AudioStreamPut_renamed_SDL_PutAudioStreamData
#define SDL_FreeAudioStream SDL_FreeAudioStream_renamed_SDL_DestroyAudioStream
#define SDL_FreeWAV SDL_FreeWAV_renamed_SDL_free
#define SDL_NewAudioStream SDL_NewAudioStream_renamed_SDL_CreateAudioStream
/* ##SDL_keycode.h */
#define KMOD_ALT KMOD_ALT_renamed_SDL_KMOD_ALT

View File

@ -689,12 +689,12 @@ static int SDLCALL SDL_RunAudio(void *devicep)
if (device->stream) {
/* Stream available audio to device, converting/resampling. */
/* if this fails...oh well. We'll play silence here. */
SDL_AudioStreamPut(device->stream, data, data_len);
SDL_PutAudioStreamData(device->stream, data, data_len);
while (SDL_AudioStreamAvailable(device->stream) >= ((int)device->spec.size)) {
while (SDL_GetAudioStreamAvailable(device->stream) >= ((int)device->spec.size)) {
int got;
data = SDL_AtomicGet(&device->enabled) ? current_audio.impl.GetDeviceBuf(device) : NULL;
got = SDL_AudioStreamGet(device->stream, data ? data : device->work_buffer, device->spec.size);
got = SDL_GetAudioStreamData(device->stream, data ? data : device->work_buffer, device->spec.size);
SDL_assert((got <= 0) || (got == device->spec.size));
if (data == NULL) { /* device is having issues... */
@ -763,7 +763,7 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
if (SDL_AtomicGet(&device->paused)) {
SDL_Delay(delay); /* just so we don't cook the CPU. */
if (device->stream) {
SDL_AudioStreamClear(device->stream);
SDL_ClearAudioStream(device->stream);
}
current_audio.impl.FlushCapture(device); /* dump anything pending. */
continue;
@ -805,10 +805,10 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
if (device->stream) {
/* if this fails...oh well. */
SDL_AudioStreamPut(device->stream, data, data_len);
SDL_PutAudioStreamData(device->stream, data, data_len);
while (SDL_AudioStreamAvailable(device->stream) >= ((int)device->callbackspec.size)) {
const int got = SDL_AudioStreamGet(device->stream, device->work_buffer, device->callbackspec.size);
while (SDL_GetAudioStreamAvailable(device->stream) >= ((int)device->callbackspec.size)) {
const int got = SDL_GetAudioStreamData(device->stream, device->work_buffer, device->callbackspec.size);
SDL_assert((got < 0) || (got == device->callbackspec.size));
if (got != device->callbackspec.size) {
SDL_memset(device->work_buffer, device->spec.silence, device->callbackspec.size);
@ -1138,7 +1138,7 @@ static void close_audio_device(SDL_AudioDevice *device)
}
SDL_free(device->work_buffer);
SDL_FreeAudioStream(device->stream);
SDL_DestroyAudioStream(device->stream);
if (device->id > 0) {
SDL_AudioDevice *opendev = open_devices[device->id - 1];
@ -1423,11 +1423,11 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
if (build_stream) {
if (iscapture) {
device->stream = SDL_NewAudioStream(device->spec.format,
device->stream = SDL_CreateAudioStream(device->spec.format,
device->spec.channels, device->spec.freq,
obtained->format, obtained->channels, obtained->freq);
} else {
device->stream = SDL_NewAudioStream(obtained->format, obtained->channels,
device->stream = SDL_CreateAudioStream(obtained->format, obtained->channels,
obtained->freq, device->spec.format,
device->spec.channels, device->spec.freq);
}

View File

@ -892,7 +892,7 @@ static int SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inb
SRC_DATA data;
int result;
SDL_assert(inbuf != ((const float *)outbuf)); /* SDL_AudioStreamPut() shouldn't allow in-place resamples. */
SDL_assert(inbuf != ((const float *)outbuf)); /* SDL_PutAudioStreamData() shouldn't allow in-place resamples. */
data.data_in = (float *)inbuf; /* Older versions of libsamplerate had a non-const pointer, but didn't write to it */
data.input_frames = inbuflen / framelen;
@ -975,7 +975,7 @@ static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf,
const int cpy = SDL_min(inbuflen, paddingbytes);
int retval;
SDL_assert(inbuf != ((const float *)outbuf)); /* SDL_AudioStreamPut() shouldn't allow in-place resamples. */
SDL_assert(inbuf != ((const float *)outbuf)); /* SDL_PutAudioStreamData() shouldn't allow in-place resamples. */
retval = SDL_ResampleAudio(chans, inrate, outrate, lpadding, rpadding, inbuf, inbuflen, outbuf, outbuflen);
@ -997,7 +997,7 @@ static void SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream)
}
SDL_AudioStream *
SDL_NewAudioStream(SDL_AudioFormat src_format,
SDL_CreateAudioStream(SDL_AudioFormat src_format,
Uint8 src_channels,
int src_rate,
SDL_AudioFormat dst_format,
@ -1036,7 +1036,7 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float));
if (retval->resampler_padding == NULL) {
SDL_FreeAudioStream(retval);
SDL_DestroyAudioStream(retval);
SDL_OutOfMemory();
return NULL;
}
@ -1045,7 +1045,7 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
if (retval->staging_buffer_size > 0) {
retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size);
if (retval->staging_buffer == NULL) {
SDL_FreeAudioStream(retval);
SDL_DestroyAudioStream(retval);
SDL_OutOfMemory();
return NULL;
}
@ -1055,14 +1055,14 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
if (src_rate == dst_rate) {
retval->cvt_before_resampling.needed = SDL_FALSE;
if (SDL_BuildAudioCVT(&retval->cvt_after_resampling, src_format, src_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) {
SDL_FreeAudioStream(retval);
SDL_DestroyAudioStream(retval);
return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */
}
} else {
/* Don't resample at first. Just get us to Float32 format. */
/* !!! FIXME: convert to int32 on devices without hardware float. */
if (SDL_BuildAudioCVT(&retval->cvt_before_resampling, src_format, src_channels, src_rate, AUDIO_F32SYS, pre_resample_channels, src_rate) < 0) {
SDL_FreeAudioStream(retval);
SDL_DestroyAudioStream(retval);
return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */
}
@ -1073,7 +1073,7 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
if (!retval->resampler_func) {
retval->resampler_state = SDL_calloc(retval->resampler_padding_samples, sizeof(float));
if (!retval->resampler_state) {
SDL_FreeAudioStream(retval);
SDL_DestroyAudioStream(retval);
SDL_OutOfMemory();
return NULL;
}
@ -1085,14 +1085,14 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
/* Convert us to the final format after resampling. */
if (SDL_BuildAudioCVT(&retval->cvt_after_resampling, AUDIO_F32SYS, pre_resample_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) {
SDL_FreeAudioStream(retval);
SDL_DestroyAudioStream(retval);
return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */
}
}
retval->queue = SDL_NewDataQueue(packetlen, (size_t)packetlen * 2);
if (!retval->queue) {
SDL_FreeAudioStream(retval);
SDL_DestroyAudioStream(retval);
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */
}
@ -1228,7 +1228,7 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf,
return buflen ? SDL_WriteToDataQueue(stream->queue, resamplebuf, buflen) : 0;
}
int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
{
/* !!! FIXME: several converters can take advantage of SIMD, but only
!!! FIXME: if the data is aligned to 16 bytes. EnsureStreamBufferSize()
@ -1295,7 +1295,7 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
return 0;
}
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
int SDL_FlushAudioStream(SDL_AudioStream *stream)
{
if (stream == NULL) {
return SDL_InvalidParamError("stream");
@ -1349,7 +1349,7 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream)
}
/* get converted/resampled data from the stream */
int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *buf, int len)
{
#if DEBUG_AUDIOSTREAM
SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len);
@ -1372,12 +1372,12 @@ int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
}
/* number of converted/resampled bytes available */
int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
int SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
{
return stream ? (int)SDL_CountDataQueue(stream->queue) : 0;
}
void SDL_AudioStreamClear(SDL_AudioStream *stream)
void SDL_ClearAudioStream(SDL_AudioStream *stream)
{
if (stream == NULL) {
SDL_InvalidParamError("stream");
@ -1392,7 +1392,7 @@ void SDL_AudioStreamClear(SDL_AudioStream *stream)
}
/* dispose of a stream */
void SDL_FreeAudioStream(SDL_AudioStream *stream)
void SDL_DestroyAudioStream(SDL_AudioStream *stream)
{
if (stream) {
if (stream->cleanup_resampler_func) {

View File

@ -535,20 +535,20 @@ static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe
Uint8 *ptr = (Uint8 *)inBuffer->mAudioData;
while (remaining > 0) {
if (SDL_AudioStreamAvailable(this->stream) == 0) {
if (SDL_GetAudioStreamAvailable(this->stream) == 0) {
/* Generate the data */
(*this->callbackspec.callback)(this->callbackspec.userdata,
this->hidden->buffer, this->hidden->bufferSize);
this->hidden->bufferOffset = 0;
SDL_AudioStreamPut(this->stream, this->hidden->buffer, this->hidden->bufferSize);
SDL_PutAudioStreamData(this->stream, this->hidden->buffer, this->hidden->bufferSize);
}
if (SDL_AudioStreamAvailable(this->stream) > 0) {
if (SDL_GetAudioStreamAvailable(this->stream) > 0) {
int got;
UInt32 len = SDL_AudioStreamAvailable(this->stream);
UInt32 len = SDL_GetAudioStreamAvailable(this->stream);
if (len > remaining) {
len = remaining;
}
got = SDL_AudioStreamGet(this->stream, ptr, len);
got = SDL_GetAudioStreamData(this->stream, ptr, len);
SDL_assert((got < 0) || (got == len));
if (got != len) {
SDL_memset(ptr, this->spec.silence, len);

View File

@ -61,7 +61,7 @@ static void HandleAudioProcess(_THIS)
/* Only do something if audio is enabled */
if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
if (this->stream) {
SDL_AudioStreamClear(this->stream);
SDL_ClearAudioStream(this->stream);
}
SDL_memset(this->work_buffer, this->spec.silence, this->spec.size);
@ -74,16 +74,16 @@ static void HandleAudioProcess(_THIS)
callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */
int got;
while (SDL_AudioStreamAvailable(this->stream) < ((int)this->spec.size)) {
while (SDL_GetAudioStreamAvailable(this->stream) < ((int)this->spec.size)) {
callback(this->callbackspec.userdata, this->work_buffer, stream_len);
if (SDL_AudioStreamPut(this->stream, this->work_buffer, stream_len) == -1) {
SDL_AudioStreamClear(this->stream);
if (SDL_PutAudioStreamData(this->stream, this->work_buffer, stream_len) == -1) {
SDL_ClearAudioStream(this->stream);
SDL_AtomicSet(&this->enabled, 0);
break;
}
}
got = SDL_AudioStreamGet(this->stream, this->work_buffer, this->spec.size);
got = SDL_GetAudioStreamData(this->stream, this->work_buffer, this->spec.size);
SDL_assert((got < 0) || (got == this->spec.size));
if (got != this->spec.size) {
SDL_memset(this->work_buffer, this->spec.silence, this->spec.size);
@ -100,7 +100,7 @@ static void HandleCaptureProcess(_THIS)
/* Only do something if audio is enabled */
if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
SDL_AudioStreamClear(this->stream);
SDL_ClearAudioStream(this->stream);
return;
}
@ -133,12 +133,12 @@ static void HandleCaptureProcess(_THIS)
SDL_assert(this->spec.size == stream_len);
callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */
if (SDL_AudioStreamPut(this->stream, this->work_buffer, this->spec.size) == -1) {
if (SDL_PutAudioStreamData(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->work_buffer, stream_len);
while (SDL_GetAudioStreamAvailable(this->stream) >= stream_len) {
const int got = SDL_GetAudioStreamData(this->stream, this->work_buffer, stream_len);
SDL_assert((got < 0) || (got == stream_len));
if (got != stream_len) {
SDL_memset(this->work_buffer, this->callbackspec.silence, stream_len);

View File

@ -52,7 +52,7 @@ static void FillSound(void *device, void *stream, size_t len,
/* Only do something if audio is enabled */
if (!SDL_AtomicGet(&audio->enabled) || SDL_AtomicGet(&audio->paused)) {
if (audio->stream) {
SDL_AudioStreamClear(audio->stream);
SDL_ClearAudioStream(audio->stream);
}
SDL_memset(stream, audio->spec.silence, len);
} else {
@ -63,16 +63,16 @@ static void FillSound(void *device, void *stream, size_t len,
} else { /* streaming/converting */
const int stream_len = audio->callbackspec.size;
const int ilen = (int) len;
while (SDL_AudioStreamAvailable(audio->stream) < ilen) {
while (SDL_GetAudioStreamAvailable(audio->stream) < ilen) {
callback(audio->callbackspec.userdata, audio->work_buffer, stream_len);
if (SDL_AudioStreamPut(audio->stream, audio->work_buffer, stream_len) == -1) {
SDL_AudioStreamClear(audio->stream);
if (SDL_PutAudioStreamData(audio->stream, audio->work_buffer, stream_len) == -1) {
SDL_ClearAudioStream(audio->stream);
SDL_AtomicSet(&audio->enabled, 0);
break;
}
}
const int got = SDL_AudioStreamGet(audio->stream, stream, ilen);
const int got = SDL_GetAudioStreamData(audio->stream, stream, ilen);
SDL_assert((got < 0) || (got == ilen));
if (got != ilen) {
SDL_memset(stream, audio->spec.silence, len);

View File

@ -988,12 +988,12 @@ static void output_callback(void *data)
int got;
/* Fire the callback until we have enough to fill a buffer */
while (SDL_AudioStreamAvailable(this->stream) < this->spec.size) {
while (SDL_GetAudioStreamAvailable(this->stream) < this->spec.size) {
this->callbackspec.callback(this->callbackspec.userdata, this->work_buffer, this->callbackspec.size);
SDL_AudioStreamPut(this->stream, this->work_buffer, this->callbackspec.size);
SDL_PutAudioStreamData(this->stream, this->work_buffer, this->callbackspec.size);
}
got = SDL_AudioStreamGet(this->stream, dst, this->spec.size);
got = SDL_GetAudioStreamData(this->stream, dst, this->spec.size);
SDL_assert(got == this->spec.size);
}
} else {

View File

@ -81,7 +81,7 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
(this->callbackspec.freq == this->spec.freq) &&
(this->callbackspec.samples == this->spec.samples)) {
/* no need to buffer/convert in an AudioStream! */
SDL_FreeAudioStream(this->stream);
SDL_DestroyAudioStream(this->stream);
this->stream = NULL;
} else if ((oldspec->channels == this->spec.channels) &&
(oldspec->format == this->spec.format) &&
@ -89,22 +89,22 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
/* The existing audio stream is okay to keep using. */
} else {
/* replace the audiostream for new format */
SDL_FreeAudioStream(this->stream);
SDL_DestroyAudioStream(this->stream);
if (this->iscapture) {
this->stream = SDL_NewAudioStream(this->spec.format,
this->stream = SDL_CreateAudioStream(this->spec.format,
this->spec.channels, this->spec.freq,
this->callbackspec.format,
this->callbackspec.channels,
this->callbackspec.freq);
} else {
this->stream = SDL_NewAudioStream(this->callbackspec.format,
this->stream = SDL_CreateAudioStream(this->callbackspec.format,
this->callbackspec.channels,
this->callbackspec.freq, this->spec.format,
this->spec.channels, this->spec.freq);
}
if (!this->stream) {
return -1; /* SDL_NewAudioStream should have called SDL_SetError. */
return -1; /* SDL_CreateAudioStream should have called SDL_SetError. */
}
}
@ -222,10 +222,10 @@ static void WASAPI_WaitDevice(_THIS)
static int WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
{
SDL_AudioStream *stream = this->hidden->capturestream;
const int avail = SDL_AudioStreamAvailable(stream);
const int avail = SDL_GetAudioStreamAvailable(stream);
if (avail > 0) {
const int cpy = SDL_min(buflen, avail);
SDL_AudioStreamGet(stream, buffer, cpy);
SDL_GetAudioStreamData(stream, buffer, cpy);
return cpy;
}
@ -268,7 +268,7 @@ static int WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
SDL_memset(ptr, this->spec.silence, leftover); /* I guess this is safe? */
}
if (SDL_AudioStreamPut(stream, ptr, leftover) == -1) {
if (SDL_PutAudioStreamData(stream, ptr, leftover) == -1) {
return -1; /* uhoh, out of memory, etc. Kill device. :( */
}
}
@ -304,7 +304,7 @@ static void WASAPI_FlushCapture(_THIS)
break; /* something broke. */
}
}
SDL_AudioStreamClear(this->hidden->capturestream);
SDL_ClearAudioStream(this->hidden->capturestream);
}
static void ReleaseWasapiDevice(_THIS)
@ -331,7 +331,7 @@ static void ReleaseWasapiDevice(_THIS)
}
if (this->hidden->capturestream) {
SDL_FreeAudioStream(this->hidden->capturestream);
SDL_DestroyAudioStream(this->hidden->capturestream);
this->hidden->capturestream = NULL;
}
@ -484,7 +484,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
this->hidden->framesize = (SDL_AUDIO_BITSIZE(this->spec.format) / 8) * this->spec.channels;
if (this->iscapture) {
this->hidden->capturestream = SDL_NewAudioStream(this->spec.format, this->spec.channels, this->spec.freq, this->spec.format, this->spec.channels, this->spec.freq);
this->hidden->capturestream = SDL_CreateAudioStream(this->spec.format, this->spec.channels, this->spec.freq, this->spec.format, this->spec.channels, this->spec.freq);
if (!this->hidden->capturestream) {
return -1; /* already set SDL_Error */
}

View File

@ -48,13 +48,13 @@ SDL3_0.0.0 {
SDL_LoadWAV_RW;
SDL_BuildAudioCVT;
SDL_ConvertAudio;
SDL_NewAudioStream;
SDL_AudioStreamPut;
SDL_AudioStreamGet;
SDL_AudioStreamAvailable;
SDL_AudioStreamFlush;
SDL_AudioStreamClear;
SDL_FreeAudioStream;
SDL_CreateAudioStream;
SDL_PutAudioStreamData;
SDL_GetAudioStreamData;
SDL_GetAudioStreamAvailable;
SDL_FlushAudioStream;
SDL_ClearAudioStream;
SDL_DestroyAudioStream;
SDL_MixAudio;
SDL_MixAudioFormat;
SDL_QueueAudio;

View File

@ -614,13 +614,13 @@
#define SDL_GetMemoryFunctions SDL_GetMemoryFunctions_REAL
#define SDL_SetMemoryFunctions SDL_SetMemoryFunctions_REAL
#define SDL_GetNumAllocations SDL_GetNumAllocations_REAL
#define SDL_NewAudioStream SDL_NewAudioStream_REAL
#define SDL_AudioStreamPut SDL_AudioStreamPut_REAL
#define SDL_AudioStreamGet SDL_AudioStreamGet_REAL
#define SDL_AudioStreamClear SDL_AudioStreamClear_REAL
#define SDL_AudioStreamAvailable SDL_AudioStreamAvailable_REAL
#define SDL_FreeAudioStream SDL_FreeAudioStream_REAL
#define SDL_AudioStreamFlush SDL_AudioStreamFlush_REAL
#define SDL_CreateAudioStream SDL_CreateAudioStream_REAL
#define SDL_PutAudioStreamData SDL_PutAudioStreamData_REAL
#define SDL_GetAudioStreamData SDL_GetAudioStreamData_REAL
#define SDL_ClearAudioStream SDL_ClearAudioStream_REAL
#define SDL_GetAudioStreamAvailable SDL_GetAudioStreamAvailable_REAL
#define SDL_DestroyAudioStream SDL_DestroyAudioStream_REAL
#define SDL_FlushAudioStream SDL_FlushAudioStream_REAL
#define SDL_acosf SDL_acosf_REAL
#define SDL_asinf SDL_asinf_REAL
#define SDL_atanf SDL_atanf_REAL

View File

@ -647,13 +647,13 @@ SDL_DYNAPI_PROC(void,SDL_UnlockJoysticks,(void),(),)
SDL_DYNAPI_PROC(void,SDL_GetMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
SDL_DYNAPI_PROC(int,SDL_SetMemoryFunctions,(SDL_malloc_func a, SDL_calloc_func b, SDL_realloc_func c, SDL_free_func d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAllocations,(void),(),return)
SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_NewAudioStream,(SDL_AudioFormat a, Uint8 b, int c, SDL_AudioFormat d, Uint8 e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_AudioStreamPut,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_AudioStreamGet,(SDL_AudioStream *a, void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_AudioStreamClear,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(int,SDL_AudioStreamAvailable,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_FreeAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(int,SDL_AudioStreamFlush,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_CreateAudioStream,(SDL_AudioFormat a, Uint8 b, int c, SDL_AudioFormat d, Uint8 e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_PutAudioStreamData,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamData,(SDL_AudioStream *a, void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_ClearAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(int,SDL_GetAudioStreamAvailable,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_DestroyAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(int,SDL_FlushAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(float,SDL_acosf,(float a),(a),return)
SDL_DYNAPI_PROC(float,SDL_asinf,(float a),(a),return)
SDL_DYNAPI_PROC(float,SDL_atanf,(float a),(a),return)