aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-06-30 07:42:09 -0700
committerChris Robinson <[email protected]>2015-06-30 07:42:09 -0700
commitc24f4f230fda217641cc9484c03b0a2053185228 (patch)
tree233469c34f6164ed3e947a098fdd2991f0f63b7b
parente5964d6dc4b711a4743c799ffbc8e0c914e27db6 (diff)
Use the lockless ringbuffer for mmdevapi capture
The backend's capture funcs are already called while under a lock, so multiple threads shouldn't be able to read from it at once.
-rw-r--r--Alc/backends/mmdevapi.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 963ff7c8..3a4bde5c 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -1123,7 +1123,7 @@ typedef struct ALCmmdevCapture {
HANDLE MsgEvent;
- RingBuffer *Ring;
+ ll_ringbuffer_t *Ring;
volatile int killNow;
althrd_t thread;
@@ -1177,7 +1177,7 @@ static void ALCmmdevCapture_Construct(ALCmmdevCapture *self, ALCdevice *device)
static void ALCmmdevCapture_Destruct(ALCmmdevCapture *self)
{
- DestroyRingBuffer(self->Ring);
+ ll_ringbuffer_free(self->Ring);
self->Ring = NULL;
if(self->NotifyEvent != NULL)
@@ -1236,7 +1236,7 @@ FORCE_ALIGN int ALCmmdevCapture_recordProc(void *arg)
break;
}
- WriteRingBuffer(self->Ring, data, numsamples);
+ ll_ringbuffer_write(self->Ring, (char*)data, numsamples);
hr = IAudioCaptureClient_ReleaseBuffer(self->capture, numsamples);
if(FAILED(hr))
@@ -1398,7 +1398,7 @@ static void ALCmmdevCapture_close(ALCmmdevCapture *self)
if(PostThreadMessage(ThreadID, WM_USER_CloseDevice, (WPARAM)&req, (LPARAM)STATIC_CAST(ALCmmdevProxy, self)))
(void)WaitForResponse(&req);
- DestroyRingBuffer(self->Ring);
+ ll_ringbuffer_free(self->Ring);
self->Ring = NULL;
CloseHandle(self->MsgEvent);
@@ -1566,8 +1566,9 @@ static HRESULT ALCmmdevCapture_resetProxy(ALCmmdevCapture *self)
return hr;
}
- buffer_len = maxu(device->UpdateSize*device->NumUpdates, buffer_len);
- self->Ring = CreateRingBuffer(OutputType.Format.nBlockAlign, buffer_len);
+ buffer_len = maxu(device->UpdateSize*device->NumUpdates + 1, buffer_len);
+ ll_ringbuffer_free(self->Ring);
+ self->Ring = ll_ringbuffer_create(buffer_len, OutputType.Format.nBlockAlign);
if(!self->Ring)
{
ERR("Failed to allocate capture ring buffer\n");
@@ -1659,14 +1660,14 @@ static void ALCmmdevCapture_stopProxy(ALCmmdevCapture *self)
ALuint ALCmmdevCapture_availableSamples(ALCmmdevCapture *self)
{
- return RingBufferSize(self->Ring);
+ return ll_ringbuffer_read_space(self->Ring);
}
ALCenum ALCmmdevCapture_captureSamples(ALCmmdevCapture *self, ALCvoid *buffer, ALCuint samples)
{
if(ALCmmdevCapture_availableSamples(self) < samples)
return ALC_INVALID_VALUE;
- ReadRingBuffer(self->Ring, buffer, samples);
+ ll_ringbuffer_read(self->Ring, buffer, samples);
return ALC_NO_ERROR;
}