From 340d376564aef42ac92567b3a2e5165bf24a77a6 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 11 Jun 2021 12:58:46 +0200 Subject: [PATCH] Add constant overloads for audio buffer pointers --- src/common/audio-shm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/common/audio-shm.h b/src/common/audio-shm.h index 5a156992..0608e737 100644 --- a/src/common/audio-shm.h +++ b/src/common/audio-shm.h @@ -145,6 +145,13 @@ class AudioShmBuffer { config.input_offsets[bus][channel]; } + template + const T* input_channel_ptr(const uint32_t bus, + const uint32_t channel) const noexcept { + return reinterpret_cast(buffer.get_address()) + + config.input_offsets[bus][channel]; + } + /** * Get a pointer to the part of the buffer where this output audio channel * is stored in. Both the bus and the channel indices start at zero. These @@ -156,6 +163,13 @@ class AudioShmBuffer { config.output_offsets[bus][channel]; } + template + const T* output_channel_ptr(const uint32_t bus, + const uint32_t channel) const noexcept { + return reinterpret_cast(buffer.get_address()) + + config.output_offsets[bus][channel]; + } + Config config; private: