diff options
author | Chris Robinson <[email protected]> | 2020-12-05 03:28:19 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-05 03:28:19 -0800 |
commit | 8a352d25f96faf570cf8c3a2ee1f11a30d9ae0fe (patch) | |
tree | 2ce45a5170beeb50cf947cf53e7f544a0c0739fd | |
parent | 2b919eac78cd6ebe07d6ca7cd01450e6f1aea75b (diff) |
Move the ringbuffer to common
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | common/ringbuffer.cpp (renamed from alc/ringbuffer.cpp) | 12 | ||||
-rw-r--r-- | common/ringbuffer.h (renamed from alc/ringbuffer.h) | 10 |
3 files changed, 8 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d74c3f75..ca776f4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -585,6 +585,8 @@ set(COMMON_OBJS common/polyphase_resampler.cpp common/polyphase_resampler.h common/pragmadefs.h + common/ringbuffer.cpp + common/ringbuffer.h common/strutils.cpp common/strutils.h common/threads.cpp @@ -693,8 +695,6 @@ set(ALC_OBJS alc/inprogext.h alc/logging.h alc/panning.cpp - alc/ringbuffer.cpp - alc/ringbuffer.h alc/uiddefs.cpp alc/voice.cpp alc/voice.h diff --git a/alc/ringbuffer.cpp b/common/ringbuffer.cpp index 5d891dbe..91857499 100644 --- a/alc/ringbuffer.cpp +++ b/common/ringbuffer.cpp @@ -24,7 +24,6 @@ #include <algorithm> #include <climits> -#include <cstdint> #include <stdexcept> #include "almalloc.h" @@ -161,17 +160,6 @@ size_t RingBuffer::write(const void *src, size_t cnt) noexcept } -void RingBuffer::readAdvance(size_t cnt) noexcept -{ - mReadPtr.fetch_add(cnt, std::memory_order_acq_rel); -} - -void RingBuffer::writeAdvance(size_t cnt) noexcept -{ - mWritePtr.fetch_add(cnt, std::memory_order_acq_rel); -} - - ll_ringbuffer_data_pair RingBuffer::getReadVector() const noexcept { ll_ringbuffer_data_pair ret; diff --git a/alc/ringbuffer.h b/common/ringbuffer.h index 32fb951c..fa8fce10 100644 --- a/alc/ringbuffer.h +++ b/common/ringbuffer.h @@ -1,10 +1,9 @@ #ifndef RINGBUFFER_H #define RINGBUFFER_H -#include <stddef.h> - #include <atomic> #include <memory> +#include <stddef.h> #include <utility> #include "albyte.h" @@ -75,7 +74,9 @@ public: */ size_t peek(void *dest, size_t cnt) const noexcept; /** Advance the read pointer `cnt' places. */ - void readAdvance(size_t cnt) noexcept; + void readAdvance(size_t cnt) noexcept + { mReadPtr.fetch_add(cnt, std::memory_order_acq_rel); } + /** * Return the number of elements available for writing. This is the number @@ -94,7 +95,8 @@ public: */ size_t write(const void *src, size_t cnt) noexcept; /** Advance the write pointer `cnt' places. */ - void writeAdvance(size_t cnt) noexcept; + void writeAdvance(size_t cnt) noexcept + { mWritePtr.fetch_add(cnt, std::memory_order_acq_rel); } /** * Create a new ringbuffer to hold at least `sz' elements of `elem_sz' |