mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-20 11:02:52 +02:00
Implement move semantics for shared audio buffer
This commit is contained in:
@@ -30,5 +30,14 @@ AudioShmBuffer::~AudioShmBuffer() noexcept {
|
|||||||
// If either side drops this object then the buffer should always be
|
// If either side drops this object then the buffer should always be
|
||||||
// removed, so we'll do it on both sides to reduce the chance that we leak
|
// removed, so we'll do it on both sides to reduce the chance that we leak
|
||||||
// shared memory
|
// shared memory
|
||||||
boost::interprocess::shared_memory_object::remove(config.name.c_str());
|
if (!is_moved) {
|
||||||
|
boost::interprocess::shared_memory_object::remove(config.name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioShmBuffer::AudioShmBuffer(AudioShmBuffer&& o) noexcept
|
||||||
|
: config(std::move(o.config)),
|
||||||
|
shm(std::move(o.shm)),
|
||||||
|
buffer(std::move(o.buffer)) {
|
||||||
|
o.is_moved = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,12 @@ class AudioShmBuffer {
|
|||||||
*/
|
*/
|
||||||
~AudioShmBuffer() noexcept;
|
~AudioShmBuffer() noexcept;
|
||||||
|
|
||||||
|
AudioShmBuffer(const AudioShmBuffer&) = delete;
|
||||||
|
AudioShmBuffer& operator=(const AudioShmBuffer&) = delete;
|
||||||
|
|
||||||
|
AudioShmBuffer(AudioShmBuffer&&) noexcept;
|
||||||
|
AudioShmBuffer& operator=(AudioShmBuffer&&) = delete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a pointer to the part of the buffer where this input audio channel is
|
* Get a pointer to the part of the buffer where this input audio channel is
|
||||||
* stored in.
|
* stored in.
|
||||||
@@ -142,4 +148,6 @@ class AudioShmBuffer {
|
|||||||
private:
|
private:
|
||||||
boost::interprocess::shared_memory_object shm;
|
boost::interprocess::shared_memory_object shm;
|
||||||
boost::interprocess::mapped_region buffer;
|
boost::interprocess::mapped_region buffer;
|
||||||
|
|
||||||
|
bool is_moved = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user