diff options
author | Chris Robinson <[email protected]> | 2018-03-08 22:23:36 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-08 22:23:36 -0800 |
commit | 46e7e96eb3407405df9999cbb3134a5392c98a08 (patch) | |
tree | 47c7cbcb7972559b5c8d7631d5cb79c90be1faf7 /Alc/backends/sdl2.c | |
parent | 41cc82e84beff737afbdf2b56ba8f53d8fb04559 (diff) |
Store the frame size for the SDL2 backend
Diffstat (limited to 'Alc/backends/sdl2.c')
-rw-r--r-- | Alc/backends/sdl2.c | 12 |
1 files changed, 6 insertions, 6 deletions
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; |