aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorJan Niklas Hasse <[email protected]>2018-03-08 10:17:02 +0100
committerJan Niklas Hasse <[email protected]>2018-03-08 10:17:02 +0100
commitef2b813776a173425ff691749453f83265747768 (patch)
treed1530a380d63de34c134300a320af26754b0d73a /Alc/backends
parenta6f93a501a08ddf35f98473822a70258e70f613a (diff)
SDL2 backend: Allow frequency changes
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/sdl2.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Alc/backends/sdl2.c b/Alc/backends/sdl2.c
index 9881594d..a52b22c8 100644
--- a/Alc/backends/sdl2.c
+++ b/Alc/backends/sdl2.c
@@ -88,7 +88,7 @@ static void ALCsdl2Backend_audioCallback(void *ptr, Uint8* stream, int len)
static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name)
{
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
- SDL_AudioSpec want;
+ SDL_AudioSpec want, have;
SDL_zero(want);
want.freq = device->Frequency;
want.format = AUDIO_F32;
@@ -100,7 +100,12 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name)
if (name && strcmp(name, defaultDeviceName) == 0)
name = NULL; // Passing NULL to SDL_OpenAudioDevice is special and will NOT select the first
// device in the list.
- self->deviceID = SDL_OpenAudioDevice(name, 0, &want, NULL, 0);
+ self->deviceID = SDL_OpenAudioDevice(name, 0, &want, &have, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
+ if(want.freq != have.freq)
+ {
+ TRACE("Frequency changed by SDL2\n");
+ device->Frequency = have.freq;
+ }
if(self->deviceID == 0) {
ERR("Could not open device\n");
return ALC_INVALID_VALUE;