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 * RW_SEEK_SET -> SDL_RW_SEEK_SET
* SDL_FreeWAV has been removed and calls can be replaced with SDL_free * SDL_FreeWAV has been removed and calls can be replaced with SDL_free
* The following functions have been renamed: * 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: * Removed the following functions from the API, see docs/README-migration.md for details:
* SDL_AudioInit() * SDL_AudioInit()
* SDL_AudioQuit() * 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. 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_cpuinfo.h
SDL_Has3DNow() has been removed; there is no replacement. 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. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AudioStreamPut * \sa SDL_PutAudioStreamData
* \sa SDL_AudioStreamGet * \sa SDL_GetAudioStreamData
* \sa SDL_AudioStreamAvailable * \sa SDL_GetAudioStreamAvailable
* \sa SDL_AudioStreamFlush * \sa SDL_FlushAudioStream
* \sa SDL_AudioStreamClear * \sa SDL_ClearAudioStream
* \sa SDL_FreeAudioStream * \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, Uint8 src_channels,
int src_rate, int src_rate,
SDL_AudioFormat dst_format, 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. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_NewAudioStream * \sa SDL_CreateAudioStream
* \sa SDL_AudioStreamGet * \sa SDL_GetAudioStreamData
* \sa SDL_AudioStreamAvailable * \sa SDL_GetAudioStreamAvailable
* \sa SDL_AudioStreamFlush * \sa SDL_FlushAudioStream
* \sa SDL_AudioStreamClear * \sa SDL_ClearAudioStream
* \sa SDL_FreeAudioStream * \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 * 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. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_NewAudioStream * \sa SDL_CreateAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_PutAudioStreamData
* \sa SDL_AudioStreamAvailable * \sa SDL_GetAudioStreamAvailable
* \sa SDL_AudioStreamFlush * \sa SDL_FlushAudioStream
* \sa SDL_AudioStreamClear * \sa SDL_ClearAudioStream
* \sa SDL_FreeAudioStream * \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. * 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. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_NewAudioStream * \sa SDL_CreateAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_PutAudioStreamData
* \sa SDL_AudioStreamGet * \sa SDL_GetAudioStreamData
* \sa SDL_AudioStreamFlush * \sa SDL_FlushAudioStream
* \sa SDL_AudioStreamClear * \sa SDL_ClearAudioStream
* \sa SDL_FreeAudioStream * \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 * 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. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_NewAudioStream * \sa SDL_CreateAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_PutAudioStreamData
* \sa SDL_AudioStreamGet * \sa SDL_GetAudioStreamData
* \sa SDL_AudioStreamAvailable * \sa SDL_GetAudioStreamAvailable
* \sa SDL_AudioStreamClear * \sa SDL_ClearAudioStream
* \sa SDL_FreeAudioStream * \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 * Clear any pending data in the stream without converting it
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_NewAudioStream * \sa SDL_CreateAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_PutAudioStreamData
* \sa SDL_AudioStreamGet * \sa SDL_GetAudioStreamData
* \sa SDL_AudioStreamAvailable * \sa SDL_GetAudioStreamAvailable
* \sa SDL_AudioStreamFlush * \sa SDL_FlushAudioStream
* \sa SDL_FreeAudioStream * \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 * Free an audio stream
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_NewAudioStream * \sa SDL_CreateAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_PutAudioStreamData
* \sa SDL_AudioStreamGet * \sa SDL_GetAudioStreamData
* \sa SDL_AudioStreamAvailable * \sa SDL_GetAudioStreamAvailable
* \sa SDL_AudioStreamFlush * \sa SDL_FlushAudioStream
* \sa SDL_AudioStreamClear * \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 #define SDL_MIX_MAXVOLUME 128

View File

