diff options
author | Chris Robinson <[email protected]> | 2018-12-22 11:38:38 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-22 11:38:38 -0800 |
commit | 10ce121dbd05e048c89a2b7c32f2ddabbc8fbe77 (patch) | |
tree | 534a48d8776c2e7cac9ee275f040aeb78198a534 /Alc/backends/dsound.cpp | |
parent | b955c5cf5dbdc0814daa349e90907229774574aa (diff) |
Use a normal delete instead of ll_ringbuffer_free
And use RingBufferPtr in more places
Diffstat (limited to 'Alc/backends/dsound.cpp')
-rw-r--r-- | Alc/backends/dsound.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp index 5aa95f0f..26e561bf 100644 --- a/Alc/backends/dsound.cpp +++ b/Alc/backends/dsound.cpp @@ -655,7 +655,7 @@ struct ALCdsoundCapture final : public ALCbackend { DWORD BufferBytes{0u}; DWORD Cursor{0u}; - ll_ringbuffer_t *Ring{nullptr}; + RingBufferPtr Ring{nullptr}; }; void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device); @@ -681,9 +681,6 @@ void ALCdsoundCapture_Construct(ALCdsoundCapture *self, ALCdevice *device) void ALCdsoundCapture_Destruct(ALCdsoundCapture *self) { - ll_ringbuffer_free(self->Ring); - self->Ring = nullptr; - if(self->DSCbuffer) { self->DSCbuffer->Stop(); @@ -838,8 +835,8 @@ ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *deviceName) self->DSC->CreateCaptureBuffer(&DSCBDescription, &self->DSCbuffer, nullptr); if(SUCCEEDED(hr)) { - self->Ring = ll_ringbuffer_create(device->UpdateSize*device->NumUpdates, - InputType.Format.nBlockAlign, false); + self->Ring.reset(ll_ringbuffer_create(device->UpdateSize*device->NumUpdates, + InputType.Format.nBlockAlign, false)); if(!self->Ring) hr = DSERR_OUTOFMEMORY; } @@ -847,7 +844,6 @@ ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *deviceName) { ERR("Device init failed: 0x%08lx\n", hr); - ll_ringbuffer_free(self->Ring); self->Ring = nullptr; if(self->DSCbuffer) self->DSCbuffer->Release(); @@ -893,7 +889,7 @@ void ALCdsoundCapture_stop(ALCdsoundCapture *self) ALCenum ALCdsoundCapture_captureSamples(ALCdsoundCapture *self, ALCvoid *buffer, ALCuint samples) { - ll_ringbuffer_read(self->Ring, buffer, samples); + ll_ringbuffer_read(self->Ring.get(), buffer, samples); return ALC_NO_ERROR; } @@ -902,7 +898,7 @@ ALCuint ALCdsoundCapture_availableSamples(ALCdsoundCapture *self) ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; if(!device->Connected.load(std::memory_order_acquire)) - return static_cast<ALCuint>(ll_ringbuffer_read_space(self->Ring)); + return static_cast<ALCuint>(ll_ringbuffer_read_space(self->Ring.get())); ALsizei FrameSize{device->frameSizeFromFmt()}; DWORD BufferBytes{self->BufferBytes}; @@ -915,15 +911,15 @@ ALCuint ALCdsoundCapture_availableSamples(ALCdsoundCapture *self) if(SUCCEEDED(hr)) { DWORD NumBytes{(ReadCursor-LastCursor + BufferBytes) % BufferBytes}; - if(!NumBytes) return static_cast<ALCubyte>(ll_ringbuffer_read_space(self->Ring)); + if(!NumBytes) return static_cast<ALCubyte>(ll_ringbuffer_read_space(self->Ring.get())); hr = self->DSCbuffer->Lock(LastCursor, NumBytes, &ReadPtr1, &ReadCnt1, &ReadPtr2, &ReadCnt2, 0); } if(SUCCEEDED(hr)) { - ll_ringbuffer_write(self->Ring, ReadPtr1, ReadCnt1/FrameSize); + ll_ringbuffer_write(self->Ring.get(), ReadPtr1, ReadCnt1/FrameSize); if(ReadPtr2 != nullptr) - ll_ringbuffer_write(self->Ring, ReadPtr2, ReadCnt2/FrameSize); + ll_ringbuffer_write(self->Ring.get(), ReadPtr2, ReadCnt2/FrameSize); hr = self->DSCbuffer->Unlock(ReadPtr1, ReadCnt1, ReadPtr2, ReadCnt2); self->Cursor = (LastCursor+ReadCnt1+ReadCnt2) % BufferBytes; } @@ -934,7 +930,7 @@ ALCuint ALCdsoundCapture_availableSamples(ALCdsoundCapture *self) aluHandleDisconnect(device, "Failure retrieving capture data: 0x%lx", hr); } - return static_cast<ALCuint>(ll_ringbuffer_read_space(self->Ring)); + return static_cast<ALCuint>(ll_ringbuffer_read_space(self->Ring.get())); } } // namespace |