diff options
author | Chris Robinson <[email protected]> | 2018-11-19 04:11:21 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-19 04:11:21 -0800 |
commit | a14f39ea06a458e6b3b70e0428264967847da7f4 (patch) | |
tree | 9177828a3223568349a7e1b9e01560b7a45d181d | |
parent | c01743fe5df8ba4778950176ea38d95c65f25309 (diff) |
Make ll_ringbuffer_write/read take void*/const void*
-rw-r--r-- | Alc/alu.cpp | 6 | ||||
-rw-r--r-- | Alc/backends/coreaudio.cpp | 5 | ||||
-rw-r--r-- | Alc/backends/dsound.cpp | 8 | ||||
-rw-r--r-- | Alc/backends/portaudio.cpp | 4 | ||||
-rw-r--r-- | Alc/backends/winmm.cpp | 2 | ||||
-rw-r--r-- | Alc/mixvoice.cpp | 2 | ||||
-rw-r--r-- | Alc/ringbuffer.cpp | 15 | ||||
-rw-r--r-- | Alc/ringbuffer.h | 6 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 2 | ||||
-rw-r--r-- | OpenAL32/event.cpp | 6 |
10 files changed, 28 insertions, 28 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index f9a53139..b4b34e5f 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -186,7 +186,7 @@ static void SendSourceStoppedEvent(ALCcontext *context, ALuint id) } strcpy(evt.u.user.msg+strpos, " state changed to AL_STOPPED"); - if(ll_ringbuffer_write(context->AsyncEvents, (const char*)&evt, 1) == 1) + if(ll_ringbuffer_write(context->AsyncEvents, &evt, 1) == 1) alsem_post(&context->EventSem); } @@ -433,7 +433,7 @@ static bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool f slot->Params.EffectState = state; props->State = NULL; - if(LIKELY(ll_ringbuffer_write(context->AsyncEvents, (const char*)&evt, 1) != 0)) + if(LIKELY(ll_ringbuffer_write(context->AsyncEvents, &evt, 1) != 0)) alsem_post(&context->EventSem); else { @@ -1847,7 +1847,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) ALsizei i; if((enabledevt&EventType_Disconnected) && - ll_ringbuffer_write(ctx->AsyncEvents, (const char*)&evt, 1) == 1) + ll_ringbuffer_write(ctx->AsyncEvents, &evt, 1) == 1) alsem_post(&ctx->EventSem); for(i = 0;i < ctx->VoiceCount;i++) diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp index 158331f1..ff02a706 100644 --- a/Alc/backends/coreaudio.cpp +++ b/Alc/backends/coreaudio.cpp @@ -420,8 +420,7 @@ static OSStatus ALCcoreAudioCapture_RecordProc(void *inRefCon, return err; } - ll_ringbuffer_write(self->ring, static_cast<const char*>(self->bufferList->mBuffers[0].mData), - inNumberFrames); + ll_ringbuffer_write(self->ring, self->bufferList->mBuffers[0].mData, inNumberFrames); return noErr; } @@ -433,7 +432,7 @@ static OSStatus ALCcoreAudioCapture_ConvertCallback(AudioConverterRef UNUSED(inA ALCcoreAudioCapture *self = reinterpret_cast<ALCcoreAudioCapture*>(inUserData); // Read from the ring buffer and store temporarily in a large buffer - ll_ringbuffer_read(self->ring, static_cast<char*>(self->resampleBuffer), *ioNumberDataPackets); + ll_ringbuffer_read(self->ring, self->resampleBuffer, *ioNumberDataPackets); // Set the input data ioData->mNumberBuffers = 1; diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp index 6a8b0754..085dab90 100644 --- a/Alc/backends/dsound.cpp +++ b/Alc/backends/dsound.cpp @@ -893,7 +893,7 @@ void ALCdsoundCapture_stop(ALCdsoundCapture *self) ALCenum ALCdsoundCapture_captureSamples(ALCdsoundCapture *self, ALCvoid *buffer, ALCuint samples) { - ll_ringbuffer_read(self->Ring, reinterpret_cast<char*>(buffer), samples); + ll_ringbuffer_read(self->Ring, buffer, samples); return ALC_NO_ERROR; } @@ -921,11 +921,9 @@ ALCuint ALCdsoundCapture_availableSamples(ALCdsoundCapture *self) } if(SUCCEEDED(hr)) { - ll_ringbuffer_write(self->Ring, reinterpret_cast<const char*>(ReadPtr1), - ReadCnt1/FrameSize); + ll_ringbuffer_write(self->Ring, ReadPtr1, ReadCnt1/FrameSize); if(ReadPtr2 != nullptr) - ll_ringbuffer_write(self->Ring, reinterpret_cast<const char*>(ReadPtr2), - ReadCnt2/FrameSize); + ll_ringbuffer_write(self->Ring, ReadPtr2, ReadCnt2/FrameSize); hr = self->DSCbuffer->Unlock(ReadPtr1, ReadCnt1, ReadPtr2, ReadCnt2); self->Cursor = (LastCursor+ReadCnt1+ReadCnt2) % BufferBytes; } diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp index 1a74250e..1c87f2c8 100644 --- a/Alc/backends/portaudio.cpp +++ b/Alc/backends/portaudio.cpp @@ -377,7 +377,7 @@ int ALCportCapture_ReadCallback(const void *inputBuffer, void *UNUSED(outputBuff size_t writable = ll_ringbuffer_write_space(self->ring); if(framesPerBuffer > writable) framesPerBuffer = writable; - ll_ringbuffer_write(self->ring, static_cast<const char*>(inputBuffer), framesPerBuffer); + ll_ringbuffer_write(self->ring, inputBuffer, framesPerBuffer); return 0; } @@ -472,7 +472,7 @@ ALCuint ALCportCapture_availableSamples(ALCportCapture *self) ALCenum ALCportCapture_captureSamples(ALCportCapture *self, ALCvoid *buffer, ALCuint samples) { - ll_ringbuffer_read(self->ring, static_cast<char*>(buffer), samples); + ll_ringbuffer_read(self->ring, buffer, samples); return ALC_NO_ERROR; } diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp index 9da3e4c3..f17b5d1f 100644 --- a/Alc/backends/winmm.cpp +++ b/Alc/backends/winmm.cpp @@ -653,7 +653,7 @@ void ALCwinmmCapture_stop(ALCwinmmCapture *self) ALCenum ALCwinmmCapture_captureSamples(ALCwinmmCapture *self, ALCvoid *buffer, ALCuint samples) { - ll_ringbuffer_read(self->Ring, static_cast<char*>(buffer), samples); + ll_ringbuffer_read(self->Ring, buffer, samples); return ALC_NO_ERROR; } diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index f89b6efa..c83fb8a7 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -201,7 +201,7 @@ static void SendAsyncEvent(ALCcontext *context, ALuint enumtype, ALenum type, evt.u.user.id = objid; evt.u.user.param = param; strcpy(evt.u.user.msg, msg); - if(ll_ringbuffer_write(context->AsyncEvents, (const char*)&evt, 1) == 1) + if(ll_ringbuffer_write(context->AsyncEvents, &evt, 1) == 1) alsem_post(&context->EventSem); } diff --git a/Alc/ringbuffer.cpp b/Alc/ringbuffer.cpp index 4fa52468..4d40ec93 100644 --- a/Alc/ringbuffer.cpp +++ b/Alc/ringbuffer.cpp @@ -105,7 +105,7 @@ size_t ll_ringbuffer_write_space(const ll_ringbuffer_t *rb) } -size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, char *dest, size_t cnt) +size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, void *dest, size_t cnt) { size_t read_ptr; size_t free_cnt; @@ -135,7 +135,8 @@ size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, char *dest, size_t cnt) read_ptr += n1; if(n2) { - memcpy(dest + n1*rb->elem_size, &rb->buf[(read_ptr&rb->size_mask)*rb->elem_size], + memcpy(static_cast<char*>(dest) + n1*rb->elem_size, + &rb->buf[(read_ptr&rb->size_mask)*rb->elem_size], n2*rb->elem_size); read_ptr += n2; } @@ -143,7 +144,7 @@ size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, char *dest, size_t cnt) return to_read; } -size_t ll_ringbuffer_peek(ll_ringbuffer_t *rb, char *dest, size_t cnt) +size_t ll_ringbuffer_peek(ll_ringbuffer_t *rb, void *dest, size_t cnt) { size_t free_cnt; size_t cnt2; @@ -173,13 +174,14 @@ size_t ll_ringbuffer_peek(ll_ringbuffer_t *rb, char *dest, size_t cnt) if(n2) { read_ptr += n1; - memcpy(dest + n1*rb->elem_size, &rb->buf[(read_ptr&rb->size_mask)*rb->elem_size], + memcpy(static_cast<char*>(dest) + n1*rb->elem_size, + &rb->buf[(read_ptr&rb->size_mask)*rb->elem_size], n2*rb->elem_size); } return to_read; } -size_t ll_ringbuffer_write(ll_ringbuffer_t *rb, const char *src, size_t cnt) +size_t ll_ringbuffer_write(ll_ringbuffer_t *rb, const void *src, size_t cnt) { size_t write_ptr; size_t free_cnt; @@ -209,7 +211,8 @@ size_t ll_ringbuffer_write(ll_ringbuffer_t *rb, const char *src, size_t cnt) write_ptr += n1; if(n2) { - memcpy(&rb->buf[(write_ptr&rb->size_mask)*rb->elem_size], src + n1*rb->elem_size, + memcpy(&rb->buf[(write_ptr&rb->size_mask)*rb->elem_size], + static_cast<const char*>(src) + n1*rb->elem_size, n2*rb->elem_size); write_ptr += n2; } diff --git a/Alc/ringbuffer.h b/Alc/ringbuffer.h index 0d05ec84..521d96cb 100644 --- a/Alc/ringbuffer.h +++ b/Alc/ringbuffer.h @@ -48,12 +48,12 @@ size_t ll_ringbuffer_read_space(const ll_ringbuffer_t *rb); * The copying data reader. Copy at most `cnt' elements from `rb' to `dest'. * Returns the actual number of elements copied. */ -size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, char *dest, size_t cnt); +size_t ll_ringbuffer_read(ll_ringbuffer_t *rb, void *dest, size_t cnt); /** * The copying data reader w/o read pointer advance. Copy at most `cnt' * elements from `rb' to `dest'. Returns the actual number of elements copied. */ -size_t ll_ringbuffer_peek(ll_ringbuffer_t *rb, char *dest, size_t cnt); +size_t ll_ringbuffer_peek(ll_ringbuffer_t *rb, void *dest, size_t cnt); /** Advance the read pointer `cnt' places. */ void ll_ringbuffer_read_advance(ll_ringbuffer_t *rb, size_t cnt); @@ -66,7 +66,7 @@ size_t ll_ringbuffer_write_space(const ll_ringbuffer_t *rb); * The copying data writer. Copy at most `cnt' elements to `rb' from `src'. * Returns the actual number of elements copied. */ -size_t ll_ringbuffer_write(ll_ringbuffer_t *rb, const char *src, size_t cnt); +size_t ll_ringbuffer_write(ll_ringbuffer_t *rb, const void *src, size_t cnt); /** Advance the write pointer `cnt' places. */ void ll_ringbuffer_write_advance(ll_ringbuffer_t *rb, size_t cnt); diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 539a5f4f..39f70ab5 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -249,7 +249,7 @@ static void SendStateChangeEvent(ALCcontext *context, ALuint id, ALenum state) * and we don't want state change messages to occur out of order, so send * it through the async queue to ensure proper ordering. */ - if(ll_ringbuffer_write(context->AsyncEvents, (const char*)&evt, 1) == 1) + if(ll_ringbuffer_write(context->AsyncEvents, &evt, 1) == 1) alsem_post(&context->EventSem); } diff --git a/OpenAL32/event.cpp b/OpenAL32/event.cpp index fcbcba66..1dc2745f 100644 --- a/OpenAL32/event.cpp +++ b/OpenAL32/event.cpp @@ -21,7 +21,7 @@ static int EventThread(ALCcontext *context) while(LIKELY(!quitnow)) { AsyncEvent evt; - if(ll_ringbuffer_read(context->AsyncEvents, (char*)&evt, 1) == 0) + if(ll_ringbuffer_read(context->AsyncEvents, &evt, 1) == 0) { alsem_wait(&context->EventSem); continue; @@ -43,7 +43,7 @@ static int EventThread(ALCcontext *context) context->EventCb(evt.u.user.type, evt.u.user.id, evt.u.user.param, (ALsizei)strlen(evt.u.user.msg), evt.u.user.msg, context->EventParam ); - } while(ll_ringbuffer_read(context->AsyncEvents, (char*)&evt, 1) != 0); + } while(ll_ringbuffer_read(context->AsyncEvents, &evt, 1) != 0); } return 0; } @@ -64,7 +64,7 @@ void StartEventThrd(ALCcontext *ctx) void StopEventThrd(ALCcontext *ctx) { static constexpr AsyncEvent kill_evt = ASYNC_EVENT(EventType_KillThread); - while(ll_ringbuffer_write(ctx->AsyncEvents, (const char*)&kill_evt, 1) == 0) + while(ll_ringbuffer_write(ctx->AsyncEvents, &kill_evt, 1) == 0) althrd_yield(); alsem_post(&ctx->EventSem); if(ctx->EventThread.joinable()) |