aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-08 18:16:10 -0800
committerChris Robinson <[email protected]>2018-03-08 18:16:10 -0800
commit58760e6184118e34fe2f8fde28fb7b51d449e8cc (patch)
treed6d6f536959dd8f57ad883175deb2cb155ca2308
parent52ca70d98e164cb925dcc28fa97ade6fea1bd6ae (diff)
Use the audio device lock for the SDL2 backend
-rw-r--r--Alc/backends/sdl2.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/Alc/backends/sdl2.c b/Alc/backends/sdl2.c
index df4324ad..b54fcc4b 100644
--- a/Alc/backends/sdl2.c
+++ b/Alc/backends/sdl2.c
@@ -50,8 +50,8 @@ static void ALCsdl2Backend_stop(ALCsdl2Backend *self);
static DECLARE_FORWARD2(ALCsdl2Backend, ALCbackend, ALCenum, captureSamples, void*, ALCuint)
static DECLARE_FORWARD(ALCsdl2Backend, ALCbackend, ALCuint, availableSamples)
static DECLARE_FORWARD(ALCsdl2Backend, ALCbackend, ClockLatency, getClockLatency)
-static DECLARE_FORWARD(ALCsdl2Backend, ALCbackend, void, lock)
-static DECLARE_FORWARD(ALCsdl2Backend, ALCbackend, void, unlock)
+static void ALCsdl2Backend_lock(ALCsdl2Backend *self);
+static void ALCsdl2Backend_unlock(ALCsdl2Backend *self);
DECLARE_DEFAULT_ALLOCATORS(ALCsdl2Backend)
DEFINE_ALCBACKEND_VTABLE(ALCsdl2Backend);
@@ -97,10 +97,9 @@ static void ALCsdl2Backend_audioCallback(void *ptr, Uint8* stream, int len)
ALsizei frameSize = FrameSizeFromDevFmt(
device->FmtChans, device->FmtType, device->AmbiOrder
);
+
assert(len % frameSize == 0);
- ALCsdl2Backend_lock(self);
aluMixData(device, stream, len / frameSize);
- ALCsdl2Backend_unlock(self);
}
static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name)
@@ -181,6 +180,16 @@ static void ALCsdl2Backend_stop(ALCsdl2Backend *self)
SDL_PauseAudioDevice(self->deviceID, 1);
}
+static void ALCsdl2Backend_lock(ALCsdl2Backend *self)
+{
+ SDL_LockAudioDevice(self->deviceID);
+}
+
+static void ALCsdl2Backend_unlock(ALCsdl2Backend *self)
+{
+ SDL_UnlockAudioDevice(self->deviceID);
+}
+
typedef struct ALCsdl2BackendFactory {
DERIVE_FROM_TYPE(ALCbackendFactory);