Remove all initializer list usages
This commit is contained in:
committed by
Robin Gareus
parent
bb448080b6
commit
047b05b860
@@ -43,7 +43,11 @@ ArdourWebsockets::ArdourWebsockets (Session& s)
|
||||
, _server (*this)
|
||||
, _dispatcher (*this)
|
||||
{
|
||||
_components = { &_strips, &_globals, &_server, &_feedback, &_dispatcher };
|
||||
_components.push_back (&_strips);
|
||||
_components.push_back (&_globals);
|
||||
_components.push_back (&_server);
|
||||
_components.push_back (&_feedback);
|
||||
_components.push_back (&_dispatcher);
|
||||
}
|
||||
|
||||
ArdourWebsockets::~ArdourWebsockets ()
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
|
||||
#include "ardour/plugin_insert.h"
|
||||
|
||||
#include "dispatcher.h"
|
||||
@@ -24,17 +26,17 @@
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
#define NODE_METHOD_PAIR(x) { Node::x, &WebsocketsDispatcher::x ## _handler }
|
||||
#define NODE_METHOD_PAIR(x) (Node::x, &WebsocketsDispatcher::x ## _handler)
|
||||
|
||||
WebsocketsDispatcher::NodeMethodMap
|
||||
WebsocketsDispatcher::_node_to_method = {
|
||||
NODE_METHOD_PAIR(tempo),
|
||||
NODE_METHOD_PAIR(strip_gain),
|
||||
NODE_METHOD_PAIR(strip_pan),
|
||||
NODE_METHOD_PAIR(strip_mute),
|
||||
NODE_METHOD_PAIR(strip_plugin_enable),
|
||||
WebsocketsDispatcher::_node_to_method = boost::assign::map_list_of
|
||||
NODE_METHOD_PAIR(tempo)
|
||||
NODE_METHOD_PAIR(strip_gain)
|
||||
NODE_METHOD_PAIR(strip_pan)
|
||||
NODE_METHOD_PAIR(strip_mute)
|
||||
NODE_METHOD_PAIR(strip_plugin_enable)
|
||||
NODE_METHOD_PAIR(strip_plugin_param_value)
|
||||
};
|
||||
;
|
||||
|
||||
void
|
||||
WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
|
||||
@@ -52,7 +54,7 @@ WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
|
||||
void
|
||||
WebsocketsDispatcher::update_all_nodes (Client client)
|
||||
{
|
||||
update (client, Node::tempo, {}, { globals ().tempo () });
|
||||
update (client, Node::tempo, globals ().tempo ());
|
||||
|
||||
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
|
||||
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
||||
@@ -61,10 +63,10 @@ WebsocketsDispatcher::update_all_nodes (Client client)
|
||||
continue;
|
||||
}
|
||||
|
||||
update (client, Node::strip_desc, { strip_n }, { strip->name () });
|
||||
update (client, Node::strip_gain, { strip_n }, { strips ().strip_gain (strip_n) });
|
||||
update (client, Node::strip_pan, { strip_n }, { strips ().strip_pan (strip_n) });
|
||||
update (client, Node::strip_mute, { strip_n }, { strips ().strip_mute (strip_n) });
|
||||
update (client, Node::strip_desc, strip_n, strip->name ());
|
||||
update (client, Node::strip_gain, strip_n, strips ().strip_gain (strip_n));
|
||||
update (client, Node::strip_pan, strip_n, strips ().strip_pan (strip_n));
|
||||
update (client, Node::strip_mute, strip_n, strips ().strip_mute (strip_n));
|
||||
|
||||
for (uint32_t plugin_n = 0 ; ; ++plugin_n) {
|
||||
boost::shared_ptr<PluginInsert> insert = strips ()
|
||||
@@ -74,11 +76,11 @@ WebsocketsDispatcher::update_all_nodes (Client client)
|
||||
}
|
||||
|
||||
boost::shared_ptr<Plugin> plugin = insert->plugin ();
|
||||
update (client, Node::strip_plugin_desc, { strip_n, plugin_n },
|
||||
{ static_cast<std::string>(plugin->name ()) });
|
||||
update (client, Node::strip_plugin_desc, strip_n, plugin_n,
|
||||
static_cast<std::string>(plugin->name ()));
|
||||
|
||||
update (client, Node::strip_plugin_enable, { strip_n, plugin_n },
|
||||
{ strips ().strip_plugin_enabled (strip_n, plugin_n) });
|
||||
update (client, Node::strip_plugin_enable, strip_n, plugin_n,
|
||||
strips ().strip_plugin_enabled (strip_n, plugin_n));
|
||||
|
||||
for (uint32_t param_n = 0; param_n < plugin->parameter_count (); ++param_n) {
|
||||
boost::shared_ptr<AutomationControl> a_ctrl =
|
||||
@@ -87,23 +89,35 @@ WebsocketsDispatcher::update_all_nodes (Client client)
|
||||
continue;
|
||||
}
|
||||
|
||||
AddressVector addr = AddressVector ();
|
||||
addr.push_back (strip_n);
|
||||
addr.push_back (plugin_n);
|
||||
addr.push_back (param_n);
|
||||
|
||||
ValueVector val = ValueVector ();
|
||||
val.push_back (a_ctrl->name ());
|
||||
|
||||
// possible flags: enumeration, integer_step, logarithmic, sr_dependent, toggled
|
||||
ParameterDescriptor pd = a_ctrl->desc ();
|
||||
|
||||
if (pd.toggled) {
|
||||
update (client, Node::strip_plugin_param_desc, { strip_n, plugin_n, param_n },
|
||||
{ a_ctrl->name (), std::string("b") });
|
||||
val.push_back (std::string("b"));
|
||||
} else if (pd.enumeration || pd.integer_step) {
|
||||
update (client, Node::strip_plugin_param_desc, { strip_n, plugin_n, param_n },
|
||||
{ a_ctrl->name (), std::string("i"), pd.lower, pd.upper, pd.integer_step });
|
||||
val.push_back (std::string("i"));
|
||||
val.push_back (pd.lower);
|
||||
val.push_back (pd.upper);
|
||||
val.push_back (pd.integer_step);
|
||||
} else {
|
||||
update (client, Node::strip_plugin_param_desc, { strip_n, plugin_n, param_n },
|
||||
{ a_ctrl->name (), std::string("d"), pd.lower, pd.upper, pd.logarithmic });
|
||||
val.push_back (std::string("d"));
|
||||
val.push_back (pd.lower);
|
||||
val.push_back (pd.upper);
|
||||
val.push_back (pd.logarithmic);
|
||||
}
|
||||
|
||||
update (client, Node::strip_plugin_param_desc, addr, val);
|
||||
|
||||
TypedValue value = strips ().strip_plugin_param_value (strip_n, plugin_n, param_n);
|
||||
update (client, Node::strip_plugin_param_value, { strip_n, plugin_n, param_n },
|
||||
{ value });
|
||||
update (client, Node::strip_plugin_param_value, strip_n, plugin_n, param_n, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +129,7 @@ WebsocketsDispatcher::tempo_handler (Client client, const NodeStateMessage& msg)
|
||||
if (msg.is_write ()) {
|
||||
globals ().set_tempo (msg.state ().nth_val (0));
|
||||
} else {
|
||||
update (client, Node::tempo, {}, { globals ().tempo () });
|
||||
update (client, Node::tempo, globals ().tempo ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +141,7 @@ WebsocketsDispatcher::strip_gain_handler (Client client, const NodeStateMessage&
|
||||
if (msg.is_write ()) {
|
||||
strips ().set_strip_gain (strip_id, msg.state ().nth_val (0));
|
||||
} else {
|
||||
update (client, Node::strip_gain, { strip_id }, { strips ().strip_gain (strip_id) });
|
||||
update (client, Node::strip_gain, strip_id, strips ().strip_gain (strip_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +153,7 @@ WebsocketsDispatcher::strip_pan_handler (Client client, const NodeStateMessage&
|
||||
if (msg.is_write ()) {
|
||||
strips ().set_strip_pan (strip_id, msg.state ().nth_val (0));
|
||||
} else {
|
||||
update (client, Node::strip_pan, { strip_id }, { strips ().strip_pan(strip_id) });
|
||||
update (client, Node::strip_pan, strip_id, strips ().strip_pan(strip_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +165,7 @@ WebsocketsDispatcher::strip_mute_handler (Client client, const NodeStateMessage&
|
||||
if (msg.is_write ()) {
|
||||
strips ().set_strip_mute (strip_id, msg.state ().nth_val (0));
|
||||
} else {
|
||||
update (client, Node::strip_mute, { strip_id }, { strips ().strip_mute (strip_id) });
|
||||
update (client, Node::strip_mute, strip_id, strips ().strip_mute (strip_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,8 +178,8 @@ WebsocketsDispatcher::strip_plugin_enable_handler (Client client, const NodeStat
|
||||
if (msg.is_write ()) {
|
||||
strips ().set_strip_plugin_enabled (strip_id, plugin_id, msg.state ().nth_val (0));
|
||||
} else {
|
||||
update (client, Node::strip_plugin_enable, { strip_id, plugin_id },
|
||||
{ strips ().strip_plugin_enabled (strip_id, plugin_id) });
|
||||
update (client, Node::strip_plugin_enable, strip_id, plugin_id,
|
||||
strips ().strip_plugin_enabled (strip_id, plugin_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,13 +195,59 @@ WebsocketsDispatcher::strip_plugin_param_value_handler (Client client, const Nod
|
||||
msg.state ().nth_val (0));
|
||||
} else {
|
||||
TypedValue value = strips ().strip_plugin_param_value (strip_id, plugin_id, param_id);
|
||||
update (client, Node::strip_plugin_param_value, { strip_id, plugin_id, param_id },
|
||||
{ value });
|
||||
update (client, Node::strip_plugin_param_value, strip_id, plugin_id, param_id, value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebsocketsDispatcher::update (Client client, std::string node, AddressVector addr, ValueVector val)
|
||||
WebsocketsDispatcher::update (Client client, std::string node, TypedValue val1)
|
||||
{
|
||||
server ().update_client (client, { node, addr, val }, true);
|
||||
update (client, node, ADDR_NONE, ADDR_NONE, ADDR_NONE, val1);
|
||||
}
|
||||
|
||||
void
|
||||
WebsocketsDispatcher::update (Client client, std::string node, uint32_t strip_n, TypedValue val1)
|
||||
{
|
||||
update (client, node, strip_n, ADDR_NONE, ADDR_NONE, val1);
|
||||
}
|
||||
|
||||
void
|
||||
WebsocketsDispatcher::update (Client client, std::string node, uint32_t strip_n, uint32_t plugin_n,
|
||||
TypedValue val1)
|
||||
{
|
||||
update (client, node, strip_n, plugin_n, ADDR_NONE, val1);
|
||||
}
|
||||
|
||||
void
|
||||
WebsocketsDispatcher::update (Client client, std::string node, uint32_t strip_n, uint32_t plugin_n,
|
||||
uint32_t param_n, TypedValue val1)
|
||||
{
|
||||
AddressVector addr = AddressVector ();
|
||||
|
||||
if (strip_n != ADDR_NONE) {
|
||||
addr.push_back (strip_n);
|
||||
}
|
||||
|
||||
if (plugin_n != ADDR_NONE) {
|
||||
addr.push_back (plugin_n);
|
||||
}
|
||||
|
||||
if (param_n != ADDR_NONE) {
|
||||
addr.push_back (param_n);
|
||||
}
|
||||
|
||||
ValueVector val = ValueVector ();
|
||||
|
||||
if (!val1.empty ()) {
|
||||
val.push_back (val1);
|
||||
}
|
||||
|
||||
update (client, node, addr, val);
|
||||
}
|
||||
|
||||
void
|
||||
WebsocketsDispatcher::update (Client client, std::string node, const AddressVector& addr,
|
||||
const ValueVector& val)
|
||||
{
|
||||
server ().update_client (client, NodeState (node, addr, val), true);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,11 @@ class WebsocketsDispatcher : public SurfaceComponent
|
||||
void strip_plugin_enable_handler (Client, const NodeStateMessage&);
|
||||
void strip_plugin_param_value_handler (Client, const NodeStateMessage&);
|
||||
|
||||
void update (Client, std::string, AddressVector, ValueVector);
|
||||
void update (Client, std::string, TypedValue);
|
||||
void update (Client, std::string, uint32_t, TypedValue);
|
||||
void update (Client, std::string, uint32_t, uint32_t, TypedValue);
|
||||
void update (Client, std::string, uint32_t, uint32_t, uint32_t, TypedValue);
|
||||
void update (Client, std::string, const AddressVector&, const ValueVector&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
#define ADDR_NONE UINT_MAX
|
||||
|
||||
struct TempoObserver {
|
||||
void operator() (ArdourFeedback* p) {
|
||||
p->update_all (Node::tempo, p->globals ().tempo ());
|
||||
|
||||
@@ -30,20 +30,19 @@ WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface)
|
||||
, _lws_context (0)
|
||||
{
|
||||
// keep references to all config for libwebsockets 2
|
||||
_lws_proto[0] = {
|
||||
"lws-ardour", // name
|
||||
WebsocketsServer::lws_callback, // callback
|
||||
0, // per_session_data_size
|
||||
0, // rx_buffer_size
|
||||
0, // id
|
||||
0, // user
|
||||
lws_protocols proto;
|
||||
proto.name = "lws-ardour";
|
||||
proto.callback = WebsocketsServer::lws_callback;
|
||||
proto.per_session_data_size = 0;
|
||||
proto.rx_buffer_size = 0;
|
||||
proto.id = 0;
|
||||
proto.user = 0;
|
||||
#if LWS_LIBRARY_VERSION_MAJOR >= 3
|
||||
0 // tx_packet_size
|
||||
proto.tx_packet_size = 0;
|
||||
#endif
|
||||
};
|
||||
_lws_proto[1] = {}; // sentinel
|
||||
_lws_proto[0] = proto;
|
||||
memset (&_lws_proto[1], 0, sizeof(lws_protocols));
|
||||
|
||||
_lws_info = {};
|
||||
_lws_info.port = WEBSOCKET_LISTEN_PORT;
|
||||
_lws_info.protocols = _lws_proto;
|
||||
_lws_info.uid = -1;
|
||||
@@ -110,7 +109,7 @@ WebsocketsServer::update_client (Client wsi, const NodeState& state, bool force)
|
||||
if (force || !it->second.has_state (state)) {
|
||||
// write to client only if state was updated
|
||||
it->second.update_state (state);
|
||||
it->second.output_buf ().push_back (NodeStateMessage { state });
|
||||
it->second.output_buf ().push_back (NodeStateMessage (state));
|
||||
lws_callback_on_writable (wsi);
|
||||
}
|
||||
}
|
||||
@@ -134,7 +133,7 @@ WebsocketsServer::add_poll_fd (struct lws_pollargs *pa)
|
||||
#else
|
||||
RefPtr<IOChannel> g_channel = IOChannel::create_from_fd (fd);
|
||||
#endif
|
||||
RefPtr<IOSource> rg_iosrc { IOSource::create (g_channel, events_to_ioc (pa->events)) };
|
||||
RefPtr<IOSource> rg_iosrc (IOSource::create (g_channel, events_to_ioc (pa->events)));
|
||||
rg_iosrc->connect (sigc::bind (sigc::mem_fun (*this, &WebsocketsServer::io_handler), fd));
|
||||
rg_iosrc->attach (main_loop ()->get_context ());
|
||||
|
||||
@@ -142,7 +141,14 @@ WebsocketsServer::add_poll_fd (struct lws_pollargs *pa)
|
||||
lws_pfd.fd = pa->fd;
|
||||
lws_pfd.events = pa->events;
|
||||
lws_pfd.revents = 0;
|
||||
_fd_ctx[fd] = LwsPollFdGlibSource { lws_pfd, g_channel, rg_iosrc, { } };
|
||||
|
||||
LwsPollFdGlibSource ctx;
|
||||
ctx.lws_pfd = lws_pfd;
|
||||
ctx.g_channel = g_channel;
|
||||
ctx.rg_iosrc = rg_iosrc;
|
||||
ctx.wg_iosrc = Glib::RefPtr<Glib::IOSource>(0);
|
||||
|
||||
_fd_ctx[fd] = ctx;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -166,14 +172,14 @@ WebsocketsServer::mod_poll_fd (struct lws_pollargs *pa)
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<IOSource> wg_iosrc = it->second.g_channel->create_watch (IOCondition::IO_OUT);
|
||||
RefPtr<IOSource> wg_iosrc = it->second.g_channel->create_watch (Glib::IO_OUT);
|
||||
wg_iosrc->connect (sigc::bind (sigc::mem_fun (*this, &WebsocketsServer::io_handler), pa->fd));
|
||||
wg_iosrc->attach (main_loop ()->get_context ());
|
||||
it->second.wg_iosrc = wg_iosrc;
|
||||
} else {
|
||||
if (it->second.wg_iosrc) {
|
||||
it->second.wg_iosrc->destroy ();
|
||||
it->second.wg_iosrc = { };
|
||||
it->second.wg_iosrc = Glib::RefPtr<Glib::IOSource>(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +204,7 @@ WebsocketsServer::del_poll_fd (struct lws_pollargs *pa)
|
||||
void
|
||||
WebsocketsServer::add_client (Client wsi)
|
||||
{
|
||||
_client_ctx.emplace (wsi, ClientContext { wsi });
|
||||
_client_ctx.emplace (wsi, ClientContext (wsi));
|
||||
dispatcher ().update_all_nodes (wsi); // send all state
|
||||
}
|
||||
|
||||
@@ -214,7 +220,7 @@ WebsocketsServer::del_client (Client wsi)
|
||||
void
|
||||
WebsocketsServer::recv_client (Client wsi, void *buf, size_t len)
|
||||
{
|
||||
NodeStateMessage msg { buf, len };
|
||||
NodeStateMessage msg (buf, len);
|
||||
if (!msg.is_valid ()) {
|
||||
return;
|
||||
}
|
||||
@@ -270,7 +276,7 @@ WebsocketsServer::write_client (Client wsi)
|
||||
}
|
||||
|
||||
bool
|
||||
WebsocketsServer::io_handler (Glib::IOCondition ioc, lws_sockfd_type fd)
|
||||
WebsocketsServer::io_handler (IOCondition ioc, lws_sockfd_type fd)
|
||||
{
|
||||
// IO_IN=1, IO_PRI=2, IO_ERR=8, IO_HUP=16
|
||||
//printf ("io_handler ioc = %d\n", ioc);
|
||||
@@ -293,7 +299,7 @@ WebsocketsServer::io_handler (Glib::IOCondition ioc, lws_sockfd_type fd)
|
||||
IOCondition
|
||||
WebsocketsServer::events_to_ioc (int events)
|
||||
{
|
||||
IOCondition ioc = { };
|
||||
IOCondition ioc;
|
||||
|
||||
if (events & POLLIN) {
|
||||
ioc |= IO_IN;
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
#ifndef websockets_server_h
|
||||
#define websockets_server_h
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <glibmm.h>
|
||||
#include <libwebsockets.h>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#if LWS_LIBRARY_VERSION_MAJOR < 3
|
||||
// <libwebsockets.h> includes <uv.h> which in turn includes
|
||||
|
||||
@@ -20,12 +20,15 @@
|
||||
#define node_state_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "typed_value.h"
|
||||
|
||||
#define ADDR_NONE UINT_MAX
|
||||
|
||||
namespace Node {
|
||||
const std::string tempo = "tempo";
|
||||
const std::string strip_desc = "strip_desc";
|
||||
|
||||
Reference in New Issue
Block a user