From f99781c1b2de5f6976f87fdcf6149fe0d5b0d1ed Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 10 Jun 2021 14:33:28 +0200 Subject: [PATCH] Make getting channel pointers noexcept There should be no bounds checks in release mode anyways, and we'll trust ourselves that this will be a simple lookup. --- src/common/audio-shm.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/audio-shm.h b/src/common/audio-shm.h index cc8a3ee0..5a156992 100644 --- a/src/common/audio-shm.h +++ b/src/common/audio-shm.h @@ -70,8 +70,10 @@ class AudioShmBuffer { std::string name; /** - * The size of the shared memory object. This should be large enough to - * hold all input and output buffers. + * The size of the shared memory object **in bytes** (so not samples). + * This should be large enough to hold all input and output buffers, and + * it depends on whether the host is going to pass 32-bit single + * precision or 64-bit double precision audio to the plugin. */ uint32_t size; @@ -138,7 +140,7 @@ class AudioShmBuffer { * addresses might change after a call to `resize()`. */ template - T* input_channel_ptr(const uint32_t bus, const uint32_t channel) { + T* input_channel_ptr(const uint32_t bus, const uint32_t channel) noexcept { return reinterpret_cast(buffer.get_address()) + config.input_offsets[bus][channel]; } @@ -149,7 +151,7 @@ class AudioShmBuffer { * addresses might change after a call to `resize()`. */ template - T* output_channel_ptr(const uint32_t bus, const uint32_t channel) { + T* output_channel_ptr(const uint32_t bus, const uint32_t channel) noexcept { return reinterpret_cast(buffer.get_address()) + config.output_offsets[bus][channel]; }