mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-30 16:37:39 +00:00
audio: Added SDL_GetAudioStreamBinding.
Now you can open a device, bind a stream, and forget about the device ID until you're ready to shutdown, where you can query the stream for it.
This commit is contained in:
parent
01f7b53865
commit
464640440f
5 changed files with 40 additions and 0 deletions
|
@ -542,6 +542,7 @@ extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
|
|||
* \sa SDL_BindAudioStreams
|
||||
* \sa SDL_UnbindAudioStreams
|
||||
* \sa SDL_UnbindAudioStream
|
||||
* \sa SDL_GetAudioStreamBinding
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int num_streams);
|
||||
|
||||
|
@ -562,6 +563,7 @@ extern DECLSPEC int SDLCALL SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_Au
|
|||
* \sa SDL_BindAudioStreams
|
||||
* \sa SDL_UnbindAudioStreams
|
||||
* \sa SDL_UnbindAudioStream
|
||||
* \sa SDL_GetAudioStreamBinding
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_AudioStream *stream);
|
||||
|
||||
|
@ -584,6 +586,7 @@ extern DECLSPEC int SDLCALL SDL_BindAudioStream(SDL_AudioDeviceID devid, SDL_Aud
|
|||
* \sa SDL_BindAudioStreams
|
||||
* \sa SDL_BindAudioStream
|
||||
* \sa SDL_UnbindAudioStream
|
||||
* \sa SDL_GetAudioStreamBinding
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnbindAudioStreams(SDL_AudioStream **streams, int num_streams);
|
||||
|
||||
|
@ -602,9 +605,31 @@ extern DECLSPEC void SDLCALL SDL_UnbindAudioStreams(SDL_AudioStream **streams, i
|
|||
* \sa SDL_BindAudioStream
|
||||
* \sa SDL_BindAudioStreams
|
||||
* \sa SDL_UnbindAudioStreams
|
||||
* \sa SDL_GetAudioStreamBinding
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnbindAudioStream(SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* Query an audio stream for its currently-bound device.
|
||||
*
|
||||
* This reports the audio device that an audio stream is currently bound to.
|
||||
*
|
||||
* If not bound, or invalid, this returns zero, which is not a valid device ID.
|
||||
*
|
||||
* \param stream the audio stream to query.
|
||||
* \returns The bound audio device, or 0 if not bound or invalid.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_BindAudioStream
|
||||
* \sa SDL_BindAudioStreams
|
||||
* \sa SDL_UnbindAudioStream
|
||||
* \sa SDL_UnbindAudioStreams
|
||||
*/
|
||||
extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_GetAudioStreamBinding(SDL_AudioStream *stream);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new audio stream.
|
||||
|
|
|
@ -1357,6 +1357,18 @@ void SDL_UnbindAudioStream(SDL_AudioStream *stream)
|
|||
SDL_UnbindAudioStreams(&stream, 1);
|
||||
}
|
||||
|
||||
SDL_AudioDeviceID SDL_GetAudioStreamBinding(SDL_AudioStream *stream)
|
||||
{
|
||||
SDL_AudioDeviceID retval = 0;
|
||||
if (stream) {
|
||||
SDL_LockMutex(stream->lock);
|
||||
if (stream->bound_device) {
|
||||
retval = stream->bound_device->instance_id;
|
||||
}
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
SDL_AudioStream *SDL_CreateAndBindAudioStream(SDL_AudioDeviceID devid, const SDL_AudioSpec *spec)
|
||||
{
|
||||
|
|
|
@ -888,6 +888,7 @@ SDL3_0.0.0 {
|
|||
SDL_PauseAudioDevice;
|
||||
SDL_UnpauseAudioDevice;
|
||||
SDL_IsAudioDevicePaused;
|
||||
SDL_GetAudioStreamBinding;
|
||||
# extra symbols go here (don't modify this line)
|
||||
local: *;
|
||||
};
|
||||
|
|
|
@ -914,3 +914,4 @@
|
|||
#define SDL_PauseAudioDevice SDL_PauseAudioDevice_REAL
|
||||
#define SDL_UnpauseAudioDevice SDL_UnpauseAudioDevice_REAL
|
||||
#define SDL_IsAudioDevicePaused SDL_IsAudioDevicePaused_REAL
|
||||
#define SDL_GetAudioStreamBinding SDL_GetAudioStreamBinding_REAL
|
||||
|
|
|
@ -958,3 +958,4 @@ SDL_DYNAPI_PROC(int,SDL_LoadWAV,(const char *a, SDL_AudioSpec *b, Uint8 **c, Uin
|
|||
SDL_DYNAPI_PROC(int,SDL_PauseAudioDevice,(SDL_AudioDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_UnpauseAudioDevice,(SDL_AudioDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_IsAudioDevicePaused,(SDL_AudioDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_AudioDeviceID,SDL_GetAudioStreamBinding,(SDL_AudioStream *a),(a),return)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue