From 46e7e96eb3407405df9999cbb3134a5392c98a08 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 8 Mar 2018 22:23:36 -0800 Subject: Store the frame size for the SDL2 backend --- Alc/backends/sdl2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Alc') diff --git a/Alc/backends/sdl2.c b/Alc/backends/sdl2.c index 61076789..f301cf48 100644 --- a/Alc/backends/sdl2.c +++ b/Alc/backends/sdl2.c @@ -35,6 +35,7 @@ typedef struct ALCsdl2Backend { DERIVE_FROM_TYPE(ALCbackend); SDL_AudioDeviceID deviceID; + ALsizei frameSize; ALuint Frequency; enum DevFmtChannels FmtChans; @@ -65,6 +66,7 @@ static void ALCsdl2Backend_Construct(ALCsdl2Backend *self, ALCdevice *device) SET_VTABLE2(ALCsdl2Backend, ALCbackend, self); self->deviceID = 0; + self->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder); self->Frequency = device->Frequency; self->FmtChans = device->FmtChans; self->FmtType = device->FmtType; @@ -81,16 +83,13 @@ static void ALCsdl2Backend_Destruct(ALCsdl2Backend *self) } -static void ALCsdl2Backend_audioCallback(void *ptr, Uint8* stream, int len) +static void ALCsdl2Backend_audioCallback(void *ptr, Uint8 *stream, int len) { ALCsdl2Backend *self = (ALCsdl2Backend*)ptr; ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; - ALsizei frameSize = FrameSizeFromDevFmt( - device->FmtChans, device->FmtType, device->AmbiOrder - ); - assert(len % frameSize == 0); - aluMixData(device, stream, len / frameSize); + assert((len % self->frameSize) == 0); + aluMixData(device, stream, len / self->frameSize); } static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name) @@ -137,6 +136,7 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name) device->UpdateSize = have.samples; device->NumUpdates = 2; /* SDL always (tries to) use two periods. */ + self->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder); self->Frequency = device->Frequency; self->FmtChans = device->FmtChans; self->FmtType = device->FmtType; -- cgit v1.2.3