diff --git a/libs/surfaces/websockets/dispatcher.cc b/libs/surfaces/websockets/dispatcher.cc index d41afc464c..e4dec90f72 100644 --- a/libs/surfaces/websockets/dispatcher.cc +++ b/libs/surfaces/websockets/dispatcher.cc @@ -57,8 +57,8 @@ void WebsocketsDispatcher::update_all_nodes (Client client) { for (ArdourMixer::StripMap::iterator it = mixer().strips().begin(); it != mixer().strips().end(); ++it) { - uint32_t strip_id = it->first; - ArdourMixerStrip& strip = it->second; + uint32_t strip_id = it->first; + ArdourMixerStrip& strip = *it->second; AddressVector strip_addr = AddressVector (); strip_addr.push_back (strip_id); @@ -81,7 +81,7 @@ WebsocketsDispatcher::update_all_nodes (Client client) for (ArdourMixerStrip::PluginMap::iterator it = strip.plugins ().begin (); it != strip.plugins ().end (); ++it) { uint32_t plugin_id = it->first; - boost::shared_ptr insert = it->second.insert (); + boost::shared_ptr insert = it->second->insert (); boost::shared_ptr plugin = insert->plugin (); update (client, Node::strip_plugin_description, strip_id, plugin_id, diff --git a/libs/surfaces/websockets/feedback.cc b/libs/surfaces/websockets/feedback.cc index 01524d4e38..48c332c730 100644 --- a/libs/surfaces/websockets/feedback.cc +++ b/libs/surfaces/websockets/feedback.cc @@ -172,8 +172,8 @@ ArdourFeedback::poll () const Glib::Threads::Mutex::Lock lock (mixer ().mutex ()); for (ArdourMixer::StripMap::iterator it = mixer ().strips ().begin (); it != mixer ().strips ().end (); ++it) { - float db = it->second.meter_level_db (); - update_all (Node::strip_meter, it->first, static_cast (db)); + double db = it->second->meter_level_db (); + update_all (Node::strip_meter, it->first, db); } return true; @@ -195,11 +195,11 @@ void ArdourFeedback::observe_mixer () { for (ArdourMixer::StripMap::iterator it = mixer().strips().begin(); it != mixer().strips().end(); ++it) { - uint32_t strip_id = it->first; - ArdourMixerStrip& strip = it->second; + uint32_t strip_id = it->first; + boost::shared_ptr strip = it->second; - boost::shared_ptr stripable = strip.stripable (); - boost::shared_ptr connections = it->second.connections (); + boost::shared_ptr stripable = strip->stripable (); + boost::shared_ptr connections = it->second->connections (); stripable->gain_control ()->Changed.connect (*connections, MISSING_INVALIDATOR, boost::bind (StripGainObserver (), this, strip_id), event_loop ()); @@ -212,7 +212,7 @@ ArdourFeedback::observe_mixer () stripable->mute_control ()->Changed.connect (*connections, MISSING_INVALIDATOR, boost::bind (StripMuteObserver (), this, strip_id), event_loop ()); - observe_strip_plugins (strip_id, strip.plugins ()); + observe_strip_plugins (strip_id, strip->plugins ()); } } @@ -221,9 +221,9 @@ ArdourFeedback::observe_strip_plugins (uint32_t strip_id, ArdourMixerStrip::Plug { for (ArdourMixerStrip::PluginMap::iterator it = plugins.begin(); it != plugins.end(); ++it) { uint32_t plugin_id = it->first; - ArdourMixerPlugin& plugin = it->second; - boost::shared_ptr insert = plugin.insert (); - boost::shared_ptr connections = plugin.connections (); + boost::shared_ptr plugin = it->second; + boost::shared_ptr insert = plugin->insert (); + boost::shared_ptr connections = plugin->connections (); uint32_t bypass = insert->plugin ()->designated_bypass_port (); Evoral::Parameter param = Evoral::Parameter (PluginAutomation, 0, bypass); boost::shared_ptr control = insert->automation_control (param); @@ -233,11 +233,11 @@ ArdourFeedback::observe_strip_plugins (uint32_t strip_id, ArdourMixerStrip::Plug boost::bind (PluginBypassObserver (), this, strip_id, plugin_id), event_loop ()); } - for (uint32_t param_id = 0; param_id < plugin.param_count (); ++param_id) { + for (uint32_t param_id = 0; param_id < plugin->param_count (); ++param_id) { try { - boost::shared_ptr control = plugin.param_control (param_id); + boost::shared_ptr control = plugin->param_control (param_id); - control->Changed.connect (*plugin.connections (), MISSING_INVALIDATOR, + control->Changed.connect (*plugin->connections (), MISSING_INVALIDATOR, boost::bind (PluginParamValueObserver (), this, strip_id, plugin_id, param_id, boost::weak_ptr(control)), event_loop ()); diff --git a/libs/surfaces/websockets/mixer.cc b/libs/surfaces/websockets/mixer.cc index d11ed8febe..b4a9ba3442 100644 --- a/libs/surfaces/websockets/mixer.cc +++ b/libs/surfaces/websockets/mixer.cc @@ -31,12 +31,11 @@ using namespace ArdourSurface; ArdourMixerPlugin::ArdourMixerPlugin (boost::shared_ptr insert) : _insert (insert) - , _connections (boost::shared_ptr (new PBD::ScopedConnectionList())) {} ArdourMixerPlugin::~ArdourMixerPlugin () { - _connections->drop_connections (); + drop_connections (); } boost::shared_ptr @@ -45,12 +44,6 @@ ArdourMixerPlugin::insert () const return _insert; } -boost::shared_ptr -ArdourMixerPlugin::connections () const -{ - return _connections; -} - bool ArdourMixerPlugin::enabled () const { @@ -127,7 +120,6 @@ ArdourMixerPlugin::param_value (boost::shared_ptr con ArdourMixerStrip::ArdourMixerStrip (boost::shared_ptr stripable, PBD::EventLoop* event_loop) : _stripable (stripable) - , _connections (boost::shared_ptr (new PBD::ScopedConnectionList())) { if (is_vca ()) { /* no plugins to handle */ @@ -150,17 +142,16 @@ ArdourMixerStrip::ArdourMixerStrip (boost::shared_ptr stripab boost::shared_ptr insert = boost::static_pointer_cast (processor); if (insert) { - ArdourMixerPlugin plugin (insert); - plugin.insert ()->DropReferences.connect (*plugin.connections (), MISSING_INVALIDATOR, - boost::bind (&ArdourMixerStrip::on_drop_plugin, this, plugin_id), event_loop); - _plugins.emplace (plugin_id, plugin); + _plugins[plugin_id] = boost::shared_ptr (new ArdourMixerPlugin (insert)); + insert->DropReferences.connect (*_plugins[plugin_id], MISSING_INVALIDATOR, + boost::bind (&ArdourMixerStrip::on_drop_plugin, this, plugin_id), event_loop); } } } ArdourMixerStrip::~ArdourMixerStrip () { - _connections->drop_connections (); + drop_connections (); } boost::shared_ptr @@ -169,12 +160,6 @@ ArdourMixerStrip::stripable () const return _stripable; } -boost::shared_ptr -ArdourMixerStrip::connections () const -{ - return _connections; -} - ArdourMixerPlugin& ArdourMixerStrip::plugin (uint32_t plugin_id) { @@ -182,7 +167,7 @@ ArdourMixerStrip::plugin (uint32_t plugin_id) throw ArdourMixerNotFoundException ("plugin id = " + boost::lexical_cast(plugin_id) + " not found"); } - return _plugins.at (plugin_id); + return *_plugins.at (plugin_id); } ArdourMixerStrip::PluginMap& @@ -297,10 +282,9 @@ ArdourMixer::start () uint32_t strip_id = 0; for (StripableList::iterator it = strips.begin (); it != strips.end (); ++it) { - ArdourMixerStrip strip (*it, event_loop ()); - strip.stripable ()->DropReferences.connect (*strip.connections (), MISSING_INVALIDATOR, - boost::bind (&ArdourMixer::on_drop_strip, this, strip_id), event_loop ()); - _strips.emplace (strip_id, strip); + _strips[strip_id] = boost::shared_ptr (new ArdourMixerStrip (*it, event_loop ())); + (*it)->DropReferences.connect (*_strips[strip_id], MISSING_INVALIDATOR, + boost::bind (&ArdourMixer::on_drop_strip, this, strip_id), event_loop ()); strip_id++; } @@ -329,7 +313,7 @@ ArdourMixer::strip (uint32_t strip_id) throw ArdourMixerNotFoundException ("strip id = " + boost::lexical_cast(strip_id) + " not found"); } - return _strips.at (strip_id); + return *_strips.at (strip_id); } void diff --git a/libs/surfaces/websockets/mixer.h b/libs/surfaces/websockets/mixer.h index 63104bf445..a3d219961e 100644 --- a/libs/surfaces/websockets/mixer.h +++ b/libs/surfaces/websockets/mixer.h @@ -26,19 +26,23 @@ namespace ArdourSurface { -struct ArdourMixerNotFoundException : public virtual std::runtime_error +class ArdourMixerNotFoundException : public std::runtime_error { public: ArdourMixerNotFoundException (std::string const & what) - : runtime_error (what) + : std::runtime_error (what) , _what (what) {} - virtual const char* what() const throw() { return _what.c_str(); } + + ~ArdourMixerNotFoundException() throw() {} + + const char* what() const throw() { return _what.c_str(); } + private: std::string _what; }; -class ArdourMixerPlugin +class ArdourMixerPlugin : public PBD::ScopedConnectionList { public: ArdourMixerPlugin (boost::shared_ptr); @@ -60,11 +64,9 @@ public: private: boost::shared_ptr _insert; - boost::shared_ptr _connections; - }; -class ArdourMixerStrip +class ArdourMixerStrip : public PBD::ScopedConnectionList { public: ArdourMixerStrip (boost::shared_ptr, PBD::EventLoop*); @@ -73,7 +75,7 @@ public: boost::shared_ptr stripable () const; boost::shared_ptr connections () const; - typedef std::map PluginMap; + typedef std::map > PluginMap; PluginMap& plugins (); ArdourMixerPlugin& plugin (uint32_t); @@ -98,7 +100,6 @@ public: private: boost::shared_ptr _stripable; - boost::shared_ptr _connections; PluginMap _plugins; @@ -116,7 +117,7 @@ public: int start (); int stop (); - typedef std::map StripMap; + typedef std::map > StripMap; StripMap& strips (); ArdourMixerStrip& strip (uint32_t);