mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-16 14:56:00 +00:00
Added SDL_PauseAudioStreamDevice() and SDL_ResumeAudioStreamDevice()
This commit is contained in:

committed by
Ryan C. Gordon

parent
a6da2e6f8b
commit
534768c7c5
@@ -1947,13 +1947,20 @@ void SDL_UnbindAudioStream(SDL_AudioStream *stream)
|
||||
SDL_AudioDeviceID SDL_GetAudioStreamDevice(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);
|
||||
|
||||
if (!stream) {
|
||||
SDL_InvalidParamError("stream");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_LockMutex(stream->lock);
|
||||
if (stream->bound_device) {
|
||||
retval = stream->bound_device->instance_id;
|
||||
} else {
|
||||
SDL_SetError("Audio stream not bound to an audio device");
|
||||
}
|
||||
SDL_UnlockMutex(stream->lock);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -2024,6 +2031,26 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
||||
return stream;
|
||||
}
|
||||
|
||||
int SDL_PauseAudioStreamDevice(SDL_AudioStream *stream)
|
||||
{
|
||||
SDL_AudioDeviceID devid = SDL_GetAudioStreamDevice(stream);
|
||||
if (!devid) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return SDL_PauseAudioDevice(devid);
|
||||
}
|
||||
|
||||
int SDL_ResumeAudioStreamDevice(SDL_AudioStream *stream)
|
||||
{
|
||||
SDL_AudioDeviceID devid = SDL_GetAudioStreamDevice(stream);
|
||||
if (!devid) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return SDL_ResumeAudioDevice(devid);
|
||||
}
|
||||
|
||||
#define NUM_FORMATS 8
|
||||
static const SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS + 1] = {
|
||||
{ SDL_AUDIO_U8, SDL_AUDIO_S8, SDL_AUDIO_S16LE, SDL_AUDIO_S16BE, SDL_AUDIO_S32LE, SDL_AUDIO_S32BE, SDL_AUDIO_F32LE, SDL_AUDIO_F32BE, 0 },
|
||||
|
Reference in New Issue
Block a user