aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/sdl2.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-08 18:22:03 -0800
committerChris Robinson <[email protected]>2018-03-08 18:22:03 -0800
commitaa7df8183f5acd81ca2d26b057eb89eccbf85492 (patch)
treef643d078bd10e928b48714b11c18444f5b015083 /Alc/backends/sdl2.c
parent58760e6184118e34fe2f8fde28fb7b51d449e8cc (diff)
Also save the update size with SDL2
Diffstat (limited to 'Alc/backends/sdl2.c')
-rw-r--r--Alc/backends/sdl2.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/Alc/backends/sdl2.c b/Alc/backends/sdl2.c
index b54fcc4b..391b110d 100644
--- a/Alc/backends/sdl2.c
+++ b/Alc/backends/sdl2.c
@@ -36,9 +36,11 @@ typedef struct ALCsdl2Backend {
SDL_AudioDeviceID deviceID;
ALCboolean quit;
+
ALuint Frequency;
enum DevFmtChannels FmtChans;
enum DevFmtType FmtType;
+ ALuint UpdateSize;
} ALCsdl2Backend;
static void ALCsdl2Backend_Construct(ALCsdl2Backend *self, ALCdevice *device);
@@ -123,11 +125,8 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name)
ERR("Could not open device\n");
return ALC_INVALID_VALUE;
}
- if(want.freq != have.freq)
- {
- TRACE("Frequency changed by SDL2\n");
- device->Frequency = have.freq;
- }
+
+ device->Frequency = have.freq;
if(have.channels == 1)
device->FmtChans = DevFmtMono;
else if(have.channels == 2)
@@ -149,12 +148,15 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name)
ERR("Unsupported format\n");
return ALC_INVALID_VALUE;
}
+ device->UpdateSize = have.samples;
+ device->NumUpdates = 2; /* SDL always (tries to) use two periods. */
+
self->Frequency = device->Frequency;
self->FmtChans = device->FmtChans;
self->FmtType = device->FmtType;
- if(!name)
- name = defaultDeviceName;
- alstr_copy_cstr(&STATIC_CAST(ALCbackend, self)->mDevice->DeviceName, name);
+ self->UpdateSize = device->UpdateSize;
+
+ alstr_copy_cstr(&device->DeviceName, name ? name : defaultDeviceName);
return ALC_NO_ERROR;
}
@@ -165,6 +167,8 @@ static ALCboolean ALCsdl2Backend_reset(ALCsdl2Backend *self)
device->Frequency = self->Frequency;
device->FmtChans = self->FmtChans;
device->FmtType = self->FmtType;
+ device->UpdateSize = self->UpdateSize;
+ device->NumUpdates = 2;
SetDefaultWFXChannelOrder(device);
return ALC_TRUE;
}