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.
This commit is contained in:
Robbert van der Helm
2021-06-10 14:33:28 +02:00
parent 0370c64f99
commit f99781c1b2
+6 -4
View File
@@ -70,8 +70,10 @@ class AudioShmBuffer {
std::string name; std::string name;
/** /**
* The size of the shared memory object. This should be large enough to * The size of the shared memory object **in bytes** (so not samples).
* hold all input and output buffers. * 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; uint32_t size;
@@ -138,7 +140,7 @@ class AudioShmBuffer {
* addresses might change after a call to `resize()`. * addresses might change after a call to `resize()`.
*/ */
template <typename T> template <typename T>
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<T*>(buffer.get_address()) + return reinterpret_cast<T*>(buffer.get_address()) +
config.input_offsets[bus][channel]; config.input_offsets[bus][channel];
} }
@@ -149,7 +151,7 @@ class AudioShmBuffer {
* addresses might change after a call to `resize()`. * addresses might change after a call to `resize()`.
*/ */
template <typename T> template <typename T>
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<T*>(buffer.get_address()) + return reinterpret_cast<T*>(buffer.get_address()) +
config.output_offsets[bus][channel]; config.output_offsets[bus][channel];
} }