13
0

Remove more libwebsocket C++11isms

* amend previous commit, fix runtime_error implementation
* Do not copy-construct classes that have a PBD::scoped connection list.
  Replace std::map::emplace[C+11], an store shared pointers the std::map.
* Update ArdourMixerStrip is-a ScopedConnectionList (not has-a)
This commit is contained in:
Robin Gareus 2020-08-30 22:50:25 +02:00
parent 8eb4dcb675
commit cdd48926d1
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 37 additions and 52 deletions

View File

@ -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<PluginInsert> insert = it->second.insert ();
boost::shared_ptr<PluginInsert> insert = it->second->insert ();
boost::shared_ptr<Plugin> plugin = insert->plugin ();
update (client, Node::strip_plugin_description, strip_id, plugin_id,

View File

@ -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<double> (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<ArdourMixerStrip> strip = it->second;
boost::shared_ptr<Stripable> stripable = strip.stripable ();
boost::shared_ptr<PBD::ScopedConnectionList> connections = it->second.connections ();
boost::shared_ptr<Stripable> stripable = strip->stripable ();
boost::shared_ptr<PBD::ScopedConnectionList> connections = it->second->connections ();
stripable->gain_control ()->Changed.connect (*connections, MISSING_INVALIDATOR,
boost::bind<void> (StripGainObserver (), this, strip_id), event_loop ());
@ -212,7 +212,7 @@ ArdourFeedback::observe_mixer ()
stripable->mute_control ()->Changed.connect (*connections, MISSING_INVALIDATOR,
boost::bind<void> (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<PluginInsert> insert = plugin.insert ();
boost::shared_ptr<PBD::ScopedConnectionList> connections = plugin.connections ();
boost::shared_ptr<ArdourMixerPlugin> plugin = it->second;
boost::shared_ptr<PluginInsert> insert = plugin->insert ();
boost::shared_ptr<PBD::ScopedConnectionList> connections = plugin->connections ();
uint32_t bypass = insert->plugin ()->designated_bypass_port ();
Evoral::Parameter param = Evoral::Parameter (PluginAutomation, 0, bypass);
boost::shared_ptr<AutomationControl> control = insert->automation_control (param);
@ -233,11 +233,11 @@ ArdourFeedback::observe_strip_plugins (uint32_t strip_id, ArdourMixerStrip::Plug
boost::bind<void> (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<AutomationControl> control = plugin.param_control (param_id);
boost::shared_ptr<AutomationControl> control = plugin->param_control (param_id);
control->Changed.connect (*plugin.connections (), MISSING_INVALIDATOR,
control->Changed.connect (*plugin->connections (), MISSING_INVALIDATOR,
boost::bind<void> (PluginParamValueObserver (), this, strip_id, plugin_id, param_id,
boost::weak_ptr<AutomationControl>(control)),
event_loop ());

View File

@ -31,12 +31,11 @@ using namespace ArdourSurface;
ArdourMixerPlugin::ArdourMixerPlugin (boost::shared_ptr<ARDOUR::PluginInsert> insert)
: _insert (insert)
, _connections (boost::shared_ptr<PBD::ScopedConnectionList> (new PBD::ScopedConnectionList()))
{}
ArdourMixerPlugin::~ArdourMixerPlugin ()
{
_connections->drop_connections ();
drop_connections ();
}
boost::shared_ptr<ARDOUR::PluginInsert>
@ -45,12 +44,6 @@ ArdourMixerPlugin::insert () const
return _insert;
}
boost::shared_ptr<PBD::ScopedConnectionList>
ArdourMixerPlugin::connections () const
{
return _connections;
}
bool
ArdourMixerPlugin::enabled () const
{
@ -127,7 +120,6 @@ ArdourMixerPlugin::param_value (boost::shared_ptr<ARDOUR::AutomationControl> con
ArdourMixerStrip::ArdourMixerStrip (boost::shared_ptr<ARDOUR::Stripable> stripable, PBD::EventLoop* event_loop)
: _stripable (stripable)
, _connections (boost::shared_ptr<PBD::ScopedConnectionList> (new PBD::ScopedConnectionList()))
{
if (is_vca ()) {
/* no plugins to handle */
@ -150,17 +142,16 @@ ArdourMixerStrip::ArdourMixerStrip (boost::shared_ptr<ARDOUR::Stripable> stripab
boost::shared_ptr<PluginInsert> insert = boost::static_pointer_cast<PluginInsert> (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<ArdourMixerPlugin> (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<ARDOUR::Stripable>
@ -169,12 +160,6 @@ ArdourMixerStrip::stripable () const
return _stripable;
}
boost::shared_ptr<PBD::ScopedConnectionList>
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<std::string>(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<ArdourMixerStrip> (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<std::string>(strip_id) + " not found");
}
return _strips.at (strip_id);
return *_strips.at (strip_id);
}
void

View File

@ -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<ARDOUR::PluginInsert>);
@ -60,11 +64,9 @@ public:
private:
boost::shared_ptr<ARDOUR::PluginInsert> _insert;
boost::shared_ptr<PBD::ScopedConnectionList> _connections;
};
class ArdourMixerStrip
class ArdourMixerStrip : public PBD::ScopedConnectionList
{
public:
ArdourMixerStrip (boost::shared_ptr<ARDOUR::Stripable>, PBD::EventLoop*);
@ -73,7 +75,7 @@ public:
boost::shared_ptr<ARDOUR::Stripable> stripable () const;
boost::shared_ptr<PBD::ScopedConnectionList> connections () const;
typedef std::map<uint32_t, ArdourMixerPlugin> PluginMap;
typedef std::map<uint32_t, boost::shared_ptr<ArdourMixerPlugin> > PluginMap;
PluginMap& plugins ();
ArdourMixerPlugin& plugin (uint32_t);
@ -98,7 +100,6 @@ public:
private:
boost::shared_ptr<ARDOUR::Stripable> _stripable;
boost::shared_ptr<PBD::ScopedConnectionList> _connections;
PluginMap _plugins;
@ -116,7 +117,7 @@ public:
int start ();
int stop ();
typedef std::map<uint32_t, ArdourMixerStrip> StripMap;
typedef std::map<uint32_t, boost::shared_ptr<ArdourMixerStrip> > StripMap;
StripMap& strips ();
ArdourMixerStrip& strip (uint32_t);