@ -40,7 +40,14 @@
#ifdef SDL_ENABLE_OLD_NAMES #ifdef SDL_ENABLE_OLD_NAMES
/* ##SDL_audio.h */ /* ##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_FreeWAV SDL_free
#define SDL_NewAudioStream SDL_CreateAudioStream
/* ##SDL_keycode.h */ /* ##SDL_keycode.h */
#define KMOD_ALT SDL_KMOD_ALT #define KMOD_ALT SDL_KMOD_ALT
@ -78,7 +85,14 @@
#else /* !SDL_ENABLE_OLD_NAMES */ #else /* !SDL_ENABLE_OLD_NAMES */
/* ##SDL_audio.h */ /* ##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_FreeWAV SDL_FreeWAV_renamed_SDL_free
#define SDL_NewAudioStream SDL_NewAudioStream_renamed_SDL_CreateAudioStream
/* ##SDL_keycode.h */ /* ##SDL_keycode.h */
#define KMOD_ALT KMOD_ALT_renamed_SDL_KMOD_ALT #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) { if (device->stream) {
/* Stream available audio to device, converting/resampling. */ /* Stream available audio to device, converting/resampling. */
/* if this fails...oh well. We'll play silence here. */ /* 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; int got;
data = SDL_AtomicGet(&device->enabled) ? current_audio.impl.GetDeviceBuf(device) : NULL; 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)); SDL_assert((got <= 0) || (got == device->spec.size));
if (data == NULL) { /* device is having issues... */ if (data == NULL) { /* device is having issues... */
@ -763,7 +763,7 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
if (SDL_AtomicGet(&device->paused)) { if (SDL_AtomicGet(&device->paused)) {
SDL_Delay(delay); /* just so we don't cook the CPU. */ SDL_Delay(delay); /* just so we don't cook the CPU. */
if (device->stream) { if (device->stream) {
SDL_AudioStreamClear(device->stream); SDL_ClearAudioStream(device->stream);
} }
current_audio.impl.FlushCapture(device); /* dump anything pending. */ current_audio.impl.FlushCapture(device); /* dump anything pending. */
continue; continue;
@ -805,10 +805,10 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
if (device->stream) { if (device->stream) {
/* if this fails...oh well. */ /* 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)) { while (SDL_GetAudioStreamAvailable(device->stream) >= ((int)device->callbackspec.size)) {
const int got = SDL_AudioStreamGet(device->stream, device->work_buffer, device->callbackspec.size); const int got = SDL_GetAudioStreamData(device->stream, device->work_buffer, device->callbackspec.size);
SDL_assert((got < 0) || (got == device->callbackspec.size)); SDL_assert((got < 0) || (got == device->callbackspec.size));
if (got != device->callbackspec.size) { if (got != device->callbackspec.size) {
SDL_memset(device->work_buffer, device->spec.silence, 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_free(device->work_buffer);
SDL_FreeAudioStream(device->stream); SDL_DestroyAudioStream(device->stream);
if (device->id > 0) { if (device->id > 0) {
SDL_AudioDevice *opendev = open_devices[device->id - 1]; 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 (build_stream) {
if (iscapture) { if (iscapture) {
device->stream = SDL_NewAudioStream(device->spec.format, device->stream = SDL_CreateAudioStream(device->spec.format,
device->spec.channels, device->spec.freq, device->spec.channels, device->spec.freq,
obtained->format, obtained->channels, obtained->freq); obtained->format, obtained->channels, obtained->freq);
} else { } else {
device->stream = SDL_NewAudioStream(obtained->format, obtained->channels, device->stream = SDL_CreateAudioStream(obtained->format, obtained->channels,
obtained->freq, device->spec.format, obtained->freq, device->spec.format,
device->spec.channels, device->spec.freq); 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; SRC_DATA data;
int result; 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.data_in = (float *)inbuf; /* Older versions of libsamplerate had a non-const pointer, but didn't write to it */
data.input_frames = inbuflen / framelen; 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); const int cpy = SDL_min(inbuflen, paddingbytes);
int retval; 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); 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_AudioStream *
SDL_NewAudioStream(SDL_AudioFormat src_format, SDL_CreateAudioStream(SDL_AudioFormat src_format,
Uint8 src_channels, Uint8 src_channels,
int src_rate, int src_rate,
SDL_AudioFormat dst_format, 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)); retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float));
if (retval->resampler_padding == NULL) { if (retval->resampler_padding == NULL) {
SDL_FreeAudioStream(retval); SDL_DestroyAudioStream(retval);
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
} }
@ -1045,7 +1045,7 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
if (retval->staging_buffer_size > 0) { if (retval->staging_buffer_size > 0) {
retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size); retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size);
if (retval->staging_buffer == NULL) { if (retval->staging_buffer == NULL) {
SDL_FreeAudioStream(retval); SDL_DestroyAudioStream(retval);
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
} }
@ -1055,14 +1055,14 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
if (src_rate == dst_rate) { if (src_rate == dst_rate) {
retval->cvt_before_resampling.needed = SDL_FALSE; 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) { 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. */ return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */
} }
} else { } else {
/* Don't resample at first. Just get us to Float32 format. */ /* Don't resample at first. Just get us to Float32 format. */
/* !!! FIXME: convert to int32 on devices without hardware float. */ /* !!! 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) { 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. */ return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */
} }
@ -1073,7 +1073,7 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
if (!retval->resampler_func) { if (!retval->resampler_func) {
retval->resampler_state = SDL_calloc(retval->resampler_padding_samples, sizeof(float)); retval->resampler_state = SDL_calloc(retval->resampler_padding_samples, sizeof(float));
if (!retval->resampler_state) { if (!retval->resampler_state) {
SDL_FreeAudioStream(retval); SDL_DestroyAudioStream(retval);
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
} }
@ -1085,14 +1085,14 @@ SDL_NewAudioStream(SDL_AudioFormat src_format,
/* Convert us to the final format after resampling. */ /* 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) { 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. */ return NULL; /* SDL_BuildAudioCVT should have called SDL_SetError. */
} }
} }
retval->queue = SDL_NewDataQueue(packetlen, (size_t)packetlen * 2); retval->queue = SDL_NewDataQueue(packetlen, (size_t)packetlen * 2);
if (!retval->queue) { if (!retval->queue) {
SDL_FreeAudioStream(retval); SDL_DestroyAudioStream(retval);
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */ 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; 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: several converters can take advantage of SIMD, but only
!!! FIXME: if the data is aligned to 16 bytes. EnsureStreamBufferSize() !!! 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; return 0;
} }
int SDL_AudioStreamFlush(SDL_AudioStream *stream) int SDL_FlushAudioStream(SDL_AudioStream *stream)
{ {
if (stream == NULL) { if (stream == NULL) {
return SDL_InvalidParamError("stream"); return SDL_InvalidParamError("stream");
@ -1349,7 +1349,7 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream)
} }
/* get converted/resampled data from the 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 #if DEBUG_AUDIOSTREAM
SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len); 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 */ /* 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; return stream ? (int)SDL_CountDataQueue(stream->queue) : 0;
} }
void SDL_AudioStreamClear(SDL_AudioStream *stream) void SDL_ClearAudioStream(SDL_AudioStream *stream)
{ {
if (stream == NULL) { if (stream == NULL) {
SDL_InvalidParamError("stream"); SDL_InvalidParamError("stream");
@ -1392,7 +1392,7 @@ void SDL_AudioStreamClear(SDL_AudioStream *stream)
} }
/* dispose of a stream */ /* dispose of a stream */
void SDL_FreeAudioStream(SDL_AudioStream *stream) void SDL_DestroyAudioStream(SDL_AudioStream *stream)
{ {
if (stream) { if (stream) {
if (stream->cleanup_resampler_func) { if (stream->cleanup_resampler_func) {

View File

@ -535,20 +535,20 @@ static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe
Uint8 *ptr = (Uint8 *)inBuffer->mAudioData; Uint8 *ptr = (Uint8 *)inBuffer->mAudioData;
while (remaining > 0) { while (remaining > 0) {
if (SDL_AudioStreamAvailable(this->stream) == 0) { if (SDL_GetAudioStreamAvailable(this->stream) == 0) {
/* Generate the data */ /* Generate the data */
(*this->callbackspec.callback)(this->callbackspec.userdata, (*this->callbackspec.callback)(this->callbackspec.userdata,
this->hidden->buffer, this->hidden->bufferSize); this->hidden->buffer, this->hidden->bufferSize);
this->hidden->bufferOffset = 0; 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; int got;
UInt32 len = SDL_AudioStreamAvailable(this->stream); UInt32 len = SDL_GetAudioStreamAvailable(this->stream);
if (len > remaining) { if (len > remaining) {
len = remaining; len = remaining;
} }
got = SDL_AudioStreamGet(this->stream, ptr, len); got = SDL_GetAudioStreamData(this->stream, ptr, len);
SDL_assert((got < 0) || (got == len)); SDL_assert((got < 0) || (got == len));
if (got != len) { if (got != len) {
SDL_memset(ptr, this->spec.silence, 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 */ /* Only do something if audio is enabled */
if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) { if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
if (this->stream) { if (this->stream) {
SDL_AudioStreamClear(this->stream); SDL_ClearAudioStream(this->stream);
} }
SDL_memset(this->work_buffer, this->spec.silence, this->spec.size); 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); callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */ } else { /* streaming/converting */
int got; 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); callback(this->callbackspec.userdata, this->work_buffer, stream_len);
if (SDL_AudioStreamPut(this->stream, this->work_buffer, stream_len) == -1) { if (SDL_PutAudioStreamData(this->stream, this->work_buffer, stream_len) == -1) {
SDL_AudioStreamClear(this->stream); SDL_ClearAudioStream(this->stream);
SDL_AtomicSet(&this->enabled, 0); SDL_AtomicSet(&this->enabled, 0);
break; 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)); SDL_assert((got < 0) || (got == this->spec.size));
if (got != this->spec.size) { if (got != this->spec.size) {
SDL_memset(this->work_buffer, this->spec.silence, 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 */ /* Only do something if audio is enabled */
if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) { if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) {
SDL_AudioStreamClear(this->stream); SDL_ClearAudioStream(this->stream);
return; return;
} }
@ -133,12 +133,12 @@ static void HandleCaptureProcess(_THIS)
SDL_assert(this->spec.size == stream_len); SDL_assert(this->spec.size == stream_len);
callback(this->callbackspec.userdata, this->work_buffer, stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */ } 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); SDL_AtomicSet(&this->enabled, 0);
} }
while (SDL_AudioStreamAvailable(this->stream) >= stream_len) { while (SDL_GetAudioStreamAvailable(this->stream) >= stream_len) {
const int got = SDL_AudioStreamGet(this->stream, this->work_buffer, stream_len); const int got = SDL_GetAudioStreamData(this->stream, this->work_buffer, stream_len);
SDL_assert((got < 0) || (got == stream_len)); SDL_assert((got < 0) || (got == stream_len));
if (got != stream_len) { if (got != stream_len) {
SDL_memset(this->work_buffer, this->callbackspec.silence, 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 */ /* Only do something if audio is enabled */
if (!SDL_AtomicGet(&audio->enabled) || SDL_AtomicGet(&audio->paused)) { if (!SDL_AtomicGet(&audio->enabled) || SDL_AtomicGet(&audio->paused)) {
if (audio->stream) { if (audio->stream) {
SDL_AudioStreamClear(audio->stream); SDL_ClearAudioStream(audio->stream);
} }
SDL_memset(stream, audio->spec.silence, len); SDL_memset(stream, audio->spec.silence, len);
} else { } else {
@ -63,16 +63,16 @@ static void FillSound(void *device, void *stream, size_t len,
} else { /* streaming/converting */ } else { /* streaming/converting */
const int stream_len = audio->callbackspec.size; const int stream_len = audio->callbackspec.size;
const int ilen = (int) len; 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); callback(audio->callbackspec.userdata, audio->work_buffer, stream_len);
if (SDL_AudioStreamPut(audio->stream, audio->work_buffer, stream_len) == -1) { if (SDL_PutAudioStreamData(audio->stream, audio->work_buffer, stream_len) == -1) {
SDL_AudioStreamClear(audio->stream); SDL_ClearAudioStream(audio->stream);
SDL_AtomicSet(&audio->enabled, 0); SDL_AtomicSet(&audio->enabled, 0);
break; 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)); SDL_assert((got < 0) || (got == ilen));
if (got != ilen) { if (got != ilen) {
SDL_memset(stream, audio->spec.silence, len); SDL_memset(stream, audio->spec.silence, len);

View File

@ -988,12 +988,12 @@ static void output_callback(void *data)
int got; int got;
/* Fire the callback until we have enough to fill a buffer */ /* 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); 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); SDL_assert(got == this->spec.size);
} }
} else { } else {

View File

@ -81,7 +81,7 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
(this->callbackspec.freq == this->spec.freq) && (this->callbackspec.freq == this->spec.freq) &&
(this->callbackspec.samples == this->spec.samples)) { (this->callbackspec.samples == this->spec.samples)) {
/* no need to buffer/convert in an AudioStream! */ /* no need to buffer/convert in an AudioStream! */
SDL_FreeAudioStream(this->stream); SDL_DestroyAudioStream(this->stream);
this->stream = NULL; this->stream = NULL;
} else if ((oldspec->channels == this->spec.channels) && } else if ((oldspec->channels == this->spec.channels) &&
(oldspec->format == this->spec.format) && (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. */ /* The existing audio stream is okay to keep using. */
} else { } else {
/* replace the audiostream for new format */ /* replace the audiostream for new format */
SDL_FreeAudioStream(this->stream); SDL_DestroyAudioStream(this->stream);
if (this->iscapture) { if (this->iscapture) {
this->stream = SDL_NewAudioStream(this->spec.format, this->stream = SDL_CreateAudioStream(this->spec.format,
this->spec.channels, this->spec.freq, this->spec.channels, this->spec.freq,
this->callbackspec.format, this->callbackspec.format,
this->callbackspec.channels, this->callbackspec.channels,
this->callbackspec.freq); this->callbackspec.freq);
} else { } else {
this->stream = SDL_NewAudioStream(this->callbackspec.format, this->stream = SDL_CreateAudioStream(this->callbackspec.format,
this->callbackspec.channels, this->callbackspec.channels,
this->callbackspec.freq, this->spec.format, this->callbackspec.freq, this->spec.format,
this->spec.channels, this->spec.freq); this->spec.channels, this->spec.freq);
} }
if (!this->stream) { 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) static int WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen)
{ {
SDL_AudioStream *stream = this->hidden->capturestream; SDL_AudioStream *stream = this->hidden->capturestream;
const int avail = SDL_AudioStreamAvailable(stream); const int avail = SDL_GetAudioStreamAvailable(stream);
if (avail > 0) { if (avail > 0) {
const int cpy = SDL_min(buflen, avail); const int cpy = SDL_min(buflen, avail);
SDL_AudioStreamGet(stream, buffer, cpy); SDL_GetAudioStreamData(stream, buffer, cpy);
return 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? */ 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. :( */ return -1; /* uhoh, out of memory, etc. Kill device. :( */
} }
} }
@ -304,7 +304,7 @@ static void WASAPI_FlushCapture(_THIS)
break; /* something broke. */ break; /* something broke. */
} }
} }
SDL_AudioStreamClear(this->hidden->capturestream); SDL_ClearAudioStream(this->hidden->capturestream);
} }
static void ReleaseWasapiDevice(_THIS) static void ReleaseWasapiDevice(_THIS)
@ -331,7 +331,7 @@ static void ReleaseWasapiDevice(_THIS)
} }
if (this->hidden->capturestream) { if (this->hidden->capturestream) {
SDL_FreeAudioStream(this->hidden->capturestream); SDL_DestroyAudioStream(this->hidden->capturestream);
this->hidden->capturestream = NULL; 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; this->hidden->framesize = (SDL_AUDIO_BITSIZE(this->spec.format) / 8) * this->spec.channels;
if (this->iscapture) { 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) { if (!this->hidden->capturestream) {
return -1; /* already set SDL_Error */ return -1; /* already set SDL_Error */
} }

View File

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

View File

@ -614,13 +614,13 @@
#define SDL_GetMemoryFunctions SDL_GetMemoryFunctions_REAL #define SDL_GetMemoryFunctions SDL_GetMemoryFunctions_REAL
#define SDL_SetMemoryFunctions SDL_SetMemoryFunctions_REAL #define SDL_SetMemoryFunctions SDL_SetMemoryFunctions_REAL
#define SDL_GetNumAllocations SDL_GetNumAllocations_REAL #define SDL_GetNumAllocations SDL_GetNumAllocations_REAL
#define SDL_NewAudioStream SDL_NewAudioStream_REAL #define SDL_CreateAudioStream SDL_CreateAudioStream_REAL
#define SDL_AudioStreamPut SDL_AudioStreamPut_REAL #define SDL_PutAudioStreamData SDL_PutAudioStreamData_REAL
#define SDL_AudioStreamGet SDL_AudioStreamGet_REAL #define SDL_GetAudioStreamData SDL_GetAudioStreamData_REAL
#define SDL_AudioStreamClear SDL_AudioStreamClear_REAL #define SDL_ClearAudioStream SDL_ClearAudioStream_REAL
#define SDL_AudioStreamAvailable SDL_AudioStreamAvailable_REAL #define SDL_GetAudioStreamAvailable SDL_GetAudioStreamAvailable_REAL
#define SDL_FreeAudioStream SDL_FreeAudioStream_REAL #define SDL_DestroyAudioStream SDL_DestroyAudioStream_REAL
#define SDL_AudioStreamFlush SDL_AudioStreamFlush_REAL #define SDL_FlushAudioStream SDL_FlushAudioStream_REAL
#define SDL_acosf SDL_acosf_REAL #define SDL_acosf SDL_acosf_REAL
#define SDL_asinf SDL_asinf_REAL #define SDL_asinf SDL_asinf_REAL
#define SDL_atanf SDL_atanf_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(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_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(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(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_AudioStreamPut,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_PutAudioStreamData,(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(int,SDL_GetAudioStreamData,(SDL_AudioStream *a, void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_AudioStreamClear,(SDL_AudioStream *a),(a),) SDL_DYNAPI_PROC(void,SDL_ClearAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(int,SDL_AudioStreamAvailable,(SDL_AudioStream *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetAudioStreamAvailable,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_FreeAudioStream,(SDL_AudioStream *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(int,SDL_AudioStreamFlush,(SDL_AudioStream *a),(a),return) 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_acosf,(float a),(a),return)
SDL_DYNAPI_PROC(float,SDL_asinf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_asinf,(float a),(a),return)
SDL_DYNAPI_PROC(float,SDL_atanf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_atanf,(float a),(a),return)