summaryrefslogtreecommitdiffstats
path: root/src/server/LV2Block.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-02-12 15:04:20 +0100
committerDavid Robillard <d@drobilla.net>2017-02-12 15:31:47 +0100
commitb1198f0842e6e4d6b1c01f07d91b42ef4a212788 (patch)
tree93fdf4da89a6f5f634707fb8c989e0d9ee1a3c65 /src/server/LV2Block.hpp
parent81d45973412c675e3c0b4a10b64d811a219feeae (diff)
downloadingen-b1198f0842e6e4d6b1c01f07d91b42ef4a212788.tar.gz
ingen-b1198f0842e6e4d6b1c01f07d91b42ef4a212788.tar.bz2
ingen-b1198f0842e6e4d6b1c01f07d91b42ef4a212788.zip
Use smart pointers to handle real-time memory disposal
Diffstat (limited to 'src/server/LV2Block.hpp')
-rw-r--r--src/server/LV2Block.hpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp
index b6be8ccf..2ccde602 100644
--- a/src/server/LV2Block.hpp
+++ b/src/server/LV2Block.hpp
@@ -58,7 +58,7 @@ public:
GraphImpl* parent);
bool prepare_poly(BufferFactory& bufs, uint32_t poly);
- bool apply_poly(RunContext& context, Raul::Maid& maid, uint32_t poly);
+ bool apply_poly(RunContext& context, uint32_t poly);
void activate(BufferFactory& bufs);
void deactivate();
@@ -83,16 +83,32 @@ public:
static LilvState* load_state(World* world, const std::string& path);
protected:
- SPtr<LilvInstance> make_instance(URIs& uris,
- SampleRate rate,
- uint32_t voice,
- bool preparing);
+ struct Instance : public Raul::Noncopyable {
+ explicit Instance(LilvInstance* i) : instance(i) {}
+
+ ~Instance() { lilv_instance_free(instance); }
+
+ LilvInstance* const instance;
+ };
+
+ SPtr<Instance> make_instance(URIs& uris,
+ SampleRate rate,
+ uint32_t voice,
+ bool preparing);
inline LilvInstance* instance(uint32_t voice) {
- return (LilvInstance*)(*_instances)[voice].get();
+ return (LilvInstance*)(*_instances)[voice]->instance;
}
- typedef Raul::Array< SPtr<void> > Instances;
+ typedef Raul::Array< SPtr<Instance> > Instances;
+
+ void drop_instances(const MPtr<Instances>& instances) {
+ if (instances) {
+ for (size_t i = 0; i < instances->size(); ++i) {
+ (*instances)[i].reset();
+ }
+ }
+ }
struct Response : public Raul::Maid::Disposable
, public Raul::Noncopyable
@@ -122,8 +138,8 @@ protected:
LV2_Worker_Respond_Handle handle, uint32_t size, const void* data);
LV2Plugin* _lv2_plugin;
- Instances* _instances;
- Instances* _prepared_instances;
+ MPtr<Instances> _instances;
+ MPtr<Instances> _prepared_instances;
const LV2_Worker_Interface* _worker_iface;
std::mutex _work_mutex;
Responses _responses;