mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-25 22:19:10 +00:00
audio: Added SDL_AudioDeviceStreamPaused.
We had the other two wrapper functions to pause and resume, and forgot query.
This commit is contained in:
parent
f61860fa93
commit
3f7f632e14
6 changed files with 33 additions and 1 deletions
|
@ -1577,6 +1577,25 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *str
|
||||||
*/
|
*/
|
||||||
extern SDL_DECLSPEC bool SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream);
|
extern SDL_DECLSPEC bool SDLCALL SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to query if an audio device associated with a stream is paused.
|
||||||
|
*
|
||||||
|
* Unlike in SDL2, audio devices start in an _unpaused_ state, since an app
|
||||||
|
* has to bind a stream before any audio will flow.
|
||||||
|
*
|
||||||
|
* \param stream the audio stream associated with the audio device to query.
|
||||||
|
* \returns true if device is valid and paused, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.1.3.
|
||||||
|
*
|
||||||
|
* \sa SDL_PauseAudioStreamDevice
|
||||||
|
* \sa SDL_ResumeAudioStreamDevice
|
||||||
|
*/
|
||||||
|
extern SDL_DECLSPEC bool SDLCALL SDL_AudioStreamDevicePaused(SDL_AudioStream *stream);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock an audio stream for serialized access.
|
* Lock an audio stream for serialized access.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2130,6 +2130,16 @@ bool SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream)
|
||||||
return SDL_ResumeAudioDevice(devid);
|
return SDL_ResumeAudioDevice(devid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SDL_AudioStreamDevicePaused(SDL_AudioStream *stream)
|
||||||
|
{
|
||||||
|
SDL_AudioDeviceID devid = SDL_GetAudioStreamDevice(stream);
|
||||||
|
if (!devid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDL_AudioDevicePaused(devid);
|
||||||
|
}
|
||||||
|
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
#define NATIVE(type) SDL_AUDIO_##type##LE
|
#define NATIVE(type) SDL_AUDIO_##type##LE
|
||||||
#define SWAPPED(type) SDL_AUDIO_##type##BE
|
#define SWAPPED(type) SDL_AUDIO_##type##BE
|
||||||
|
|
|
@ -1230,6 +1230,7 @@ SDL3_0.0.0 {
|
||||||
SDL_GetTrayMenuParentEntry;
|
SDL_GetTrayMenuParentEntry;
|
||||||
SDL_GetTrayMenuParentTray;
|
SDL_GetTrayMenuParentTray;
|
||||||
SDL_GetThreadState;
|
SDL_GetThreadState;
|
||||||
|
SDL_AudioStreamDevicePaused;
|
||||||
# extra symbols go here (don't modify this line)
|
# extra symbols go here (don't modify this line)
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1255,3 +1255,4 @@
|
||||||
#define SDL_GetTrayMenuParentEntry SDL_GetTrayMenuParentEntry_REAL
|
#define SDL_GetTrayMenuParentEntry SDL_GetTrayMenuParentEntry_REAL
|
||||||
#define SDL_GetTrayMenuParentTray SDL_GetTrayMenuParentTray_REAL
|
#define SDL_GetTrayMenuParentTray SDL_GetTrayMenuParentTray_REAL
|
||||||
#define SDL_GetThreadState SDL_GetThreadState_REAL
|
#define SDL_GetThreadState SDL_GetThreadState_REAL
|
||||||
|
#define SDL_AudioStreamDevicePaused SDL_AudioStreamDevicePaused_REAL
|
||||||
|
|
|
@ -1263,3 +1263,4 @@ SDL_DYNAPI_PROC(SDL_TrayMenu*,SDL_GetTrayEntryParent,(SDL_TrayEntry *a),(a),retu
|
||||||
SDL_DYNAPI_PROC(SDL_TrayEntry*,SDL_GetTrayMenuParentEntry,(SDL_TrayMenu *a),(a),return)
|
SDL_DYNAPI_PROC(SDL_TrayEntry*,SDL_GetTrayMenuParentEntry,(SDL_TrayMenu *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_Tray*,SDL_GetTrayMenuParentTray,(SDL_TrayMenu *a),(a),return)
|
SDL_DYNAPI_PROC(SDL_Tray*,SDL_GetTrayMenuParentTray,(SDL_TrayMenu *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_ThreadState,SDL_GetThreadState,(SDL_Thread *a),(a),return)
|
SDL_DYNAPI_PROC(SDL_ThreadState,SDL_GetThreadState,(SDL_Thread *a),(a),return)
|
||||||
|
SDL_DYNAPI_PROC(bool,SDL_AudioStreamDevicePaused,(SDL_AudioStream *a),(a),return)
|
||||||
|
|
|
@ -172,7 +172,7 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
||||||
|
|
||||||
SDL_AppResult SDL_AppIterate(void *appstate)
|
SDL_AppResult SDL_AppIterate(void *appstate)
|
||||||
{
|
{
|
||||||
if (!SDL_AudioDevicePaused(SDL_GetAudioStreamDevice(stream_in))) {
|
if (!SDL_AudioStreamDevicePaused(stream_in)) {
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||||
} else {
|
} else {
|
||||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue