From 7ca44cb8800a2800e58fadd0267416224650e08d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 23 May 2012 00:57:57 +0000 Subject: Fix crash when loading polyphonic patches. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4442 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/PatchView.cpp | 13 +++++++++---- src/server/PatchImpl.cpp | 10 +++++----- src/server/PatchImpl.hpp | 6 ++++-- src/server/events/SetMetadata.cpp | 9 +++++---- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp index d8e00ac2..b3b79ddf 100644 --- a/src/gui/PatchView.cpp +++ b/src/gui/PatchView.cpp @@ -171,10 +171,15 @@ PatchView::process_toggled() void PatchView::poly_changed() { - _app->interface()->set_property( - _patch->path(), - _app->uris().ingen_polyphony, - _app->forge().make(_poly_spin->get_value_as_int())); + const int poly = _poly_spin->get_value_as_int(); + if (_enable_signal && poly != (int)_patch->internal_poly()) { + std::cerr << "POLY SPIN CHANGE " << _patch->internal_poly() + << " => " << poly << std::endl; + _app->interface()->set_property( + _patch->path(), + _app->uris().ingen_polyphony, + _app->forge().make(poly)); + } } void diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp index 43a8ea01..bd12f78a 100644 --- a/src/server/PatchImpl.cpp +++ b/src/server/PatchImpl.cpp @@ -49,7 +49,8 @@ PatchImpl::PatchImpl(Engine& engine, "patch", "Ingen Patch"), symbol, poly, parent, srate) , _engine(engine) - , _internal_poly(internal_poly) + , _poly_pre(internal_poly) + , _poly_process(internal_poly) , _compiled_patch(NULL) , _process(false) { @@ -109,6 +110,7 @@ PatchImpl::prepare_internal_poly(BufferFactory& bufs, uint32_t poly) for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) (*i)->prepare_poly(bufs, poly); + _poly_pre = poly; return true; } @@ -132,12 +134,11 @@ PatchImpl::apply_internal_poly(ProcessContext& context, } } - const bool polyphonic = parent_patch() && (poly == parent_patch()->internal_poly()); + const bool polyphonic = parent_patch() && (poly == parent_patch()->internal_poly_process()); for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) (*i)->setup_buffers(context, bufs, polyphonic ? poly : 1); - _internal_poly = poly; - + _poly_process = poly; return true; } @@ -267,7 +268,6 @@ PatchImpl::add_node(Nodes::Node* ln) assert(ln != NULL); assert(ln->elem() != NULL); assert(ln->elem()->parent_patch() == this); - //assert(ln->elem()->polyphony() == _internal_poly); _nodes.push_back(ln); } diff --git a/src/server/PatchImpl.hpp b/src/server/PatchImpl.hpp index 557f0343..d1b11187 100644 --- a/src/server/PatchImpl.hpp +++ b/src/server/PatchImpl.hpp @@ -152,7 +152,8 @@ public: void enable() { _process = true; } void disable(ProcessContext& context); - uint32_t internal_poly() const { return _internal_poly; } + uint32_t internal_poly() const { return _poly_pre; } + uint32_t internal_poly_process() const { return _poly_process; } private: inline void compile_recursive(NodeImpl* n, CompiledPatch* output) const; @@ -160,7 +161,8 @@ private: void process_single(ProcessContext& context); Engine& _engine; - uint32_t _internal_poly; + uint32_t _poly_pre; ///< Pre-process thread only + uint32_t _poly_process; ///< Process thread only CompiledPatch* _compiled_patch; ///< Process thread only Edges _edges; ///< Pre-process thread only Ports _inputs; ///< Pre-process thread only diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp index e8cce384..cc2ae563 100644 --- a/src/server/events/SetMetadata.cpp +++ b/src/server/events/SetMetadata.cpp @@ -303,16 +303,17 @@ SetMetadata::execute(ProcessContext& context) case POLYPHONIC: { PatchImpl* parent = reinterpret_cast(object->parent()); if (value.get_bool()) { - object->apply_poly(context, *_engine.maid(), parent->internal_poly()); + object->apply_poly( + context, *_engine.maid(), parent->internal_poly_process()); } else { object->apply_poly(context, *_engine.maid(), 1); } } break; case POLYPHONY: - if (_patch->internal_poly() != static_cast(value.get_int32()) && - !_patch->apply_internal_poly(context, + if (!_patch->apply_internal_poly(context, *_engine.buffer_factory(), - *_engine.maid(), value.get_int32())) { + *_engine.maid(), + value.get_int32())) { _status = INTERNAL_ERROR; } break; -- cgit v1.2.1