summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-02-09 14:34:20 +0100
committerDavid Robillard <d@drobilla.net>2020-02-09 14:34:20 +0100
commitaf5ec4bdda21e9a2f76f22050216a0b1cbbed575 (patch)
treef93ddc033b70297abb472f7e28a06f9e936cf0ee /src
parentc321c02a6b9c67b4b106e36a77167ee279b9ef78 (diff)
downloadpatchage-af5ec4bdda21e9a2f76f22050216a0b1cbbed575.tar.gz
patchage-af5ec4bdda21e9a2f76f22050216a0b1cbbed575.tar.bz2
patchage-af5ec4bdda21e9a2f76f22050216a0b1cbbed575.zip
Format all code with clang-format
This configuration tries to get as close to the previous style as possible so the changes aren't too dramatic. It's still far from ideal and the code could use some adaptation, but this makes things much easier to work on.
Diffstat (limited to 'src')
-rw-r--r--src/AlsaDriver.cpp163
-rw-r--r--src/AlsaDriver.hpp60
-rw-r--r--src/Configuration.cpp109
-rw-r--r--src/Configuration.hpp77
-rw-r--r--src/Driver.hpp13
-rw-r--r--src/JackDbusDriver.cpp599
-rw-r--r--src/JackDbusDriver.hpp128
-rw-r--r--src/JackDriver.cpp138
-rw-r--r--src/JackDriver.hpp28
-rw-r--r--src/Legend.hpp38
-rw-r--r--src/Patchage.cpp350
-rw-r--r--src/Patchage.hpp30
-rw-r--r--src/PatchageCanvas.cpp84
-rw-r--r--src/PatchageCanvas.hpp18
-rw-r--r--src/PatchageEvent.cpp34
-rw-r--r--src/PatchageEvent.hpp38
-rw-r--r--src/PatchageModule.cpp44
-rw-r--r--src/PatchagePort.hpp43
-rw-r--r--src/PortID.hpp58
-rw-r--r--src/Queue.hpp36
-rw-r--r--src/UIFile.hpp13
-rw-r--r--src/Widget.hpp18
-rw-r--r--src/main.cpp22
23 files changed, 1229 insertions, 912 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index 0dfcd72..4ad2897 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -31,10 +31,9 @@
using boost::format;
AlsaDriver::AlsaDriver(Patchage* app)
- : _app(app)
- , _seq(NULL)
-{
-}
+ : _app(app)
+ , _seq(NULL)
+{}
AlsaDriver::~AlsaDriver()
{
@@ -58,7 +57,8 @@ AlsaDriver::attach(bool /*launch_daemon*/)
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 50000);
- ret = pthread_create(&_refresh_thread, &attr, &AlsaDriver::refresh_main, this);
+ ret = pthread_create(
+ &_refresh_thread, &attr, &AlsaDriver::refresh_main, this);
if (ret)
_app->error_msg("Alsa: Failed to start refresh thread.");
@@ -121,7 +121,8 @@ AlsaDriver::refresh()
// Create port views
while (snd_seq_query_next_client(_seq, cinfo) >= 0) {
- snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
+ snd_seq_port_info_set_client(pinfo,
+ snd_seq_client_info_get_client(cinfo));
snd_seq_port_info_set_port(pinfo, -1);
while (snd_seq_query_next_port(_seq, pinfo) >= 0) {
const snd_seq_addr_t& addr = *snd_seq_port_info_get_addr(pinfo);
@@ -136,7 +137,8 @@ AlsaDriver::refresh()
// Create connections
snd_seq_client_info_set_client(cinfo, -1);
while (snd_seq_query_next_client(_seq, cinfo) >= 0) {
- snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
+ snd_seq_port_info_set_client(pinfo,
+ snd_seq_client_info_get_client(cinfo));
snd_seq_port_info_set_port(pinfo, -1);
while (snd_seq_query_next_port(_seq, pinfo) >= 0) {
const snd_seq_addr_t* addr = snd_seq_port_info_get_addr(pinfo);
@@ -144,7 +146,8 @@ AlsaDriver::refresh()
continue;
}
- PatchagePort* port = _app->canvas()->find_port(PortID(*addr, false));
+ PatchagePort* port =
+ _app->canvas()->find_port(PortID(*addr, false));
if (!port) {
continue;
}
@@ -154,9 +157,10 @@ AlsaDriver::refresh()
snd_seq_query_subscribe_set_root(subsinfo, addr);
snd_seq_query_subscribe_set_index(subsinfo, 0);
while (!snd_seq_query_port_subscribers(_seq, subsinfo)) {
- const snd_seq_addr_t* addr2 = snd_seq_query_subscribe_get_addr(subsinfo);
+ const snd_seq_addr_t* addr2 =
+ snd_seq_query_subscribe_get_addr(subsinfo);
if (addr2) {
- const PortID id2(*addr2, true);
+ const PortID id2(*addr2, true);
PatchagePort* port2 = _app->canvas()->find_port(id2);
if (port2 && !_app->canvas()->get_edge(port, port2)) {
_app->canvas()->make_connection(port, port2);
@@ -164,15 +168,14 @@ AlsaDriver::refresh()
}
snd_seq_query_subscribe_set_index(
- subsinfo, snd_seq_query_subscribe_get_index(subsinfo) + 1);
+ subsinfo, snd_seq_query_subscribe_get_index(subsinfo) + 1);
}
}
}
}
PatchagePort*
-AlsaDriver::create_port_view(Patchage* patchage,
- const PortID& id)
+AlsaDriver::create_port_view(Patchage* patchage, const PortID& id)
{
PatchageModule* parent = NULL;
PatchagePort* port = NULL;
@@ -203,11 +206,10 @@ AlsaDriver::find_module(uint8_t client_id, ModuleType type)
}
PatchageModule*
-AlsaDriver::find_or_create_module(
- Patchage* patchage,
- uint8_t client_id,
- const std::string& client_name,
- ModuleType type)
+AlsaDriver::find_or_create_module(Patchage* patchage,
+ uint8_t client_id,
+ const std::string& client_name,
+ ModuleType type)
{
PatchageModule* m = find_module(client_id, type);
if (!m) {
@@ -220,11 +222,10 @@ AlsaDriver::find_or_create_module(
}
void
-AlsaDriver::create_port_view_internal(
- Patchage* patchage,
- snd_seq_addr_t addr,
- PatchageModule*& m,
- PatchagePort*& port)
+AlsaDriver::create_port_view_internal(Patchage* patchage,
+ snd_seq_addr_t addr,
+ PatchageModule*& m,
+ PatchagePort*& port)
{
if (ignore(addr))
return;
@@ -288,7 +289,7 @@ AlsaDriver::create_port_view_internal(
if (is_duplex) {
type = ((!is_input) ? Input : Output);
- m = find_or_create_module(_app, addr.client, client_name, type);
+ m = find_or_create_module(_app, addr.client, client_name, type);
if (!m->get_port(port_name)) {
port = create_port(*m, port_name, !is_input, addr);
port->show();
@@ -303,13 +304,17 @@ AlsaDriver::create_port(PatchageModule& parent,
bool is_input,
snd_seq_addr_t addr)
{
- PatchagePort* ret = new PatchagePort(
- parent, ALSA_MIDI, name, "", is_input,
- _app->conf()->get_port_color(ALSA_MIDI),
- _app->show_human_names());
-
- dynamic_cast<PatchageCanvas*>(parent.canvas())->index_port(
- PortID(addr, is_input), ret);
+ PatchagePort* ret =
+ new PatchagePort(parent,
+ ALSA_MIDI,
+ name,
+ "",
+ is_input,
+ _app->conf()->get_port_color(ALSA_MIDI),
+ _app->show_human_names());
+
+ dynamic_cast<PatchageCanvas*>(parent.canvas())
+ ->index_port(PortID(addr, is_input), ret);
_app->canvas()->index_port(PortID(addr, is_input), ret);
_port_addrs.insert(std::make_pair(ret, PortID(addr, is_input)));
@@ -342,14 +347,14 @@ AlsaDriver::ignore(const snd_seq_addr_t& addr, bool add)
if (caps & SND_SEQ_PORT_CAP_NO_EXPORT) {
_ignored.insert(addr);
return true;
- } else if ( !( (caps & SND_SEQ_PORT_CAP_READ)
- || (caps & SND_SEQ_PORT_CAP_WRITE)
- || (caps & SND_SEQ_PORT_CAP_DUPLEX))) {
+ } else if (!((caps & SND_SEQ_PORT_CAP_READ) ||
+ (caps & SND_SEQ_PORT_CAP_WRITE) ||
+ (caps & SND_SEQ_PORT_CAP_DUPLEX))) {
_ignored.insert(addr);
return true;
- } else if ((snd_seq_client_info_get_type(cinfo) != SND_SEQ_USER_CLIENT)
- && ((type == SND_SEQ_PORT_SYSTEM_TIMER
- || type == SND_SEQ_PORT_SYSTEM_ANNOUNCE))) {
+ } else if ((snd_seq_client_info_get_type(cinfo) != SND_SEQ_USER_CLIENT) &&
+ ((type == SND_SEQ_PORT_SYSTEM_TIMER ||
+ type == SND_SEQ_PORT_SYSTEM_ANNOUNCE))) {
_ignored.insert(addr);
return true;
}
@@ -362,8 +367,7 @@ AlsaDriver::ignore(const snd_seq_addr_t& addr, bool add)
* \return Whether connection succeeded.
*/
bool
-AlsaDriver::connect(PatchagePort* src_port,
- PatchagePort* dst_port)
+AlsaDriver::connect(PatchagePort* src_port, PatchagePort* dst_port)
{
PortAddrs::const_iterator s = _port_addrs.find(src_port);
PortAddrs::const_iterator d = _port_addrs.find(dst_port);
@@ -376,8 +380,8 @@ AlsaDriver::connect(PatchagePort* src_port,
const PortID src = s->second;
const PortID dst = d->second;
- if (src.id.alsa_addr.client == dst.id.alsa_addr.client
- && src.id.alsa_addr.port == dst.id.alsa_addr.port) {
+ if (src.id.alsa_addr.client == dst.id.alsa_addr.client &&
+ src.id.alsa_addr.port == dst.id.alsa_addr.port) {
_app->warning_msg("Alsa: Refusing to connect port to itself.");
return false;
}
@@ -400,17 +404,18 @@ AlsaDriver::connect(PatchagePort* src_port,
int ret = snd_seq_subscribe_port(_seq, subs);
if (ret < 0) {
- _app->error_msg((format("Alsa: Subscription failed (%1%).")
- % snd_strerror(ret)).str());
+ _app->error_msg(
+ (format("Alsa: Subscription failed (%1%).") % snd_strerror(ret))
+ .str());
result = false;
}
if (result)
- _app->info_msg(std::string("Alsa: Connected ")
- + src_port->full_name() + " => " + dst_port->full_name());
+ _app->info_msg(std::string("Alsa: Connected ") + src_port->full_name() +
+ " => " + dst_port->full_name());
else
- _app->error_msg(std::string("Alsa: Unable to connect ")
- + src_port->full_name() + " => " + dst_port->full_name());
+ _app->error_msg(std::string("Alsa: Unable to connect ") +
+ src_port->full_name() + " => " + dst_port->full_name());
return (!result);
}
@@ -420,8 +425,7 @@ AlsaDriver::connect(PatchagePort* src_port,
* \return Whether disconnection succeeded.
*/
bool
-AlsaDriver::disconnect(PatchagePort* src_port,
- PatchagePort* dst_port)
+AlsaDriver::disconnect(PatchagePort* src_port, PatchagePort* dst_port)
{
PortAddrs::const_iterator s = _port_addrs.find(src_port);
PortAddrs::const_iterator d = _port_addrs.find(dst_port);
@@ -444,20 +448,21 @@ AlsaDriver::disconnect(PatchagePort* src_port,
// Not connected (shouldn't happen)
if (snd_seq_get_port_subscription(_seq, subs) != 0) {
- _app->error_msg("Alsa: Attempt to unsubscribe ports that are not subscribed.");
+ _app->error_msg(
+ "Alsa: Attempt to unsubscribe ports that are not subscribed.");
return false;
}
int ret = snd_seq_unsubscribe_port(_seq, subs);
if (ret < 0) {
- _app->error_msg(std::string("Alsa: Unable to disconnect ")
- + src_port->full_name() + " => " + dst_port->full_name()
- + "(" + snd_strerror(ret) + ")");
+ _app->error_msg(std::string("Alsa: Unable to disconnect ") +
+ src_port->full_name() + " => " + dst_port->full_name() +
+ "(" + snd_strerror(ret) + ")");
return false;
}
- _app->info_msg(std::string("Alsa: Disconnected ")
- + src_port->full_name() + " => " + dst_port->full_name());
+ _app->info_msg(std::string("Alsa: Disconnected ") + src_port->full_name() +
+ " => " + dst_port->full_name());
return true;
}
@@ -470,12 +475,15 @@ AlsaDriver::create_refresh_port()
snd_seq_port_info_set_name(port_info, "System Announcement Reciever");
snd_seq_port_info_set_type(port_info, SND_SEQ_PORT_TYPE_APPLICATION);
snd_seq_port_info_set_capability(port_info,
- SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE|SND_SEQ_PORT_CAP_NO_EXPORT);
+ SND_SEQ_PORT_CAP_WRITE |
+ SND_SEQ_PORT_CAP_SUBS_WRITE |
+ SND_SEQ_PORT_CAP_NO_EXPORT);
int ret = snd_seq_create_port(_seq, port_info);
if (ret) {
- _app->error_msg((format("Alsa: Error creating port (%1%): ")
- % snd_strerror(ret)).str());
+ _app->error_msg(
+ (format("Alsa: Error creating port (%1%): ") % snd_strerror(ret))
+ .str());
return false;
}
@@ -485,8 +493,10 @@ AlsaDriver::create_refresh_port()
SND_SEQ_CLIENT_SYSTEM,
SND_SEQ_PORT_SYSTEM_ANNOUNCE);
if (ret) {
- _app->error_msg((format("Alsa: Failed to connect to system announce port (%1%)")
- % snd_strerror(ret)).str());
+ _app->error_msg(
+ (format("Alsa: Failed to connect to system announce port (%1%)") %
+ snd_strerror(ret))
+ .str());
return false;
}
@@ -505,7 +515,8 @@ void
AlsaDriver::_refresh_main()
{
if (!create_refresh_port()) {
- _app->error_msg("Alsa: Could not create listen port, auto-refresh disabled.");
+ _app->error_msg(
+ "Alsa: Could not create listen port, auto-refresh disabled.");
return;
}
@@ -525,36 +536,42 @@ AlsaDriver::_refresh_main()
switch (ev->type) {
case SND_SEQ_EVENT_PORT_SUBSCRIBED:
- if (!ignore(ev->data.connect.sender) && !ignore(ev->data.connect.dest))
+ if (!ignore(ev->data.connect.sender) &&
+ !ignore(ev->data.connect.dest))
_events.push(PatchageEvent(PatchageEvent::CONNECTION,
- ev->data.connect.sender, ev->data.connect.dest));
+ ev->data.connect.sender,
+ ev->data.connect.dest));
break;
case SND_SEQ_EVENT_PORT_UNSUBSCRIBED:
- if (!ignore(ev->data.connect.sender) && !ignore(ev->data.connect.dest))
+ if (!ignore(ev->data.connect.sender) &&
+ !ignore(ev->data.connect.dest))
_events.push(PatchageEvent(PatchageEvent::DISCONNECTION,
- ev->data.connect.sender, ev->data.connect.dest));
+ ev->data.connect.sender,
+ ev->data.connect.dest));
break;
case SND_SEQ_EVENT_PORT_START:
snd_seq_get_any_client_info(_seq, ev->data.addr.client, cinfo);
- snd_seq_get_any_port_info(_seq, ev->data.addr.client, ev->data.addr.port, pinfo);
+ snd_seq_get_any_port_info(
+ _seq, ev->data.addr.client, ev->data.addr.port, pinfo);
caps = snd_seq_port_info_get_capability(pinfo);
if (!ignore(ev->data.addr))
- _events.push(PatchageEvent(PatchageEvent::PORT_CREATION,
- PortID(ev->data.addr, (caps & SND_SEQ_PORT_CAP_READ))));
+ _events.push(PatchageEvent(
+ PatchageEvent::PORT_CREATION,
+ PortID(ev->data.addr, (caps & SND_SEQ_PORT_CAP_READ))));
break;
case SND_SEQ_EVENT_PORT_EXIT:
if (!ignore(ev->data.addr, false)) {
// Note: getting caps at this point does not work
- // Delete both inputs and outputs (in case this is a duplex port)
+ // Delete both inputs and outputs (to handle duplex ports)
_events.push(PatchageEvent(PatchageEvent::PORT_DESTRUCTION,
PortID(ev->data.addr, true)));
_events.push(PatchageEvent(PatchageEvent::PORT_DESTRUCTION,
PortID(ev->data.addr, false)));
- _port_addrs.erase(_app->canvas()->find_port(
- PortID(ev->data.addr, false)));
- _port_addrs.erase(_app->canvas()->find_port(
- PortID(ev->data.addr, true)));
+ _port_addrs.erase(
+ _app->canvas()->find_port(PortID(ev->data.addr, false)));
+ _port_addrs.erase(
+ _app->canvas()->find_port(PortID(ev->data.addr, true)));
}
break;
case SND_SEQ_EVENT_CLIENT_CHANGE:
diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp
index e5bb8cf..7428db2 100644
--- a/src/AlsaDriver.hpp
+++ b/src/AlsaDriver.hpp
@@ -47,15 +47,11 @@ public:
void refresh();
void destroy_all();
- PatchagePort* create_port_view(
- Patchage* patchage,
- const PortID& id);
+ PatchagePort* create_port_view(Patchage* patchage, const PortID& id);
- bool connect(PatchagePort* src_port,
- PatchagePort* dst_port);
+ bool connect(PatchagePort* src_port, PatchagePort* dst_port);
- bool disconnect(PatchagePort* src_port,
- PatchagePort* dst_port);
+ bool disconnect(PatchagePort* src_port, PatchagePort* dst_port);
void print_addr(snd_seq_addr_t addr);
@@ -68,25 +64,20 @@ private:
PatchageModule* find_module(uint8_t client_id, ModuleType type);
- PatchageModule*
- find_or_create_module(
- Patchage* patchage,
- uint8_t client_id,
- const std::string& client_name,
- ModuleType type);
-
- void
- create_port_view_internal(
- Patchage* patchage,
- snd_seq_addr_t addr,
- PatchageModule*& parent,
- PatchagePort*& port);
-
- PatchagePort* create_port(
- PatchageModule& parent,
- const std::string& name,
- bool is_input,
- snd_seq_addr_t addr);
+ PatchageModule* find_or_create_module(Patchage* patchage,
+ uint8_t client_id,
+ const std::string& client_name,
+ ModuleType type);
+
+ void create_port_view_internal(Patchage* patchage,
+ snd_seq_addr_t addr,
+ PatchageModule*& parent,
+ PatchagePort*& port);
+
+ PatchagePort* create_port(PatchageModule& parent,
+ const std::string& name,
+ bool is_input,
+ snd_seq_addr_t addr);
Patchage* _app;
snd_seq_t* _seq;
@@ -95,22 +86,25 @@ private:
Glib::Mutex _events_mutex;
std::queue<PatchageEvent> _events;
- struct SeqAddrComparator {
- bool operator() (const snd_seq_addr_t& a, const snd_seq_addr_t& b) const {
- return ((a.client < b.client) || ((a.client == b.client) && a.port < b.port));
+ struct SeqAddrComparator
+ {
+ bool operator()(const snd_seq_addr_t& a, const snd_seq_addr_t& b) const
+ {
+ return ((a.client < b.client) ||
+ ((a.client == b.client) && a.port < b.port));
}
};
typedef std::set<snd_seq_addr_t, SeqAddrComparator> Ignored;
- Ignored _ignored;
+ Ignored _ignored;
typedef std::multimap<uint8_t, PatchageModule*> Modules;
- Modules _modules;
+ Modules _modules;
typedef std::map<PatchagePort*, PortID> PortAddrs;
- PortAddrs _port_addrs;
+ PortAddrs _port_addrs;
- bool ignore(const snd_seq_addr_t& addr, bool add=true);
+ bool ignore(const snd_seq_addr_t& addr, bool add = true);
};
#endif // PATCHAGE_ALSADRIVER_HPP
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 219d4f9..0d6cfc0 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -26,43 +26,44 @@
#include <limits>
#include <vector>
-static const char* port_type_names[N_PORT_TYPES] = {
- "JACK_AUDIO",
- "JACK_MIDI",
- "ALSA_MIDI",
- "JACK_OSC",
- "JACK_CV"
-};
+static const char* port_type_names[N_PORT_TYPES] = {"JACK_AUDIO",
+ "JACK_MIDI",
+ "ALSA_MIDI",
+ "JACK_OSC",
+ "JACK_CV"};
Configuration::Configuration()
- : _window_location(0, 0)
- , _window_size(640, 480)
- , _zoom(1.0)
- , _font_size(12.0)
- , _messages_height(0)
- , _show_toolbar(true)
- , _show_messages(false)
- , _sort_ports(true)
+ : _window_location(0, 0)
+ , _window_size(640, 480)
+ , _zoom(1.0)
+ , _font_size(12.0)
+ , _messages_height(0)
+ , _show_toolbar(true)
+ , _show_messages(false)
+ , _sort_ports(true)
{
#ifdef PATCHAGE_USE_LIGHT_THEME
_port_colors[JACK_AUDIO] = _default_port_colors[JACK_AUDIO] = 0xA4BC8CFF;
- _port_colors[JACK_MIDI] = _default_port_colors[JACK_MIDI] = 0xC89595FF;
- _port_colors[ALSA_MIDI] = _default_port_colors[ALSA_MIDI] = 0x8F7198FF;
- _port_colors[JACK_OSC] = _default_port_colors[JACK_OSC] = 0x7E8EAAFF;
- _port_colors[JACK_CV] = _default_port_colors[JACK_CV] = 0x83AFABFF;
+ _port_colors[JACK_MIDI] = _default_port_colors[JACK_MIDI] = 0xC89595FF;
+ _port_colors[ALSA_MIDI] = _default_port_colors[ALSA_MIDI] = 0x8F7198FF;
+ _port_colors[JACK_OSC] = _default_port_colors[JACK_OSC] = 0x7E8EAAFF;
+ _port_colors[JACK_CV] = _default_port_colors[JACK_CV] = 0x83AFABFF;
#else
_port_colors[JACK_AUDIO] = _default_port_colors[JACK_AUDIO] = 0x3E5E00FF;
- _port_colors[JACK_MIDI] = _default_port_colors[JACK_MIDI] = 0x650300FF;
- _port_colors[ALSA_MIDI] = _default_port_colors[ALSA_MIDI] = 0x2D0043FF;
- _port_colors[JACK_OSC] = _default_port_colors[JACK_OSC] = 0x4100FEFF;
- _port_colors[JACK_CV] = _default_port_colors[JACK_CV] = 0x005E4EFF;
+ _port_colors[JACK_MIDI] = _default_port_colors[JACK_MIDI] = 0x650300FF;
+ _port_colors[ALSA_MIDI] = _default_port_colors[ALSA_MIDI] = 0x2D0043FF;
+ _port_colors[JACK_OSC] = _default_port_colors[JACK_OSC] = 0x4100FEFF;
+ _port_colors[JACK_CV] = _default_port_colors[JACK_CV] = 0x005E4EFF;
#endif
}
bool
-Configuration::get_module_location(const std::string& name, ModuleType type, Coord& loc)
+Configuration::get_module_location(const std::string& name,
+ ModuleType type,
+ Coord& loc)
{
- std::map<std::string, ModuleSettings>::const_iterator i = _module_settings.find(name);
+ std::map<std::string, ModuleSettings>::const_iterator i =
+ _module_settings.find(name);
if (i == _module_settings.end()) {
return false;
}
@@ -82,12 +83,17 @@ Configuration::get_module_location(const std::string& name, ModuleType type, Coo
}
void
-Configuration::set_module_location(const std::string& name, ModuleType type, Coord loc)
+Configuration::set_module_location(const std::string& name,
+ ModuleType type,
+ Coord loc)
{
- std::map<std::string, ModuleSettings>::iterator i = _module_settings.find(name);
+ std::map<std::string, ModuleSettings>::iterator i =
+ _module_settings.find(name);
if (i == _module_settings.end()) {
- i = _module_settings.insert(
- std::make_pair(name, ModuleSettings(type != InputOutput))).first;
+ i = _module_settings
+ .insert(
+ std::make_pair(name, ModuleSettings(type != InputOutput)))
+ .first;
}
ModuleSettings& settings = (*i).second;
@@ -102,19 +108,20 @@ Configuration::set_module_location(const std::string& name, ModuleType type, Coo
settings.inout_location = loc;
break;
default:
- break; // shouldn't reach here
+ break; // shouldn't reach here
}
}
/** Returns whether or not this module should be split.
*
- * If nothing is known about the given module, `default_val` is returned (this is
- * to allow driver's to request terminal ports get split by default).
+ * If nothing is known about the given module, `default_val` is returned (this
+ * is to allow driver's to request terminal ports get split by default).
*/
bool
Configuration::get_module_split(const std::string& name, bool default_val) const
{
- std::map<std::string, ModuleSettings>::const_iterator i = _module_settings.find(name);
+ std::map<std::string, ModuleSettings>::const_iterator i =
+ _module_settings.find(name);
if (i == _module_settings.end()) {
return default_val;
}
@@ -133,7 +140,7 @@ static std::vector<std::string>
get_filenames()
{
std::vector<std::string> filenames;
- std::string prefix;
+ std::string prefix;
const char* xdg_config_home = getenv("XDG_CONFIG_HOME");
const char* home = getenv("HOME");
@@ -165,7 +172,8 @@ Configuration::load()
for (size_t i = 0; i < filenames.size(); ++i) {
file.open(filenames[i].c_str(), std::ios::in);
if (file.good()) {
- std::cout << "Loading configuration from " << filenames[i] << std::endl;
+ std::cout << "Loading configuration from " << filenames[i]
+ << std::endl;
break;
}
}
@@ -222,8 +230,8 @@ Configuration::load()
}
}
if (!found) {
- std::cerr << "error: color for unknown port type `"
- << type_name << "'" << std::endl;
+ std::cerr << "error: color for unknown port type `" << type_name
+ << "'" << std::endl;
}
} else if (key == "module_position" || key[0] == '\"') {
Coord loc;
@@ -285,7 +293,8 @@ Configuration::save()
for (size_t i = 0; i < filenames.size(); ++i) {
file.open(filenames[i].c_str(), std::ios::out);
if (file.good()) {
- std::cout << "Writing configuration to " << filenames[i] << std::endl;
+ std::cout << "Writing configuration to " << filenames[i]
+ << std::endl;
break;
}
}
@@ -295,8 +304,10 @@ Configuration::save()
return;
}
- file << "window_location " << _window_location.x << " " << _window_location.y << std::endl;
- file << "window_size " << _window_size.x << " " << _window_size.y << std::endl;
+ file << "window_location " << _window_location.x << " "
+ << _window_location.y << std::endl;
+ file << "window_size " << _window_size.x << " " << _window_size.y
+ << std::endl;
file << "zoom_level " << _zoom << std::endl;
file << "font_size " << _font_size << std::endl;
file << "show_toolbar " << _show_toolbar << std::endl;
@@ -308,23 +319,29 @@ Configuration::save()
file << std::hex << std::uppercase;
for (int i = 0; i < N_PORT_TYPES; ++i) {
if (_port_colors[i] != _default_port_colors[i]) {
- file << "port_color " << port_type_names[i] << " " << _port_colors[i] << std::endl;
+ file << "port_color " << port_type_names[i] << " "
+ << _port_colors[i] << std::endl;
}
}
file << std::dec << std::nouppercase;
- for (std::map<std::string, ModuleSettings>::iterator i = _module_settings.begin();
- i != _module_settings.end(); ++i) {
+ for (std::map<std::string, ModuleSettings>::iterator i =
+ _module_settings.begin();
+ i != _module_settings.end();
+ ++i) {
const ModuleSettings& settings = (*i).second;
const std::string& name = (*i).first;
if (settings.split) {
if (settings.input_location && settings.output_location) {
- write_module_position(file, name, "input", *settings.input_location);
- write_module_position(file, name, "output", *settings.output_location);
+ write_module_position(
+ file, name, "input", *settings.input_location);
+ write_module_position(
+ file, name, "output", *settings.output_location);
}
} else if (settings.inout_location) {
- write_module_position(file, name, "inputoutput", *settings.inout_location);
+ write_module_position(
+ file, name, "inputoutput", *settings.inout_location);
}
}
diff --git a/src/Configuration.hpp b/src/Configuration.hpp
index 64b72cf..7a4452e 100644
--- a/src/Configuration.hpp
+++ b/src/Configuration.hpp
@@ -19,19 +19,35 @@
#include <stdint.h>
-#include <string>
#include <map>
+#include <string>
#include <boost/optional.hpp>
-enum ModuleType { Input, Output, InputOutput };
+enum ModuleType
+{
+ Input,
+ Output,
+ InputOutput
+};
-enum PortType { JACK_AUDIO, JACK_MIDI, ALSA_MIDI, JACK_OSC, JACK_CV };
+enum PortType
+{
+ JACK_AUDIO,
+ JACK_MIDI,
+ ALSA_MIDI,
+ JACK_OSC,
+ JACK_CV
+};
#define N_PORT_TYPES 5
-struct Coord {
- Coord(double x_=0, double y_=0) : x(x_), y(y_) {}
+struct Coord
+{
+ Coord(double x_ = 0, double y_ = 0)
+ : x(x_)
+ , y(y_)
+ {}
double x;
double y;
};
@@ -44,45 +60,58 @@ public:
void load();
void save();
- bool get_module_location(const std::string& name, ModuleType type, Coord& loc);
- void set_module_location(const std::string& name, ModuleType type, Coord loc);
+ bool
+ get_module_location(const std::string& name, ModuleType type, Coord& loc);
+
+ void
+ set_module_location(const std::string& name, ModuleType type, Coord loc);
void set_module_split(const std::string& name, bool split);
bool get_module_split(const std::string& name, bool default_val) const;
- float get_zoom() const { return _zoom; }
- void set_zoom(float zoom) { _zoom = zoom; }
- float get_font_size() const { return _font_size; }
+ float get_zoom() const { return _zoom; }
+ void set_zoom(float zoom) { _zoom = zoom; }
+ float get_font_size() const { return _font_size; }
void set_font_size(float font_size) { _font_size = font_size; }
- float get_show_toolbar() const { return _show_toolbar; }
+ float get_show_toolbar() const { return _show_toolbar; }
void set_show_toolbar(float show_toolbar) { _show_toolbar = show_toolbar; }
- float get_sprung_layout() const { return _sprung_layout; }
- void set_sprung_layout(float sprung_layout) { _sprung_layout = sprung_layout; }
+ float get_sprung_layout() const { return _sprung_layout; }
+ void set_sprung_layout(float sprung_layout)
+ {
+ _sprung_layout = sprung_layout;
+ }
- bool get_show_messages() const { return _show_messages; }
- void set_show_messages(bool show_messages) { _show_messages = show_messages; }
+ bool get_show_messages() const { return _show_messages; }
+ void set_show_messages(bool show_messages)
+ {
+ _show_messages = show_messages;
+ }
- bool get_sort_ports() const { return _sort_ports; }
- void set_sort_ports(bool sort_ports) { _sort_ports = sort_ports; }
+ bool get_sort_ports() const { return _sort_ports; }
+ void set_sort_ports(bool sort_ports) { _sort_ports = sort_ports; }
- int get_messages_height() const { return _messages_height; }
+ int get_messages_height() const { return _messages_height; }
void set_messages_height(int height) { _messages_height = height; }
uint32_t get_port_color(PortType type) const { return _port_colors[type]; }
- void set_port_color(PortType type, uint32_t rgba) {
+ void set_port_color(PortType type, uint32_t rgba)
+ {
_port_colors[type] = rgba;
}
- Coord get_window_location() { return _window_location; }
+ Coord get_window_location() { return _window_location; }
void set_window_location(Coord loc) { _window_location = loc; }
- Coord get_window_size() { return _window_size; }
- void set_window_size(Coord size) { _window_size = size; }
+ Coord get_window_size() { return _window_size; }
+ void set_window_size(Coord size) { _window_size = size; }
private:
- struct ModuleSettings {
- ModuleSettings(bool s=false) : split(s) {}
+ struct ModuleSettings
+ {
+ ModuleSettings(bool s = false)
+ : split(s)
+ {}
boost::optional<Coord> input_location;
boost::optional<Coord> output_location;
boost::optional<Coord> inout_location;
diff --git a/src/Driver.hpp b/src/Driver.hpp
index bab570b..4186cf2 100644
--- a/src/Driver.hpp
+++ b/src/Driver.hpp
@@ -25,7 +25,8 @@ class PatchagePort;
class PatchageCanvas;
/** Trival driver base class */
-class Driver {
+class Driver
+{
public:
virtual ~Driver() {}
@@ -38,14 +39,12 @@ public:
virtual void refresh() = 0;
virtual void destroy_all() {}
- virtual PatchagePort* create_port_view(Patchage* patchage,
- const PortID& id) = 0;
+ virtual PatchagePort*
+ create_port_view(Patchage* patchage, const PortID& id) = 0;
- virtual bool connect(PatchagePort* src_port,
- PatchagePort* dst_port) = 0;
+ virtual bool connect(PatchagePort* src_port, PatchagePort* dst_port) = 0;
- virtual bool disconnect(PatchagePort* src_port,
- PatchagePort* dst_port) = 0;
+ virtual bool disconnect(PatchagePort* src_port, PatchagePort* dst_port) = 0;
sigc::signal<void> signal_attached;
sigc::signal<void> signal_detached;
diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp
index 7521045..9c535c0 100644
--- a/src/JackDbusDriver.cpp
+++ b/src/JackDbusDriver.cpp
@@ -32,8 +32,8 @@
#include <cassert>
#include <cstring>
-#include <string>
#include <set>
+#include <string>
#define JACKDBUS_SERVICE "org.jackaudio.service"
#define JACKDBUS_OBJECT "/org/jackaudio/Controller"
@@ -54,12 +54,12 @@
//#define USE_FULL_REFRESH
JackDriver::JackDriver(Patchage* app)
- : _app(app)
- , _dbus_connection(0)
- , _max_dsp_load(0)
- , _server_responding(false)
- , _server_started(false)
- , _graph_version(0)
+ : _app(app)
+ , _dbus_connection(0)
+ , _max_dsp_load(0)
+ , _server_responding(false)
+ , _server_started(false)
+ , _graph_version(0)
{
dbus_error_init(&_dbus_error);
}
@@ -93,7 +93,7 @@ void
JackDriver::update_attached()
{
bool was_attached = _server_started;
- _server_started = is_started();
+ _server_started = is_started();
if (!_server_responding) {
if (was_attached) {
@@ -125,7 +125,8 @@ JackDriver::on_jack_disappeared()
{
info_msg("JACK disappeared.");
- // we are not calling update_attached() here, because it will activate jackdbus
+ // we are not calling update_attached() here, because it will activate
+ // jackdbus
_server_responding = false;
@@ -162,14 +163,21 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
assert(me->_dbus_connection);
- if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
- if (!dbus_message_get_args( message, &me->_dbus_error,
- DBUS_TYPE_STRING, &object_name,
- DBUS_TYPE_STRING, &old_owner,
- DBUS_TYPE_STRING, &new_owner,
- DBUS_TYPE_INVALID)) {
- me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
- "NameOwnerChanged signal arguments (%s)") % me->_dbus_error.message));
+ if (dbus_message_is_signal(
+ message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
+ if (!dbus_message_get_args(message,
+ &me->_dbus_error,
+ DBUS_TYPE_STRING,
+ &object_name,
+ DBUS_TYPE_STRING,
+ &old_owner,
+ DBUS_TYPE_STRING,
+ &new_owner,
+ DBUS_TYPE_INVALID)) {
+ me->error_msg(
+ str(boost::format("dbus_message_get_args() failed to extract "
+ "NameOwnerChanged signal arguments (%s)") %
+ me->_dbus_error.message));
dbus_error_free(&me->_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -182,12 +190,17 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
}
#if defined(USE_FULL_REFRESH)
- if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "GraphChanged")) {
- if (!dbus_message_get_args(message, &me->_dbus_error,
- DBUS_TYPE_UINT64, &new_graph_version,
- DBUS_TYPE_INVALID)) {
- me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
- "GraphChanged signal arguments (%s)") % me->_dbus_error.message));
+ if (dbus_message_is_signal(
+ message, JACKDBUS_IFACE_PATCHBAY, "GraphChanged")) {
+ if (!dbus_message_get_args(message,
+ &me->_dbus_error,
+ DBUS_TYPE_UINT64,
+ &new_graph_version,
+ DBUS_TYPE_INVALID)) {
+ me->error_msg(
+ str(boost::format("dbus_message_get_args() failed to extract "
+ "GraphChanged signal arguments (%s)") %
+ me->_dbus_error.message));
dbus_error_free(&me->_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -201,21 +214,32 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
me->refresh_internal(false);
}
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
#else
- if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortAppeared")) {
- if (!dbus_message_get_args( message, &me->_dbus_error,
- DBUS_TYPE_UINT64, &new_graph_version,
- DBUS_TYPE_UINT64, &client_id,
- DBUS_TYPE_STRING, &client_name,
- DBUS_TYPE_UINT64, &port_id,
- DBUS_TYPE_STRING, &port_name,
- DBUS_TYPE_UINT32, &port_flags,
- DBUS_TYPE_UINT32, &port_type,
- DBUS_TYPE_INVALID)) {
- me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
- "PortAppeared signal arguments (%s)") % me->_dbus_error.message));
+ if (dbus_message_is_signal(
+ message, JACKDBUS_IFACE_PATCHBAY, "PortAppeared")) {
+ if (!dbus_message_get_args(message,
+ &me->_dbus_error,
+ DBUS_TYPE_UINT64,
+ &new_graph_version,
+ DBUS_TYPE_UINT64,
+ &client_id,
+ DBUS_TYPE_STRING,
+ &client_name,
+ DBUS_TYPE_UINT64,
+ &port_id,
+ DBUS_TYPE_STRING,
+ &port_name,
+ DBUS_TYPE_UINT32,
+ &port_flags,
+ DBUS_TYPE_UINT32,
+ &port_type,
+ DBUS_TYPE_INVALID)) {
+ me->error_msg(
+ str(boost::format("dbus_message_get_args() failed to extract "
+ "PortAppeared signal arguments (%s)") %
+ me->_dbus_error.message));
dbus_error_free(&me->_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -225,21 +249,31 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
me->signal_attached.emit();
}
- me->add_port(client_id, client_name, port_id, port_name, port_flags, port_type);
+ me->add_port(
+ client_id, client_name, port_id, port_name, port_flags, port_type);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
- if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortDisappeared")) {
- if (!dbus_message_get_args( message, &me->_dbus_error,
- DBUS_TYPE_UINT64, &new_graph_version,
- DBUS_TYPE_UINT64, &client_id,
- DBUS_TYPE_STRING, &client_name,
- DBUS_TYPE_UINT64, &port_id,
- DBUS_TYPE_STRING, &port_name,
- DBUS_TYPE_INVALID)) {
- me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
- "PortDisappeared signal arguments (%s)") % me->_dbus_error.message));
+ if (dbus_message_is_signal(
+ message, JACKDBUS_IFACE_PATCHBAY, "PortDisappeared")) {
+ if (!dbus_message_get_args(message,
+ &me->_dbus_error,
+ DBUS_TYPE_UINT64,
+ &new_graph_version,
+ DBUS_TYPE_UINT64,
+ &client_id,
+ DBUS_TYPE_STRING,
+ &client_name,
+ DBUS_TYPE_UINT64,
+ &port_id,
+ DBUS_TYPE_STRING,
+ &port_name,
+ DBUS_TYPE_INVALID)) {
+ me->error_msg(
+ str(boost::format("dbus_message_get_args() failed to extract "
+ "PortDisappeared signal arguments (%s)") %
+ me->_dbus_error.message));
dbus_error_free(&me->_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -251,24 +285,38 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
me->remove_port(client_id, client_name, port_id, port_name);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortsConnected")) {
- if (!dbus_message_get_args(message, &me->_dbus_error,
- DBUS_TYPE_UINT64, &new_graph_version,
- DBUS_TYPE_UINT64, &client_id,
- DBUS_TYPE_STRING, &client_name,
- DBUS_TYPE_UINT64, &port_id,
- DBUS_TYPE_STRING, &port_name,
- DBUS_TYPE_UINT64, &client2_id,
- DBUS_TYPE_STRING, &client2_name,
- DBUS_TYPE_UINT64, &port2_id,
- DBUS_TYPE_STRING, &port2_name,
- DBUS_TYPE_UINT64, &connection_id,
- DBUS_TYPE_INVALID)) {
- me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
- "PortsConnected signal arguments (%s)") % me->_dbus_error.message));
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (dbus_message_is_signal(
+ message, JACKDBUS_IFACE_PATCHBAY, "PortsConnected")) {
+ if (!dbus_message_get_args(message,
+ &me->_dbus_error,
+ DBUS_TYPE_UINT64,
+ &new_graph_version,
+ DBUS_TYPE_UINT64,
+ &client_id,
+ DBUS_TYPE_STRING,
+ &client_name,
+ DBUS_TYPE_UINT64,
+ &port_id,
+ DBUS_TYPE_STRING,
+ &port_name,
+ DBUS_TYPE_UINT64,
+ &client2_id,
+ DBUS_TYPE_STRING,
+ &client2_name,
+ DBUS_TYPE_UINT64,
+ &port2_id,
+ DBUS_TYPE_STRING,
+ &port2_name,
+ DBUS_TYPE_UINT64,
+ &connection_id,
+ DBUS_TYPE_INVALID)) {
+ me->error_msg(
+ str(boost::format("dbus_message_get_args() failed to extract "
+ "PortsConnected signal arguments (%s)") %
+ me->_dbus_error.message));
dbus_error_free(&me->_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -278,31 +326,48 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
me->signal_attached.emit();
}
- me->connect_ports(
- connection_id,
- client_id, client_name,
- port_id, port_name,
- client2_id, client2_name,
- port2_id, port2_name);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-
- if (dbus_message_is_signal(message, JACKDBUS_IFACE_PATCHBAY, "PortsDisconnected")) {
- if (!dbus_message_get_args(message, &me->_dbus_error,
- DBUS_TYPE_UINT64, &new_graph_version,
- DBUS_TYPE_UINT64, &client_id,
- DBUS_TYPE_STRING, &client_name,
- DBUS_TYPE_UINT64, &port_id,
- DBUS_TYPE_STRING, &port_name,
- DBUS_TYPE_UINT64, &client2_id,
- DBUS_TYPE_STRING, &client2_name,
- DBUS_TYPE_UINT64, &port2_id,
- DBUS_TYPE_STRING, &port2_name,
- DBUS_TYPE_UINT64, &connection_id,
- DBUS_TYPE_INVALID)) {
- me->error_msg(str(boost::format("dbus_message_get_args() failed to extract "
- "PortsConnected signal arguments (%s)") % me->_dbus_error.message));
+ me->connect_ports(connection_id,
+ client_id,
+ client_name,
+ port_id,
+ port_name,
+ client2_id,
+ client2_name,
+ port2_id,
+ port2_name);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (dbus_message_is_signal(
+ message, JACKDBUS_IFACE_PATCHBAY, "PortsDisconnected")) {
+ if (!dbus_message_get_args(message,
+ &me->_dbus_error,
+ DBUS_TYPE_UINT64,
+ &new_graph_version,
+ DBUS_TYPE_UINT64,
+ &client_id,
+ DBUS_TYPE_STRING,
+ &client_name,
+ DBUS_TYPE_UINT64,
+ &port_id,
+ DBUS_TYPE_STRING,
+ &port_name,
+ DBUS_TYPE_UINT64,
+ &client2_id,
+ DBUS_TYPE_STRING,
+ &client2_name,
+ DBUS_TYPE_UINT64,
+ &port2_id,
+ DBUS_TYPE_STRING,
+ &port2_name,
+ DBUS_TYPE_UINT64,
+ &connection_id,
+ DBUS_TYPE_INVALID)) {
+ me->error_msg(
+ str(boost::format("dbus_message_get_args() failed to extract "
+ "PortsConnected signal arguments (%s)") %
+ me->_dbus_error.message));
dbus_error_free(&me->_dbus_error);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -312,14 +377,17 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
me->signal_attached.emit();
}
- me->disconnect_ports(
- connection_id,
- client_id, client_name,
- port_id, port_name,
- client2_id, client2_name,
- port2_id, port2_name);
-
- return DBUS_HANDLER_RESULT_HANDLED;
+ me->disconnect_ports(connection_id,
+ client_id,
+ client_name,
+ port_id,
+ port_name,
+ client2_id,
+ client2_name,
+ port2_id,
+ port2_name);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
#endif
@@ -327,22 +395,19 @@ JackDriver::dbus_message_hook(DBusConnection* connection,
}
bool
-JackDriver::call(
- bool response_expected,
- const char* iface,
- const char* method,
- DBusMessage** reply_ptr_ptr,
- int in_type, ...)
+JackDriver::call(bool response_expected,
+ const char* iface,
+ const char* method,
+ DBusMessage** reply_ptr_ptr,
+ int in_type,
+ ...)
{
DBusMessage* request_ptr;
DBusMessage* reply_ptr;
- va_list ap;
+ va_list ap;
request_ptr = dbus_message_new_method_call(
- JACKDBUS_SERVICE,
- JACKDBUS_OBJECT,
- iface,
- method);
+ JACKDBUS_SERVICE, JACKDBUS_OBJECT, iface, method);
if (!request_ptr) {
throw std::runtime_error("dbus_message_new_method_call() returned 0");
}
@@ -354,21 +419,26 @@ JackDriver::call(
va_end(ap);
// send message and get a handle for a reply
- reply_ptr = dbus_connection_send_with_reply_and_block(_dbus_connection, request_ptr,
- JACKDBUS_CALL_DEFAULT_TIMEOUT, &_dbus_error);
+ reply_ptr =
+ dbus_connection_send_with_reply_and_block(_dbus_connection,
+ request_ptr,
+ JACKDBUS_CALL_DEFAULT_TIMEOUT,
+ &_dbus_error);
dbus_message_unref(request_ptr);
if (!reply_ptr) {
if (response_expected) {
- error_msg(str(boost::format("no reply from server when calling method '%s'"
- ", error is '%s'") % method % _dbus_error.message));
+ error_msg(str(
+ boost::format("no reply from server when calling method '%s'"
+ ", error is '%s'") %
+ method % _dbus_error.message));
}
_server_responding = false;
dbus_error_free(&_dbus_error);
} else {
_server_responding = true;
- *reply_ptr_ptr = reply_ptr;
+ *reply_ptr_ptr = reply_ptr;
}
return reply_ptr;
@@ -378,15 +448,21 @@ bool
JackDriver::is_started()
{
DBusMessage* reply_ptr;
- dbus_bool_t started;
+ dbus_bool_t started;
- if (!call(false, JACKDBUS_IFACE_CONTROL, "IsStarted", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(false,
+ JACKDBUS_IFACE_CONTROL,
+ "IsStarted",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return false;
}
- if (!dbus_message_get_args(reply_ptr, &_dbus_error,
- DBUS_TYPE_BOOLEAN, &started,
- DBUS_TYPE_INVALID)) {
+ if (!dbus_message_get_args(reply_ptr,
+ &_dbus_error,
+ DBUS_TYPE_BOOLEAN,
+ &started,
+ DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
error_msg("decoding reply of IsStarted failed.");
@@ -403,7 +479,11 @@ JackDriver::start_server()
{
DBusMessage* reply_ptr;
- if (!call(false, JACKDBUS_IFACE_CONTROL, "StartServer", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(false,
+ JACKDBUS_IFACE_CONTROL,
+ "StartServer",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return;
}
@@ -417,7 +497,11 @@ JackDriver::stop_server()
{
DBusMessage* reply_ptr;
- if (!call(false, JACKDBUS_IFACE_CONTROL, "StopServer", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(false,
+ JACKDBUS_IFACE_CONTROL,
+ "StopServer",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return;
}
@@ -443,14 +527,32 @@ JackDriver::attach(bool launch_daemon)
dbus_connection_setup_with_g_main(_dbus_connection, NULL);
- dbus_bus_add_match(_dbus_connection, "type='signal',interface='" DBUS_INTERFACE_DBUS "',member=NameOwnerChanged,arg0='org.jackaudio.service'", NULL);
+ dbus_bus_add_match(_dbus_connection,
+ "type='signal',interface='" DBUS_INTERFACE_DBUS
+ "',member=NameOwnerChanged,arg0='org.jackaudio.service'",
+ NULL);
#if defined(USE_FULL_REFRESH)
- dbus_bus_add_match(_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=GraphChanged", NULL);
+ dbus_bus_add_match(_dbus_connection,
+ "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
+ "',member=GraphChanged",
+ NULL);
#else
- dbus_bus_add_match(_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortAppeared", NULL);
- dbus_bus_add_match(_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortDisappeared", NULL);
- dbus_bus_add_match(_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortsConnected", NULL);
- dbus_bus_add_match(_dbus_connection, "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY "',member=PortsDisconnected", NULL);
+ dbus_bus_add_match(_dbus_connection,
+ "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
+ "',member=PortAppeared",
+ NULL);
+ dbus_bus_add_match(_dbus_connection,
+ "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
+ "',member=PortDisappeared",
+ NULL);
+ dbus_bus_add_match(_dbus_connection,
+ "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
+ "',member=PortsConnected",
+ NULL);
+ dbus_bus_add_match(_dbus_connection,
+ "type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
+ "',member=PortsDisconnected",
+ NULL);
#endif
dbus_connection_add_filter(_dbus_connection, dbus_message_hook, this, NULL);
@@ -487,14 +589,13 @@ JackDriver::add_port(PatchageModule* module,
return;
}
- new PatchagePort(
- *module,
- type,
- name,
- "", // TODO: pretty name
- is_input,
- _app->conf()->get_port_color(type),
- _app->show_human_names());
+ new PatchagePort(*module,
+ type,
+ name,
+ "", // TODO: pretty name
+ is_input,
+ _app->conf()->get_port_color(type),
+ _app->show_human_names());
}
void
@@ -520,7 +621,8 @@ JackDriver::add_port(dbus_uint64_t client_id,
}
ModuleType type = InputOutput;
- if (_app->conf()->get_module_split(client_name, port_flags & JACKDBUS_PORT_FLAG_TERMINAL)) {
+ if (_app->conf()->get_module_split(
+ client_name, port_flags & JACKDBUS_PORT_FLAG_TERMINAL)) {
if (port_flags & JACKDBUS_PORT_FLAG_INPUT) {
type = Input;
} else {
@@ -530,7 +632,10 @@ JackDriver::add_port(dbus_uint64_t client_id,
PatchageModule* module = find_or_create_module(type, client_name);
- add_port(module, local_port_type, port_name, port_flags & JACKDBUS_PORT_FLAG_INPUT);
+ add_port(module,
+ local_port_type,
+ port_name,
+ port_flags & JACKDBUS_PORT_FLAG_INPUT);
}
void
@@ -539,7 +644,8 @@ JackDriver::remove_port(dbus_uint64_t client_id,
dbus_uint64_t port_id,
const char* port_name)
{
- PatchagePort* port = _app->canvas()->find_port_by_name(client_name, port_name);
+ PatchagePort* port =
+ _app->canvas()->find_port_by_name(client_name, port_name);
if (!port) {
error_msg("Unable to remove unknown port");
return;
@@ -564,9 +670,7 @@ JackDriver::remove_port(dbus_uint64_t client_id,
}
PatchageModule*
-JackDriver::find_or_create_module(
- ModuleType type,
- const std::string& name)
+JackDriver::find_or_create_module(ModuleType type, const std::string& name)
{
PatchageModule* module = _app->canvas()->find_module(name, type);
@@ -590,15 +694,19 @@ JackDriver::connect_ports(dbus_uint64_t connection_id,
dbus_uint64_t port2_id,
const char* port2_name)
{
- PatchagePort* port1 = _app->canvas()->find_port_by_name(client1_name, port1_name);
+ PatchagePort* port1 =
+ _app->canvas()->find_port_by_name(client1_name, port1_name);
if (!port1) {
- error_msg((std::string)"Unable to connect unknown port '" + port1_name + "' of client '" + client1_name + "'");
+ error_msg((std::string) "Unable to connect unknown port '" +
+ port1_name + "' of client '" + client1_name + "'");
return;
}
- PatchagePort* port2 = _app->canvas()->find_port_by_name(client2_name, port2_name);
+ PatchagePort* port2 =
+ _app->canvas()->find_port_by_name(client2_name, port2_name);
if (!port2) {
- error_msg((std::string)"Unable to connect unknown port '" + port2_name + "' of client '" + client2_name + "'");
+ error_msg((std::string) "Unable to connect unknown port '" +
+ port2_name + "' of client '" + client2_name + "'");
return;
}
@@ -616,15 +724,19 @@ JackDriver::disconnect_ports(dbus_uint64_t connection_id,
dbus_uint64_t port2_id,
const char* port2_name)
{
- PatchagePort* port1 = _app->canvas()->find_port_by_name(client1_name, port1_name);
+ PatchagePort* port1 =
+ _app->canvas()->find_port_by_name(client1_name, port1_name);
if (!port1) {
- error_msg((std::string)"Unable to disconnect unknown port '" + port1_name + "' of client '" + client1_name + "'");
+ error_msg((std::string) "Unable to disconnect unknown port '" +
+ port1_name + "' of client '" + client1_name + "'");
return;
}
- PatchagePort* port2 = _app->canvas()->find_port_by_name(client2_name, port2_name);
+ PatchagePort* port2 =
+ _app->canvas()->find_port_by_name(client2_name, port2_name);
if (!port2) {
- error_msg((std::string)"Unable to disconnect unknown port '" + port2_name + "' of client '" + client2_name + "'");
+ error_msg((std::string) "Unable to disconnect unknown port '" +
+ port2_name + "' of client '" + client2_name + "'");
return;
}
@@ -662,7 +774,13 @@ JackDriver::refresh_internal(bool force)
version = _graph_version;
}
- if (!call(true, JACKDBUS_IFACE_PATCHBAY, "GetGraph", &reply_ptr, DBUS_TYPE_UINT64, &version, DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_PATCHBAY,
+ "GetGraph",
+ &reply_ptr,
+ DBUS_TYPE_UINT64,
+ &version,
+ DBUS_TYPE_INVALID)) {
error_msg("GetGraph() failed.");
return;
}
@@ -670,7 +788,8 @@ JackDriver::refresh_internal(bool force)
reply_signature = dbus_message_get_signature(reply_ptr);
if (strcmp(reply_signature, "ta(tsa(tsuu))a(tstststst)") != 0) {
- error_msg((std::string)"GetGraph() reply signature mismatch. " + reply_signature);
+ error_msg((std::string) "GetGraph() reply signature mismatch. " +
+ reply_signature);
goto unref;
}
@@ -688,8 +807,9 @@ JackDriver::refresh_internal(bool force)
_graph_version = version;
for (dbus_message_iter_recurse(&iter, &clients_array_iter);
- dbus_message_iter_get_arg_type(&clients_array_iter) != DBUS_TYPE_INVALID;
- dbus_message_iter_next(&clients_array_iter)) {
+ dbus_message_iter_get_arg_type(&clients_array_iter) !=
+ DBUS_TYPE_INVALID;
+ dbus_message_iter_next(&clients_array_iter)) {
dbus_message_iter_recurse(&clients_array_iter, &client_struct_iter);
dbus_message_iter_get_basic(&client_struct_iter, &client_id);
@@ -699,8 +819,9 @@ JackDriver::refresh_internal(bool force)
dbus_message_iter_next(&client_struct_iter);
for (dbus_message_iter_recurse(&client_struct_iter, &ports_array_iter);
- dbus_message_iter_get_arg_type(&ports_array_iter) != DBUS_TYPE_INVALID;
- dbus_message_iter_next(&ports_array_iter)) {
+ dbus_message_iter_get_arg_type(&ports_array_iter) !=
+ DBUS_TYPE_INVALID;
+ dbus_message_iter_next(&ports_array_iter)) {
dbus_message_iter_recurse(&ports_array_iter, &port_struct_iter);
dbus_message_iter_get_basic(&port_struct_iter, &port_id);
@@ -715,7 +836,12 @@ JackDriver::refresh_internal(bool force)
dbus_message_iter_get_basic(&port_struct_iter, &port_type);
dbus_message_iter_next(&port_struct_iter);
- add_port(client_id, client_name, port_id, port_name, port_flags, port_type);
+ add_port(client_id,
+ client_name,
+ port_id,
+ port_name,
+ port_flags,
+ port_type);
}
dbus_message_iter_next(&client_struct_iter);
@@ -724,9 +850,11 @@ JackDriver::refresh_internal(bool force)
dbus_message_iter_next(&iter);
for (dbus_message_iter_recurse(&iter, &connections_array_iter);
- dbus_message_iter_get_arg_type(&connections_array_iter) != DBUS_TYPE_INVALID;
- dbus_message_iter_next(&connections_array_iter)) {
- dbus_message_iter_recurse(&connections_array_iter, &connection_struct_iter);
+ dbus_message_iter_get_arg_type(&connections_array_iter) !=
+ DBUS_TYPE_INVALID;
+ dbus_message_iter_next(&connections_array_iter)) {
+ dbus_message_iter_recurse(&connections_array_iter,
+ &connection_struct_iter);
dbus_message_iter_get_basic(&connection_struct_iter, &client_id);
dbus_message_iter_next(&connection_struct_iter);
@@ -755,12 +883,15 @@ JackDriver::refresh_internal(bool force)
dbus_message_iter_get_basic(&connection_struct_iter, &connection_id);
dbus_message_iter_next(&connection_struct_iter);
- connect_ports(
- connection_id,
- client_id, client_name,
- port_id, port_name,
- client2_id, client2_name,
- port2_id, port2_name);
+ connect_ports(connection_id,
+ client_id,
+ client_name,
+ port_id,
+ port_name,
+ client2_id,
+ client2_name,
+ port2_id,
+ port2_name);
}
unref:
@@ -774,8 +905,7 @@ JackDriver::refresh()
}
bool
-JackDriver::connect(PatchagePort* src,
- PatchagePort* dst)
+JackDriver::connect(PatchagePort* src, PatchagePort* dst)
{
const char* client1_name = src->get_module()->get_label();
const char* port1_name = src->get_label();
@@ -783,12 +913,19 @@ JackDriver::connect(PatchagePort* src,
const char* port2_name = dst->get_label();
DBusMessage* reply_ptr;
- if (!call(true, JACKDBUS_IFACE_PATCHBAY, "ConnectPortsByName", &reply_ptr,
- DBUS_TYPE_STRING, &client1_name,
- DBUS_TYPE_STRING, &port1_name,
- DBUS_TYPE_STRING, &client2_name,
- DBUS_TYPE_STRING, &port2_name,
- DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_PATCHBAY,
+ "ConnectPortsByName",
+ &reply_ptr,
+ DBUS_TYPE_STRING,
+ &client1_name,
+ DBUS_TYPE_STRING,
+ &port1_name,
+ DBUS_TYPE_STRING,
+ &client2_name,
+ DBUS_TYPE_STRING,
+ &port2_name,
+ DBUS_TYPE_INVALID)) {
error_msg("ConnectPortsByName() failed.");
return false;
}
@@ -797,8 +934,7 @@ JackDriver::connect(PatchagePort* src,
}
bool
-JackDriver::disconnect(PatchagePort* src,
- PatchagePort* dst)
+JackDriver::disconnect(PatchagePort* src, PatchagePort* dst)
{
const char* client1_name = src->get_module()->get_label();
const char* port1_name = src->get_label();
@@ -806,12 +942,19 @@ JackDriver::disconnect(PatchagePort* src,
const char* port2_name = dst->get_label();
DBusMessage* reply_ptr;
- if (!call(true, JACKDBUS_IFACE_PATCHBAY, "DisconnectPortsByName", &reply_ptr,
- DBUS_TYPE_STRING, &client1_name,
- DBUS_TYPE_STRING, &port1_name,
- DBUS_TYPE_STRING, &client2_name,
- DBUS_TYPE_STRING, &port2_name,
- DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_PATCHBAY,
+ "DisconnectPortsByName",
+ &reply_ptr,
+ DBUS_TYPE_STRING,
+ &client1_name,
+ DBUS_TYPE_STRING,
+ &port1_name,
+ DBUS_TYPE_STRING,
+ &client2_name,
+ DBUS_TYPE_STRING,
+ &port2_name,
+ DBUS_TYPE_INVALID)) {
error_msg("DisconnectPortsByName() failed.");
return false;
}
@@ -822,18 +965,26 @@ JackDriver::disconnect(PatchagePort* src,
jack_nframes_t
JackDriver::buffer_size()
{
- DBusMessage* reply_ptr;
+ DBusMessage* reply_ptr;
dbus_uint32_t buffer_size;
if (_server_responding && !_server_started) {
goto fail;
}
- if (!call(true, JACKDBUS_IFACE_CONTROL, "GetBufferSize", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_CONTROL,
+ "GetBufferSize",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
goto fail;
}
- if (!dbus_message_get_args(reply_ptr, &_dbus_error, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) {
+ if (!dbus_message_get_args(reply_ptr,
+ &_dbus_error,
+ DBUS_TYPE_UINT32,
+ &buffer_size,
+ DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
error_msg("decoding reply of GetBufferSize failed.");
@@ -851,12 +1002,18 @@ fail:
bool
JackDriver::set_buffer_size(jack_nframes_t size)
{
- DBusMessage* reply_ptr;
+ DBusMessage* reply_ptr;
dbus_uint32_t buffer_size;
buffer_size = size;
- if (!call(true, JACKDBUS_IFACE_CONTROL, "SetBufferSize", &reply_ptr, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_CONTROL,
+ "SetBufferSize",
+ &reply_ptr,
+ DBUS_TYPE_UINT32,
+ &buffer_size,
+ DBUS_TYPE_INVALID)) {
return false;
}
@@ -869,13 +1026,21 @@ float
JackDriver::sample_rate()
{
DBusMessage* reply_ptr;
- double sample_rate;
+ double sample_rate;
- if (!call(true, JACKDBUS_IFACE_CONTROL, "GetSampleRate", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_CONTROL,
+ "GetSampleRate",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return false;
}
- if (!dbus_message_get_args(reply_ptr, &_dbus_error, DBUS_TYPE_DOUBLE, &sample_rate, DBUS_TYPE_INVALID)) {
+ if (!dbus_message_get_args(reply_ptr,
+ &_dbus_error,
+ DBUS_TYPE_DOUBLE,
+ &sample_rate,
+ DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
error_msg("decoding reply of GetSampleRate failed.");
@@ -894,13 +1059,19 @@ JackDriver::is_realtime() const
dbus_bool_t realtime;
JackDriver* me = const_cast<JackDriver*>(this);
- if (!me->call(true, JACKDBUS_IFACE_CONTROL, "IsRealtime",
- &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!me->call(true,
+ JACKDBUS_IFACE_CONTROL,
+ "IsRealtime",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return false;
}
- if (!dbus_message_get_args(reply_ptr, &me->_dbus_error, DBUS_TYPE_BOOLEAN,
- &realtime, DBUS_TYPE_INVALID)) {
+ if (!dbus_message_get_args(reply_ptr,
+ &me->_dbus_error,
+ DBUS_TYPE_BOOLEAN,
+ &realtime,
+ DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&me->_dbus_error);
error_msg("decoding reply of IsRealtime failed.");
@@ -922,11 +1093,19 @@ JackDriver::get_xruns()
return 0;
}
- if (!call(true, JACKDBUS_IFACE_CONTROL, "GetXruns", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_CONTROL,
+ "GetXruns",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return 0;
}
- if (!dbus_message_get_args(reply_ptr, &_dbus_error, DBUS_TYPE_UINT32, &xruns, DBUS_TYPE_INVALID)) {
+ if (!dbus_message_get_args(reply_ptr,
+ &_dbus_error,
+ DBUS_TYPE_UINT32,
+ &xruns,
+ DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
error_msg("decoding reply of GetXruns failed.");
@@ -943,7 +1122,11 @@ JackDriver::reset_xruns()
{
DBusMessage* reply_ptr;
- if (!call(true, JACKDBUS_IFACE_CONTROL, "ResetXruns", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_CONTROL,
+ "ResetXruns",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return;
}
@@ -960,11 +1143,19 @@ JackDriver::get_max_dsp_load()
return 0.0;
}
- if (!call(true, JACKDBUS_IFACE_CONTROL, "GetLoad", &reply_ptr, DBUS_TYPE_INVALID)) {
+ if (!call(true,
+ JACKDBUS_IFACE_CONTROL,
+ "GetLoad",
+ &reply_ptr,
+ DBUS_TYPE_INVALID)) {
return 0.0;
}
- if (!dbus_message_get_args(reply_ptr, &_dbus_error, DBUS_TYPE_DOUBLE, &load, DBUS_TYPE_INVALID)) {
+ if (!dbus_message_get_args(reply_ptr,
+ &_dbus_error,
+ DBUS_TYPE_DOUBLE,
+ &load,
+ DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
error_msg("decoding reply of GetLoad failed.");
@@ -982,7 +1173,6 @@ JackDriver::get_max_dsp_load()
return _max_dsp_load;
}
-
void
JackDriver::reset_max_dsp_load()
{
@@ -990,21 +1180,20 @@ JackDriver::reset_max_dsp_load()
}
PatchagePort*
-JackDriver::create_port_view(Patchage* patchage,
- const PortID& id)
+JackDriver::create_port_view(Patchage* patchage, const PortID& id)
{
- assert(false); // we dont use events at all
+ assert(false); // we dont use events at all
return NULL;
}
void
JackDriver::error_msg(const std::string& msg) const
{
- _app->error_msg((std::string)"Jack: " + msg);
+ _app->error_msg((std::string) "Jack: " + msg);
}
void
JackDriver::info_msg(const std::string& msg) const
{
- _app->info_msg((std::string)"Jack: " + msg);
+ _app->info_msg((std::string) "Jack: " + msg);
}
diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp
index d6c39dd..e3851a3 100644
--- a/src/JackDbusDriver.hpp
+++ b/src/JackDbusDriver.hpp
@@ -17,14 +17,14 @@
#ifndef PATCHAGE_JACKDBUSDRIVER_HPP
#define PATCHAGE_JACKDBUSDRIVER_HPP
-#include <string>
-#include <jack/jack.h>
-#include <jack/statistics.h>
-#include <glibmm/thread.h>
-#include <dbus/dbus.h>
#include "Driver.hpp"
#include "Patchage.hpp"
#include "PatchageModule.hpp"
+#include <dbus/dbus.h>
+#include <glibmm/thread.h>
+#include <jack/jack.h>
+#include <jack/statistics.h>
+#include <string>
class PatchageEvent;
class PatchageCanvas;
@@ -45,13 +45,9 @@ public:
void refresh();
void destroy_all();
- bool connect(
- PatchagePort* src,
- PatchagePort* dst);
+ bool connect(PatchagePort* src, PatchagePort* dst);
- bool disconnect(
- PatchagePort* src,
- PatchagePort* dst);
+ bool disconnect(PatchagePort* src, PatchagePort* dst);
size_t get_xruns();
void reset_xruns();
@@ -64,67 +60,58 @@ public:
void process_events(Patchage* app) {}
- PatchagePort* create_port_view(
- Patchage* patchage,
- const PortID& ref);
+ PatchagePort* create_port_view(Patchage* patchage, const PortID& ref);
private:
void error_msg(const std::string& msg) const;
void info_msg(const std::string& msg) const;
- PatchageModule* find_or_create_module(
- ModuleType type,
- const std::string& name);
-
- void add_port(
- PatchageModule* module,
- PortType type,
- const std::string& name,
- bool is_input);
-
- void add_port(
- dbus_uint64_t client_id,
- const char* client_name,
- dbus_uint64_t port_id,
- const char* port_name,
- dbus_uint32_t port_flags,
- dbus_uint32_t port_type);
-
- void remove_port(
- dbus_uint64_t client_id,
- const char* client_name,
- dbus_uint64_t port_id,
- const char* port_name);
-
- void connect_ports(
- dbus_uint64_t connection_id,
- dbus_uint64_t client1_id,
- const char* client1_name,
- dbus_uint64_t port1_id,
- const char* port1_name,
- dbus_uint64_t client2_id,
- const char* client2_name,
- dbus_uint64_t port2_id,
- const char* port2_name);
-
- void disconnect_ports(
- dbus_uint64_t connection_id,
- dbus_uint64_t client1_id,
- const char* client1_name,
- dbus_uint64_t port1_id,
- const char* port1_name,
- dbus_uint64_t client2_id,
- const char* client2_name,
- dbus_uint64_t port2_id,
- const char* port2_name);
-
- bool call(
- bool response_expected,
- const char* iface,
- const char* method,
- DBusMessage** reply_ptr_ptr,
- int in_type,
- ...);
+ PatchageModule*
+ find_or_create_module(ModuleType type, const std::string& name);
+
+ void add_port(PatchageModule* module,
+ PortType type,
+ const std::string& name,
+ bool is_input);
+
+ void add_port(dbus_uint64_t client_id,
+ const char* client_name,
+ dbus_uint64_t port_id,
+ const char* port_name,
+ dbus_uint32_t port_flags,
+ dbus_uint32_t port_type);
+
+ void remove_port(dbus_uint64_t client_id,
+ const char* client_name,
+ dbus_uint64_t port_id,
+ const char* port_name);
+
+ void connect_ports(dbus_uint64_t connection_id,
+ dbus_uint64_t client1_id,
+ const char* client1_name,
+ dbus_uint64_t port1_id,
+ const char* port1_name,
+ dbus_uint64_t client2_id,
+ const char* client2_name,
+ dbus_uint64_t port2_id,
+ const char* port2_name);
+
+ void disconnect_ports(dbus_uint64_t connection_id,
+ dbus_uint64_t client1_id,
+ const char* client1_name,
+ dbus_uint64_t port1_id,
+ const char* port1_name,
+ dbus_uint64_t client2_id,
+ const char* client2_name,
+ dbus_uint64_t port2_id,
+ const char* port2_name);
+
+ bool call(bool response_expected,
+ const char* iface,
+ const char* method,
+ DBusMessage** reply_ptr_ptr,
+ int in_type,
+ ...);
void update_attached();
@@ -136,10 +123,9 @@ private:
void refresh_internal(bool force);
- static DBusHandlerResult dbus_message_hook(
- DBusConnection *connection,
- DBusMessage *message,
- void *me);
+ static DBusHandlerResult dbus_message_hook(DBusConnection* connection,
+ DBusMessage* message,
+ void* me);
void on_jack_appeared();
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index df344f1..097b1aa 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -24,8 +24,8 @@
#include "patchage_config.h"
#ifdef HAVE_JACK_METADATA
-#include <jack/metadata.h>
-#include "jackey.h"
+# include "jackey.h"
+# include <jack/metadata.h>
#endif
#include <boost/format.hpp>
@@ -40,12 +40,12 @@
using boost::format;
JackDriver::JackDriver(Patchage* app)
- : _app(app)
- , _client(NULL)
- , _events(128)
- , _xruns(0)
- , _xrun_delay(0)
- , _is_activated(false)
+ : _app(app)
+ , _client(NULL)
+ , _events(128)
+ , _xruns(0)
+ , _xrun_delay(0)
+ , _is_activated(false)
{
_last_pos.frame = 0;
_last_pos.valid = (jack_position_bits_t)0;
@@ -65,7 +65,8 @@ JackDriver::attach(bool launch_daemon)
if (_client)
return;
- jack_options_t options = (!launch_daemon) ? JackNoStartServer : JackNullOption;
+ jack_options_t options =
+ (!launch_daemon) ? JackNoStartServer : JackNullOption;
_client = jack_client_open("Patchage", options, NULL);
if (_client == NULL) {
_app->error_msg("Jack: Unable to create client.");
@@ -74,8 +75,10 @@ JackDriver::attach(bool launch_daemon)
jack_client_t* const client = _client;
jack_on_shutdown(client, jack_shutdown_cb, this);
- jack_set_client_registration_callback(client, jack_client_registration_cb, this);
- jack_set_port_registration_callback(client, jack_port_registration_cb, this);
+ jack_set_client_registration_callback(
+ client, jack_client_registration_cb, this);
+ jack_set_port_registration_callback(
+ client, jack_port_registration_cb, this);
jack_set_port_connect_callback(client, jack_port_connect_cb, this);
jack_set_xrun_callback(client, jack_xrun_cb, this);
@@ -110,10 +113,8 @@ JackDriver::detach()
static bool
is_jack_port(const PatchagePort* port)
{
- return (port->type() == JACK_AUDIO ||
- port->type() == JACK_MIDI ||
- port->type() == JACK_OSC ||
- port->type() == JACK_CV);
+ return (port->type() == JACK_AUDIO || port->type() == JACK_MIDI ||
+ port->type() == JACK_OSC || port->type() == JACK_CV);
}
/** Destroy all JACK (canvas) ports.
@@ -127,15 +128,15 @@ JackDriver::destroy_all()
}
PatchagePort*
-JackDriver::create_port_view(Patchage* patchage,
- const PortID& id)
+JackDriver::create_port_view(Patchage* patchage, const PortID& id)
{
assert(id.type == PortID::JACK_ID);
jack_port_t* jack_port = jack_port_by_id(_client, id.id.jack_id);
if (!jack_port) {
- _app->error_msg((format("Jack: Failed to find port with ID `%1%'.")
- % id).str());;
+ _app->error_msg(
+ (format("Jack: Failed to find port with ID `%1%'.") % id).str());
+ ;
return NULL;
}
@@ -145,8 +146,8 @@ JackDriver::create_port_view(Patchage* patchage,
port_names(id, module_name, port_name);
ModuleType type = InputOutput;
- if (_app->conf()->get_module_split(
- module_name, (jack_flags & JackPortIsTerminal))) {
+ if (_app->conf()->get_module_split(module_name,
+ (jack_flags & JackPortIsTerminal))) {
if (jack_flags & JackPortIsInput) {
type = Input;
} else {
@@ -162,8 +163,9 @@ JackDriver::create_port_view(Patchage* patchage,
}
if (parent->get_port(port_name)) {
- _app->error_msg((format("Jack: Module `%1%' already has port `%2%'.")
- % module_name % port_name).str());
+ _app->error_msg((format("Jack: Module `%1%' already has port `%2%'.") %
+ module_name % port_name)
+ .str());
return NULL;
}
@@ -232,18 +234,21 @@ JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id)
}
#endif
} else {
- _app->warning_msg((format("Jack: Port `%1%' has unknown type `%2%'.")
- % jack_port_name(port) % type_str).str());
+ _app->warning_msg((format("Jack: Port `%1%' has unknown type `%2%'.") %
+ jack_port_name(port) % type_str)
+ .str());
return NULL;
}
PatchagePort* ret(
- new PatchagePort(parent, port_type, jack_port_short_name(port),
- label,
- (jack_port_flags(port) & JackPortIsInput),
- _app->conf()->get_port_color(port_type),
- _app->show_human_names(),
- order));
+ new PatchagePort(parent,
+ port_type,
+ jack_port_short_name(port),
+ label,
+ (jack_port_flags(port) & JackPortIsInput),
+ _app->conf()->get_port_color(port_type),
+ _app->show_human_names(),
+ order));
if (id.type != PortID::NULL_PORT_ID) {
dynamic_cast<PatchageCanvas*>(parent.canvas())->index_port(id, ret);
@@ -298,8 +303,7 @@ JackDriver::refresh()
ModuleType type = InputOutput;
if (_app->conf()->get_module_split(
- client1_name,
- (jack_port_flags(port) & JackPortIsTerminal))) {
+ client1_name, (jack_port_flags(port) & JackPortIsTerminal))) {
if (jack_port_flags(port) & JackPortIsInput) {
type = Input;
} else {
@@ -322,31 +326,33 @@ JackDriver::refresh()
// Add all connections
for (int i = 0; ports[i]; ++i) {
port = jack_port_by_name(_client, ports[i]);
- const char** connected_ports = jack_port_get_all_connections(_client, port);
+ const char** connected_ports =
+ jack_port_get_all_connections(_client, port);
client1_name = ports[i];
colon = client1_name.find(':');
port1_name = client1_name.substr(colon + 1);
client1_name = client1_name.substr(0, colon);
- const ModuleType port1_type = (jack_port_flags(port) & JackPortIsInput)
- ? Input : Output;
+ const ModuleType port1_type =
+ (jack_port_flags(port) & JackPortIsInput) ? Input : Output;
- PatchageModule* client1_module
- = _app->canvas()->find_module(client1_name, port1_type);
+ PatchageModule* client1_module =
+ _app->canvas()->find_module(client1_name, port1_type);
if (connected_ports) {
for (int j = 0; connected_ports[j]; ++j) {
client2_name = connected_ports[j];
colon = client2_name.find(':');
- port2_name = client2_name.substr(colon+1);
+ port2_name = client2_name.substr(colon + 1);
client2_name = client2_name.substr(0, colon);
- const ModuleType port2_type = (port1_type == Input) ? Output : Input;
+ const ModuleType port2_type =
+ (port1_type == Input) ? Output : Input;
- PatchageModule* client2_module
- = _app->canvas()->find_module(client2_name, port2_type);
+ PatchageModule* client2_module =
+ _app->canvas()->find_module(client2_name, port2_type);
Ganv::Port* port1 = client1_module->get_port(port1_name);
Ganv::Port* port2 = client2_module->get_port(port2_name);
@@ -395,7 +401,7 @@ JackDriver::port_names(const PortID& id,
const std::string full_name = jack_port_name(jack_port);
module_name = full_name.substr(0, full_name.find(":"));
- port_name = full_name.substr(full_name.find(":")+1);
+ port_name = full_name.substr(full_name.find(":") + 1);
return true;
}
@@ -405,20 +411,20 @@ JackDriver::port_names(const PortID& id,
* \return Whether connection succeeded.
*/
bool
-JackDriver::connect(PatchagePort* src_port,
- PatchagePort* dst_port)
+JackDriver::connect(PatchagePort* src_port, PatchagePort* dst_port)
{
if (_client == NULL)
return false;
- int result = jack_connect(_client, src_port->full_name().c_str(), dst_port->full_name().c_str());
+ int result = jack_connect(
+ _client, src_port->full_name().c_str(), dst_port->full_name().c_str());
if (result == 0)
- _app->info_msg(std::string("Jack: Connected ")
- + src_port->full_name() + " => " + dst_port->full_name());
+ _app->info_msg(std::string("Jack: Connected ") + src_port->full_name() +
+ " => " + dst_port->full_name());
else
- _app->error_msg(std::string("Jack: Unable to connect ")
- + src_port->full_name() + " => " + dst_port->full_name());
+ _app->error_msg(std::string("Jack: Unable to connect ") +
+ src_port->full_name() + " => " + dst_port->full_name());
return (!result);
}
@@ -434,20 +440,23 @@ JackDriver::disconnect(PatchagePort* const src_port,
if (_client == NULL)
return false;
- int result = jack_disconnect(_client, src_port->full_name().c_str(), dst_port->full_name().c_str());
+ int result = jack_disconnect(
+ _client, src_port->full_name().c_str(), dst_port->full_name().c_str());
if (result == 0)
- _app->info_msg(std::string("Jack: Disconnected ")
- + src_port->full_name() + " => " + dst_port->full_name());
+ _app->info_msg(std::string("Jack: Disconnected ") +
+ src_port->full_name() + " => " + dst_port->full_name());
else
- _app->error_msg(std::string("Jack: Unable to disconnect ")
- + src_port->full_name() + " => " + dst_port->full_name());
+ _app->error_msg(std::string("Jack: Unable to disconnect ") +
+ src_port->full_name() + " => " + dst_port->full_name());
return (!result);
}
void
-JackDriver::jack_client_registration_cb(const char* name, int registered, void* jack_driver)
+JackDriver::jack_client_registration_cb(const char* name,
+ int registered,
+ void* jack_driver)
{
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
assert(me->_client);
@@ -455,12 +464,15 @@ JackDriver::jack_client_registration_cb(const char* name, int registered, void*
if (registered) {
me->_events.push(PatchageEvent(PatchageEvent::CLIENT_CREATION, name));
} else {
- me->_events.push(PatchageEvent(PatchageEvent::CLIENT_DESTRUCTION, name));
+ me->_events.push(
+ PatchageEvent(PatchageEvent::CLIENT_DESTRUCTION, name));
}
}
void
-JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, void* jack_driver)
+JackDriver::jack_port_registration_cb(jack_port_id_t port_id,
+ int registered,
+ void* jack_driver)
{
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
assert(me->_client);
@@ -468,12 +480,16 @@ JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, vo
if (registered) {
me->_events.push(PatchageEvent(PatchageEvent::PORT_CREATION, port_id));
} else {
- me->_events.push(PatchageEvent(PatchageEvent::PORT_DESTRUCTION, port_id));
+ me->_events.push(
+ PatchageEvent(PatchageEvent::PORT_DESTRUCTION, port_id));
}
}
void
-JackDriver::jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int connect, void* jack_driver)
+JackDriver::jack_port_connect_cb(jack_port_id_t src,
+ jack_port_id_t dst,
+ int connect,
+ void* jack_driver)
{
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
assert(me->_client);
@@ -506,7 +522,7 @@ JackDriver::jack_shutdown_cb(void* jack_driver)
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
me->_app->info_msg("Jack: Shutdown.");
Glib::Mutex::Lock lock(me->_shutdown_mutex);
- me->_client = NULL;
+ me->_client = NULL;
me->_is_activated = false;
me->signal_detached.emit();
}
diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp
index 575c537..601b37e 100644
--- a/src/JackDriver.hpp
+++ b/src/JackDriver.hpp
@@ -55,14 +55,11 @@ public:
std::string& module_name,
std::string& port_name);
- PatchagePort* create_port_view(Patchage* patchage,
- const PortID& id);
+ PatchagePort* create_port_view(Patchage* patchage, const PortID& id);
- bool connect(PatchagePort* src,
- PatchagePort* dst);
+ bool connect(PatchagePort* src, PatchagePort* dst);
- bool disconnect(PatchagePort* src,
- PatchagePort* dst);
+ bool disconnect(PatchagePort* src, PatchagePort* dst);
uint32_t get_xruns() { return _xruns; }
void reset_xruns();
@@ -78,16 +75,19 @@ public:
void process_events(Patchage* app);
private:
- PatchagePort* create_port(
- PatchageModule& parent,
- jack_port_t* port,
- PortID id);
+ PatchagePort*
+ create_port(PatchageModule& parent, jack_port_t* port, PortID id);
void shutdown();
- static void jack_client_registration_cb(const char* name, int registered, void* me);
- static void jack_port_registration_cb(jack_port_id_t port_id, int registered, void* me);
- static void jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int connect, void* me);
+ static void
+ jack_client_registration_cb(const char* name, int registered, void* me);
+ static void
+ jack_port_registration_cb(jack_port_id_t port_id, int registered, void* me);
+ static void jack_port_connect_cb(jack_port_id_t src,
+ jack_port_id_t dst,
+ int connect,
+ void* me);
static int jack_xrun_cb(void* me);
static void jack_shutdown_cb(void* me);
@@ -102,7 +102,7 @@ private:
jack_nframes_t _buffer_size;
uint32_t _xruns;
float _xrun_delay;
- bool _is_activated :1;
+ bool _is_activated : 1;
};
#endif // PATCHAGE_JACKDRIVER_HPP
diff --git a/src/Legend.hpp b/src/Legend.hpp
index 52a4851..9b2b63d 100644
--- a/src/Legend.hpp
+++ b/src/Legend.hpp
@@ -22,30 +22,34 @@
#include <gtkmm/box.h>
#include <gtkmm/colorbutton.h>
-class Legend : public Gtk::HBox {
+class Legend : public Gtk::HBox
+{
public:
- Legend(const Configuration& configuration) {
- add_button(JACK_AUDIO, "Audio", configuration.get_port_color(JACK_AUDIO));
+ Legend(const Configuration& configuration)
+ {
+ add_button(
+ JACK_AUDIO, "Audio", configuration.get_port_color(JACK_AUDIO));
#ifdef HAVE_JACK_METADATA
- add_button(JACK_CV, "CV", configuration.get_port_color(JACK_CV));
- add_button(JACK_OSC, "OSC", configuration.get_port_color(JACK_OSC));
+ add_button(JACK_CV, "CV", configuration.get_port_color(JACK_CV));
+ add_button(JACK_OSC, "OSC", configuration.get_port_color(JACK_OSC));
#endif
- add_button(JACK_MIDI, "MIDI", configuration.get_port_color(JACK_MIDI));
- add_button(ALSA_MIDI, "ALSA MIDI", configuration.get_port_color(ALSA_MIDI));
+ add_button(JACK_MIDI, "MIDI", configuration.get_port_color(JACK_MIDI));
+ add_button(
+ ALSA_MIDI, "ALSA MIDI", configuration.get_port_color(ALSA_MIDI));
show_all_children();
}
- void add_button(int id, const std::string& label, uint32_t rgba) {
+ void add_button(int id, const std::string& label, uint32_t rgba)
+ {
Gdk::Color col;
col.set_rgb(((rgba >> 24) & 0xFF) * 0x100,
- ((rgba>> 16) & 0xFF) * 0x100,
- ((rgba >> 8) & 0xFF) * 0x100);
+ ((rgba >> 16) & 0xFF) * 0x100,
+ ((rgba >> 8) & 0xFF) * 0x100);
Gtk::HBox* box = new Gtk::HBox();
Gtk::ColorButton* but = new Gtk::ColorButton(col);
but->set_use_alpha(false);
- but->signal_color_set().connect(
- sigc::bind(sigc::mem_fun(this, &Legend::on_color_set),
- id, label, but));
+ but->signal_color_set().connect(sigc::bind(
+ sigc::mem_fun(this, &Legend::on_color_set), id, label, but));
box->pack_end(*Gtk::manage(but));
box->pack_end(*Gtk::manage(new Gtk::Label(label)), false, false, 2);
@@ -55,12 +59,12 @@ public:
void on_color_set(const int id,
const std::string& label,
- const Gtk::ColorButton* but) {
+ const Gtk::ColorButton* but)
+ {
const Gdk::Color col = but->get_color();
const uint32_t rgba = (((col.get_red() / 0x100) << 24) |
- ((col.get_green() / 0x100) << 16) |
- ((col.get_blue() / 0x100) << 8) |
- 0xFF);
+ ((col.get_green() / 0x100) << 16) |
+ ((col.get_blue() / 0x100) << 8) | 0xFF);
signal_color_changed.emit(id, label, rgba);
}
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index fe57e3e..b400e85 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -24,22 +24,22 @@
#include "patchage_config.h"
#if defined(HAVE_JACK_DBUS)
- #include "JackDbusDriver.hpp"
+# include "JackDbusDriver.hpp"
#elif defined(PATCHAGE_LIBJACK)
- #include "JackDriver.hpp"
- #include <jack/statistics.h>
+# include "JackDriver.hpp"
+# include <jack/statistics.h>
#endif
#ifdef PATCHAGE_JACK_SESSION
- #include <jack/session.h>
+# include <jack/session.h>
#endif
#ifdef HAVE_ALSA
- #include "AlsaDriver.hpp"
+# include "AlsaDriver.hpp"
#endif
-#include "ganv/Module.hpp"
#include "ganv/Edge.hpp"
+#include "ganv/Module.hpp"
#include <boost/format.hpp>
#include <glib.h>
@@ -53,18 +53,18 @@
#include <gtkmm/stock.h>
#include <gtkmm/treemodel.h>
-#include <cstdlib>
#include <cmath>
+#include <cstdlib>
#include <fstream>
#ifdef PATCHAGE_GTK_OSX
-#include <gtkosxapplication.h>
+# include <gtkosxapplication.h>
static gboolean
can_activate_cb(GtkWidget* widget, guint signal_id, gpointer data)
{
- return gtk_widget_is_sensitive(widget);
+ return gtk_widget_is_sensitive(widget);
}
static void
@@ -102,70 +102,71 @@ port_order(const GanvPort* a, const GanvPort* b, void* data)
return 0;
}
-struct ProjectList_column_record : public Gtk::TreeModel::ColumnRecord {
+struct ProjectList_column_record : public Gtk::TreeModel::ColumnRecord
+{
Gtk::TreeModelColumn<Glib::ustring> label;
};
#define INIT_WIDGET(x) x(_xml, ((const char*)#x) + 1)
Patchage::Patchage(int argc, char** argv)
- : _xml(UIFile::open("patchage"))
+ : _xml(UIFile::open("patchage"))
#ifdef HAVE_ALSA
- , _alsa_driver(NULL)
+ , _alsa_driver(NULL)
#endif
- , _jack_driver(NULL)
- , _conf(NULL)
- , INIT_WIDGET(_about_win)
- , INIT_WIDGET(_main_scrolledwin)
- , INIT_WIDGET(_main_win)
- , INIT_WIDGET(_main_vbox)
- , INIT_WIDGET(_menubar)
- , INIT_WIDGET(_menu_alsa_connect)
- , INIT_WIDGET(_menu_alsa_disconnect)
- , INIT_WIDGET(_menu_file_quit)
- , INIT_WIDGET(_menu_export_image)
- , INIT_WIDGET(_menu_help_about)
- , INIT_WIDGET(_menu_jack_connect)
- , INIT_WIDGET(_menu_jack_disconnect)
- , INIT_WIDGET(_menu_open_session)
- , INIT_WIDGET(_menu_save_session)
- , INIT_WIDGET(_menu_save_close_session)
- , INIT_WIDGET(_menu_view_arrange)
- , INIT_WIDGET(_menu_view_sprung_layout)
- , INIT_WIDGET(_menu_view_messages)
- , INIT_WIDGET(_menu_view_toolbar)
- , INIT_WIDGET(_menu_view_refresh)
- , INIT_WIDGET(_menu_view_human_names)
- , INIT_WIDGET(_menu_view_sort_ports)
- , INIT_WIDGET(_menu_zoom_in)
- , INIT_WIDGET(_menu_zoom_out)
- , INIT_WIDGET(_menu_zoom_normal)
- , INIT_WIDGET(_menu_zoom_full)
- , INIT_WIDGET(_menu_increase_font_size)
- , INIT_WIDGET(_menu_decrease_font_size)
- , INIT_WIDGET(_menu_normal_font_size)
- , INIT_WIDGET(_toolbar)
- , INIT_WIDGET(_clear_load_but)
- , INIT_WIDGET(_xrun_progress)
- , INIT_WIDGET(_buf_size_combo)
- , INIT_WIDGET(_latency_label)
- , INIT_WIDGET(_legend_alignment)
- , INIT_WIDGET(_main_paned)
- , INIT_WIDGET(_log_scrolledwindow)
- , INIT_WIDGET(_status_text)
- , _legend(NULL)
- , _pane_initialized(false)
- , _attach(true)
- , _driver_detached(false)
- , _refresh(false)
- , _enable_refresh(true)
- , _jack_driver_autoattach(true)
+ , _jack_driver(NULL)
+ , _conf(NULL)
+ , INIT_WIDGET(_about_win)
+ , INIT_WIDGET(_main_scrolledwin)
+ , INIT_WIDGET(_main_win)
+ , INIT_WIDGET(_main_vbox)
+ , INIT_WIDGET(_menubar)
+ , INIT_WIDGET(_menu_alsa_connect)
+ , INIT_WIDGET(_menu_alsa_disconnect)
+ , INIT_WIDGET(_menu_file_quit)
+ , INIT_WIDGET(_menu_export_image)
+ , INIT_WIDGET(_menu_help_about)
+ , INIT_WIDGET(_menu_jack_connect)
+ , INIT_WIDGET(_menu_jack_disconnect)
+ , INIT_WIDGET(_menu_open_session)
+ , INIT_WIDGET(_menu_save_session)
+ , INIT_WIDGET(_menu_save_close_session)
+ , INIT_WIDGET(_menu_view_arrange)
+ , INIT_WIDGET(_menu_view_sprung_layout)
+ , INIT_WIDGET(_menu_view_messages)
+ , INIT_WIDGET(_menu_view_toolbar)
+ , INIT_WIDGET(_menu_view_refresh)
+ , INIT_WIDGET(_menu_view_human_names)
+ , INIT_WIDGET(_menu_view_sort_ports)
+ , INIT_WIDGET(_menu_zoom_in)
+ , INIT_WIDGET(_menu_zoom_out)
+ , INIT_WIDGET(_menu_zoom_normal)
+ , INIT_WIDGET(_menu_zoom_full)
+ , INIT_WIDGET(_menu_increase_font_size)
+ , INIT_WIDGET(_menu_decrease_font_size)
+ , INIT_WIDGET(_menu_normal_font_size)
+ , INIT_WIDGET(_toolbar)
+ , INIT_WIDGET(_clear_load_but)
+ , INIT_WIDGET(_xrun_progress)
+ , INIT_WIDGET(_buf_size_combo)
+ , INIT_WIDGET(_latency_label)
+ , INIT_WIDGET(_legend_alignment)
+ , INIT_WIDGET(_main_paned)
+ , INIT_WIDGET(_log_scrolledwindow)
+ , INIT_WIDGET(_status_text)
+ , _legend(NULL)
+ , _pane_initialized(false)
+ , _attach(true)
+ , _driver_detached(false)
+ , _refresh(false)
+ , _enable_refresh(true)
+ , _jack_driver_autoattach(true)
#ifdef HAVE_ALSA
- , _alsa_driver_autoattach(true)
+ , _alsa_driver_autoattach(true)
#endif
{
_conf = new Configuration();
- _canvas = std::make_shared<PatchageCanvas>(this, 1600*2, 1200*2);
+ _canvas = std::make_shared<PatchageCanvas>(this, 1600 * 2, 1200 * 2);
while (argc > 0) {
if (!strcmp(*argv, "-h") || !strcmp(*argv, "--help")) {
@@ -173,8 +174,10 @@ Patchage::Patchage(int argc, char** argv)
std::cout << "Visually connect JACK and ALSA Audio/MIDI ports.\n\n";
std::cout << "Options:\n";
std::cout << "\t-h --help Show this help\n";
- std::cout << "\t-A --no-alsa Do not automatically attach to ALSA\n";
- std::cout << "\t-J --no-jack Do not automatically attack to JACK\n";
+ std::cout
+ << "\t-A --no-alsa Do not automatically attach to ALSA\n";
+ std::cout
+ << "\t-J --no-jack Do not automatically attack to JACK\n";
exit(0);
#ifdef HAVE_ALSA
} else if (!strcmp(*argv, "-A") || !strcmp(*argv, "--no-alsa")) {
@@ -191,14 +194,15 @@ Patchage::Patchage(int argc, char** argv)
}
Glib::set_application_name("Patchage");
- _about_win->property_program_name() = "Patchage";
+ _about_win->property_program_name() = "Patchage";
_about_win->property_logo_icon_name() = "patchage";
gtk_window_set_default_icon_name("patchage");
// Create list model for buffer size selector
- Glib::RefPtr<Gtk::ListStore> buf_size_store = Gtk::ListStore::create(_buf_size_columns);
+ Glib::RefPtr<Gtk::ListStore> buf_size_store =
+ Gtk::ListStore::create(_buf_size_columns);
for (size_t i = 32; i <= 4096; i *= 2) {
- Gtk::TreeModel::Row row = *(buf_size_store->append());
+ Gtk::TreeModel::Row row = *(buf_size_store->append());
row[_buf_size_columns.label] = std::to_string(i);
}
@@ -207,25 +211,27 @@ Patchage::Patchage(int argc, char** argv)
_main_scrolledwin->add(_canvas->widget());
- _main_scrolledwin->property_hadjustment().get_value()->set_step_increment(10);
- _main_scrolledwin->property_vadjustment().get_value()->set_step_increment(10);
+ _main_scrolledwin->property_hadjustment().get_value()->set_step_increment(
+ 10);
+ _main_scrolledwin->property_vadjustment().get_value()->set_step_increment(
+ 10);
_main_scrolledwin->signal_scroll_event().connect(
- sigc::mem_fun(this, &Patchage::on_scroll));
+ sigc::mem_fun(this, &Patchage::on_scroll));
_clear_load_but->signal_clicked().connect(
- sigc::mem_fun(this, &Patchage::clear_load));
+ sigc::mem_fun(this, &Patchage::clear_load));
_buf_size_combo->signal_changed().connect(
- sigc::mem_fun(this, &Patchage::buffer_size_changed));
+ sigc::mem_fun(this, &Patchage::buffer_size_changed));
_status_text->signal_size_allocate().connect(
- sigc::mem_fun(this, &Patchage::on_messages_resized));
+ sigc::mem_fun(this, &Patchage::on_messages_resized));
#ifdef PATCHAGE_JACK_SESSION
_menu_open_session->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::show_open_session_dialog));
+ sigc::mem_fun(this, &Patchage::show_open_session_dialog));
_menu_save_session->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::show_save_session_dialog));
+ sigc::mem_fun(this, &Patchage::show_save_session_dialog));
_menu_save_close_session->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::show_save_close_session_dialog));
+ sigc::mem_fun(this, &Patchage::show_save_close_session_dialog));
#else
_menu_open_session->hide();
_menu_save_session->hide();
@@ -234,48 +240,48 @@ Patchage::Patchage(int argc, char** argv)
#ifdef HAVE_ALSA
_menu_alsa_connect->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_alsa_connect));
+ sigc::mem_fun(this, &Patchage::menu_alsa_connect));
_menu_alsa_disconnect->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_alsa_disconnect));
+ sigc::mem_fun(this, &Patchage::menu_alsa_disconnect));
#else
_menu_alsa_connect->set_sensitive(false);
_menu_alsa_disconnect->set_sensitive(false);
#endif
_menu_file_quit->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_quit));
+ sigc::mem_fun(this, &Patchage::on_quit));
_menu_export_image->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_export_image));
+ sigc::mem_fun(this, &Patchage::on_export_image));
_menu_view_refresh->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::refresh));
+ sigc::mem_fun(this, &Patchage::refresh));
_menu_view_human_names->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_view_human_names));
+ sigc::mem_fun(this, &Patchage::on_view_human_names));
_menu_view_sort_ports->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_view_sort_ports));
+ sigc::mem_fun(this, &Patchage::on_view_sort_ports));
_menu_view_arrange->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_arrange));
+ sigc::mem_fun(this, &Patchage::on_arrange));
_menu_view_sprung_layout->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_sprung_layout_toggled));
+ sigc::mem_fun(this, &Patchage::on_sprung_layout_toggled));
_menu_view_messages->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_view_messages));
+ sigc::mem_fun(this, &Patchage::on_view_messages));
_menu_view_toolbar->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_view_toolbar));
+ sigc::mem_fun(this, &Patchage::on_view_toolbar));
_menu_help_about->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_help_about));
+ sigc::mem_fun(this, &Patchage::on_help_about));
_menu_zoom_in->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_zoom_in));
+ sigc::mem_fun(this, &Patchage::on_zoom_in));
_menu_zoom_out->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_zoom_out));
+ sigc::mem_fun(this, &Patchage::on_zoom_out));
_menu_zoom_normal->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_zoom_normal));
+ sigc::mem_fun(this, &Patchage::on_zoom_normal));
_menu_zoom_full->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_zoom_full));
+ sigc::mem_fun(this, &Patchage::on_zoom_full));
_menu_increase_font_size->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_increase_font_size));
+ sigc::mem_fun(this, &Patchage::on_increase_font_size));
_menu_decrease_font_size->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_decrease_font_size));
+ sigc::mem_fun(this, &Patchage::on_decrease_font_size));
_menu_normal_font_size->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_normal_font_size));
+ sigc::mem_fun(this, &Patchage::on_normal_font_size));
if (_canvas->supports_sprung_layout()) {
_menu_view_sprung_layout->set_active(true);
@@ -289,11 +295,11 @@ Patchage::Patchage(int argc, char** argv)
_status_text->modify_text((Gtk::StateType)s, Gdk::Color("#FFFFFF"));
}
- _error_tag = Gtk::TextTag::create();
+ _error_tag = Gtk::TextTag::create();
_error_tag->property_foreground() = "#CC0000";
_status_text->get_buffer()->get_tag_table()->add(_error_tag);
- _warning_tag = Gtk::TextTag::create();
+ _warning_tag = Gtk::TextTag::create();
_warning_tag->property_foreground() = "#C4A000";
_status_text->get_buffer()->get_tag_table()->add(_warning_tag);
@@ -308,26 +314,23 @@ Patchage::Patchage(int argc, char** argv)
_canvas->set_port_order(port_order, NULL);
}
- _main_win->resize(
- static_cast<int>(_conf->get_window_size().x),
- static_cast<int>(_conf->get_window_size().y));
+ _main_win->resize(static_cast<int>(_conf->get_window_size().x),
+ static_cast<int>(_conf->get_window_size().y));
- _main_win->move(
- static_cast<int>(_conf->get_window_location().x),
- static_cast<int>(_conf->get_window_location().y));
+ _main_win->move(static_cast<int>(_conf->get_window_location().x),
+ static_cast<int>(_conf->get_window_location().y));
_legend = new Legend(*_conf);
_legend->signal_color_changed.connect(
- sigc::mem_fun(this, &Patchage::on_legend_color_change));
+ sigc::mem_fun(this, &Patchage::on_legend_color_change));
_legend_alignment->add(*Gtk::manage(_legend));
_legend->show_all();
_about_win->set_transient_for(*_main_win);
#ifdef __APPLE__
try {
- _about_win->set_logo(
- Gdk::Pixbuf::create_from_file(
- bundle_location() + "/Resources/Patchage.icns"));
+ _about_win->set_logo(Gdk::Pixbuf::create_from_file(
+ bundle_location() + "/Resources/Patchage.icns"));
} catch (const Glib::Exception& e) {
error_msg((boost::format("failed to set logo (%s)") % e.what()).str());
}
@@ -335,12 +338,13 @@ Patchage::Patchage(int argc, char** argv)
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
_jack_driver = new JackDriver(this);
- _jack_driver->signal_detached.connect(sigc::mem_fun(this, &Patchage::driver_detached));
+ _jack_driver->signal_detached.connect(
+ sigc::mem_fun(this, &Patchage::driver_detached));
- _menu_jack_connect->signal_activate().connect(sigc::bind(
- sigc::mem_fun(_jack_driver, &JackDriver::attach), true));
+ _menu_jack_connect->signal_activate().connect(
+ sigc::bind(sigc::mem_fun(_jack_driver, &JackDriver::attach), true));
_menu_jack_disconnect->signal_activate().connect(
- sigc::mem_fun(_jack_driver, &JackDriver::detach));
+ sigc::mem_fun(_jack_driver, &JackDriver::detach));
#endif
#ifdef HAVE_ALSA
@@ -357,28 +361,30 @@ Patchage::Patchage(int argc, char** argv)
_status_text->set_right_margin(4);
_status_text->set_pixels_below_lines(2);
- g_signal_connect(_main_win->gobj(), "configure-event",
- G_CALLBACK(configure_cb), this);
+ g_signal_connect(
+ _main_win->gobj(), "configure-event", G_CALLBACK(configure_cb), this);
_canvas->widget().grab_focus();
// Idle callback, check if we need to refresh
Glib::signal_timeout().connect(
- sigc::mem_fun(this, &Patchage::idle_callback), 100);
+ sigc::mem_fun(this, &Patchage::idle_callback), 100);
#ifdef PATCHAGE_GTK_OSX
// Set up Mac menu bar
- GtkosxApplication* osxapp = (GtkosxApplication*)g_object_new(
- GTKOSX_TYPE_APPLICATION, NULL);
+ GtkosxApplication* osxapp =
+ (GtkosxApplication*)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
_menubar->hide();
_menu_file_quit->hide();
gtkosx_application_set_menu_bar(osxapp, GTK_MENU_SHELL(_menubar->gobj()));
gtkosx_application_insert_app_menu_item(
- osxapp, GTK_WIDGET(_menu_help_about->gobj()), 0);
- g_signal_connect(_menubar->gobj(), "can-activate-accel",
- G_CALLBACK(can_activate_cb), NULL);
- g_signal_connect(osxapp, "NSApplicationWillTerminate",
- G_CALLBACK(terminate_cb), this);
+ osxapp, GTK_WIDGET(_menu_help_about->gobj()), 0);
+ g_signal_connect(_menubar->gobj(),
+ "can-activate-accel",
+ G_CALLBACK(can_activate_cb),
+ NULL);
+ g_signal_connect(
+ osxapp, "NSApplicationWillTerminate", G_CALLBACK(terminate_cb), this);
gtkosx_application_ready(osxapp);
#endif
}
@@ -485,13 +491,15 @@ Patchage::update_toolbar()
const jack_nframes_t buffer_size = _jack_driver->buffer_size();
const jack_nframes_t sample_rate = _jack_driver->sample_rate();
if (sample_rate != 0) {
- const int latency_ms = lrintf(buffer_size * 1000 / (float)sample_rate);
+ const int latency_ms =
+ lrintf(buffer_size * 1000 / (float)sample_rate);
std::stringstream ss;
- ss << " frames @ " << (sample_rate / 1000)
- << "kHz (" << latency_ms << "ms)";
+ ss << " frames @ " << (sample_rate / 1000) << "kHz (" << latency_ms
+ << "ms)";
_latency_label->set_label(ss.str());
_latency_label->set_visible(true);
- _buf_size_combo->set_active((int)log2f(_jack_driver->buffer_size()) - 5);
+ _buf_size_combo->set_active(
+ (int)log2f(_jack_driver->buffer_size()) - 5);
updating = false;
return;
}
@@ -588,7 +596,8 @@ void
Patchage::warning_msg(const std::string& msg)
{
Glib::RefPtr<Gtk::TextBuffer> buffer = _status_text->get_buffer();
- buffer->insert_with_tag(buffer->end(), std::string("\n") + msg, _warning_tag);
+ buffer->insert_with_tag(
+ buffer->end(), std::string("\n") + msg, _warning_tag);
_status_text->scroll_to_mark(buffer->get_insert(), 0);
}
@@ -619,28 +628,36 @@ Patchage::connect_widgets()
{
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
_jack_driver->signal_attached.connect(sigc::bind(
- sigc::mem_fun(*_menu_jack_connect, &Gtk::MenuItem::set_sensitive), false));
+ sigc::mem_fun(*_menu_jack_connect, &Gtk::MenuItem::set_sensitive),
+ false));
_jack_driver->signal_attached.connect(
- sigc::mem_fun(this, &Patchage::refresh));
+ sigc::mem_fun(this, &Patchage::refresh));
_jack_driver->signal_attached.connect(sigc::bind(
- sigc::mem_fun(*_menu_jack_disconnect, &Gtk::MenuItem::set_sensitive), true));
+ sigc::mem_fun(*_menu_jack_disconnect, &Gtk::MenuItem::set_sensitive),
+ true));
_jack_driver->signal_detached.connect(sigc::bind(
- sigc::mem_fun(*_menu_jack_connect, &Gtk::MenuItem::set_sensitive), true));
+ sigc::mem_fun(*_menu_jack_connect, &Gtk::MenuItem::set_sensitive),
+ true));
_jack_driver->signal_detached.connect(sigc::bind(
- sigc::mem_fun(*_menu_jack_disconnect, &Gtk::MenuItem::set_sensitive), false));
+ sigc::mem_fun(*_menu_jack_disconnect, &Gtk::MenuItem::set_sensitive),
+ false));
#endif
#ifdef HAVE_ALSA
_alsa_driver->signal_attached.connect(sigc::bind(
- sigc::mem_fun(*_menu_alsa_connect, &Gtk::MenuItem::set_sensitive), false));
+ sigc::mem_fun(*_menu_alsa_connect, &Gtk::MenuItem::set_sensitive),
+ false));
_alsa_driver->signal_attached.connect(sigc::bind(
- sigc::mem_fun(*_menu_alsa_disconnect, &Gtk::MenuItem::set_sensitive), true));
+ sigc::mem_fun(*_menu_alsa_disconnect, &Gtk::MenuItem::set_sensitive),
+ true));
_alsa_driver->signal_detached.connect(sigc::bind(
- sigc::mem_fun(*_menu_alsa_connect, &Gtk::MenuItem::set_sensitive), true));
+ sigc::mem_fun(*_menu_alsa_connect, &Gtk::MenuItem::set_sensitive),
+ true));
_alsa_driver->signal_detached.connect(sigc::bind(
- sigc::mem_fun(*_menu_alsa_disconnect, &Gtk::MenuItem::set_sensitive), false));
+ sigc::mem_fun(*_menu_alsa_disconnect, &Gtk::MenuItem::set_sensitive),
+ false));
#endif
}
@@ -648,11 +665,12 @@ Patchage::connect_widgets()
void
Patchage::show_open_session_dialog()
{
- Gtk::FileChooserDialog dialog(*_main_win, "Open Session",
- Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ Gtk::FileChooserDialog dialog(
+ *_main_win, "Open Session", Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- Gtk::Button* open_but = dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+ Gtk::Button* open_but =
+ dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
open_but->property_has_default() = true;
if (dialog.run() != Gtk::RESPONSE_OK) {
@@ -685,18 +703,19 @@ print_edge(GanvEdge* edge, void* data)
return;
}
- (*script) << "jack_connect '" << src->full_name()
- << "' '" << dst->full_name() << "' &\n";
+ (*script) << "jack_connect '" << src->full_name() << "' '"
+ << dst->full_name() << "' &\n";
}
void
Patchage::save_session(bool close)
{
- Gtk::FileChooserDialog dialog(*_main_win, "Save Session",
- Gtk::FILE_CHOOSER_ACTION_SAVE);
+ Gtk::FileChooserDialog dialog(
+ *_main_win, "Save Session", Gtk::FILE_CHOOSER_ACTION_SAVE);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- Gtk::Button* save_but = dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
+ Gtk::Button* save_but =
+ dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
save_but->property_has_default() = true;
if (dialog.run() != Gtk::RESPONSE_OK) {
@@ -710,14 +729,14 @@ Patchage::save_session(bool close)
}
path += '/';
- jack_session_command_t* cmd = jack_session_notify(
- _jack_driver->client(),
- NULL,
- close ? JackSessionSaveAndQuit : JackSessionSave,
- path.c_str());
+ jack_session_command_t* cmd =
+ jack_session_notify(_jack_driver->client(),
+ NULL,
+ close ? JackSessionSaveAndQuit : JackSessionSave,
+ path.c_str());
const std::string script_path = path + "jack-session";
- std::ofstream script(script_path.c_str());
+ std::ofstream script(script_path.c_str());
script << "#!/bin/sh\n\n";
const std::string var("${SESSION_DIR}");
@@ -889,9 +908,7 @@ highlight_color(guint c, guint delta)
const guint b = MIN(((c >> 8) & 0xFF) + delta, max_char);
const guint a = c & 0xFF;
- return ((((guint)(r)) << 24) |
- (((guint)(g)) << 16) |
- (((guint)(b)) << 8) |
+ return ((((guint)(r)) << 24) | (((guint)(g)) << 16) | (((guint)(b)) << 8) |
(((guint)(a))));
}
@@ -912,7 +929,8 @@ update_port_colors(GanvNode* node, void* data)
for (PatchageModule::iterator i = pmod->begin(); i != pmod->end(); ++i) {
PatchagePort* port = dynamic_cast<PatchagePort*>(*i);
if (port) {
- const uint32_t rgba = patchage->conf()->get_port_color(port->type());
+ const uint32_t rgba =
+ patchage->conf()->get_port_color(port->type());
port->set_fill_color(rgba);
port->set_border_color(highlight_color(rgba, 0x20));
}
@@ -932,7 +950,9 @@ update_edge_color(GanvEdge* edge, void* data)
}
void
-Patchage::on_legend_color_change(int id, const std::string& label, uint32_t rgba)
+Patchage::on_legend_color_change(int id,
+ const std::string& label,
+ uint32_t rgba)
{
_conf->set_port_color((PortType)id, rgba);
_canvas->for_each_node(update_port_colors, this);
@@ -949,7 +969,7 @@ Patchage::on_messages_resized(Gtk::Allocation& alloc)
void
Patchage::save()
{
- _conf->set_zoom(_canvas->get_zoom()); // Can be changed by ganv
+ _conf->set_zoom(_canvas->get_zoom()); // Can be changed by ganv
_conf->save();
}
@@ -968,14 +988,15 @@ Patchage::on_quit()
void
Patchage::on_export_image()
{
- Gtk::FileChooserDialog dialog("Export Image", Gtk::FILE_CHOOSER_ACTION_SAVE);
+ Gtk::FileChooserDialog dialog("Export Image",
+ Gtk::FILE_CHOOSER_ACTION_SAVE);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
dialog.set_default_response(Gtk::RESPONSE_OK);
dialog.set_transient_for(*_main_win);
typedef std::map<std::string, std::string> Types;
- Types types;
+ Types types;
types["*.dot"] = "Graphviz DOT";
types["*.pdf"] = "Portable Document Format";
types["*.ps"] = "PostScript";
@@ -997,9 +1018,12 @@ Patchage::on_export_image()
if (dialog.run() == Gtk::RESPONSE_OK) {
const std::string filename = dialog.get_filename();
if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
- Gtk::MessageDialog confirm(
- std::string("File exists! Overwrite ") + filename + "?",
- true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
+ Gtk::MessageDialog confirm(std::string("File exists! Overwrite ") +
+ filename + "?",
+ true,
+ Gtk::MESSAGE_WARNING,
+ Gtk::BUTTONS_YES_NO,
+ true);
confirm.set_transient_for(dialog);
if (confirm.run() != Gtk::RESPONSE_YES) {
return;
@@ -1021,13 +1045,14 @@ Patchage::on_view_messages()
const int max_pos = _main_paned->get_allocation().get_height();
const int min_height = (line_height + 2 * pad);
const int conf_height = _conf->get_messages_height();
- _main_paned->set_position(max_pos - std::max(conf_height, min_height));
+ _main_paned->set_position(max_pos -
+ std::max(conf_height, min_height));
_pane_initialized = true;
}
_log_scrolledwindow->show();
- _status_text->scroll_to_mark(
- _status_text->get_buffer()->get_insert(), 0);
+ _status_text->scroll_to_mark(_status_text->get_buffer()->get_insert(),
+ 0);
_conf->set_show_messages(true);
} else {
_log_scrolledwindow->hide();
@@ -1067,4 +1092,3 @@ Patchage::buffer_size_changed()
}
#endif
}
-
diff --git a/src/Patchage.hpp b/src/Patchage.hpp
index 9660d70..9f5f7c9 100644
--- a/src/Patchage.hpp
+++ b/src/Patchage.hpp
@@ -51,9 +51,12 @@ class JackDriver;
class PatchageCanvas;
class Configuration;
-namespace Ganv { class Module; }
+namespace Ganv {
+class Module;
+}
-class Patchage {
+class Patchage
+{
public:
Patchage(int argc, char** argv);
~Patchage();
@@ -62,10 +65,10 @@ public:
Gtk::Window* window() { return _main_win.get(); }
- Configuration* conf() const { return _conf; }
+ Configuration* conf() const { return _conf; }
JackDriver* jack_driver() const { return _jack_driver; }
#ifdef HAVE_ALSA
- AlsaDriver* alsa_driver() const { return _alsa_driver; }
+ AlsaDriver* alsa_driver() const { return _alsa_driver; }
#endif
#ifdef PATCHAGE_JACK_SESSION
void show_open_session_dialog();
@@ -80,7 +83,7 @@ public:
void quit() { _main_win->hide(); }
void refresh();
- inline void queue_refresh() { _refresh = true; }
+ inline void queue_refresh() { _refresh = true; }
inline void driver_detached() { _driver_detached = true; }
void info_msg(const std::string& msg);
@@ -90,11 +93,15 @@ public:
void update_state();
void store_window_location();
- bool show_human_names() const { return _menu_view_human_names->get_active(); }
- bool sort_ports() const { return _menu_view_sort_ports->get_active(); }
+ bool show_human_names() const
+ {
+ return _menu_view_human_names->get_active();
+ }
+ bool sort_ports() const { return _menu_view_sort_ports->get_active(); }
protected:
- class BufferSizeColumns : public Gtk::TreeModel::ColumnRecord {
+ class BufferSizeColumns : public Gtk::TreeModel::ColumnRecord
+ {
public:
BufferSizeColumns() { add(label); }
@@ -120,7 +127,8 @@ protected:
void on_increase_font_size();
void on_decrease_font_size();
void on_normal_font_size();
- void on_legend_color_change(int id, const std::string& label, uint32_t rgba);
+ void
+ on_legend_color_change(int id, const std::string& label, uint32_t rgba);
void on_messages_resized(Gtk::Allocation& alloc);
bool on_scroll(GdkEventScroll* ev);
@@ -137,8 +145,8 @@ protected:
#ifdef HAVE_ALSA
AlsaDriver* _alsa_driver;
- void menu_alsa_connect();
- void menu_alsa_disconnect();
+ void menu_alsa_connect();
+ void menu_alsa_disconnect();
#endif
#ifdef PATCHAGE_JACK_SESSION
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp
index a51ea32..828096b 100644
--- a/src/PatchageCanvas.cpp
+++ b/src/PatchageCanvas.cpp
@@ -23,12 +23,12 @@
#include "PatchagePort.hpp"
#if defined(HAVE_JACK_DBUS)
- #include "JackDbusDriver.hpp"
+# include "JackDbusDriver.hpp"
#elif defined(PATCHAGE_LIBJACK)
- #include "JackDriver.hpp"
+# include "JackDriver.hpp"
#endif
#ifdef HAVE_ALSA
- #include "AlsaDriver.hpp"
+# include "AlsaDriver.hpp"
#endif
#include "ganv/Edge.hpp"
@@ -38,15 +38,12 @@
using boost::format;
PatchageCanvas::PatchageCanvas(Patchage* app, int width, int height)
- : Ganv::Canvas(width, height)
- , _app(app)
+ : Ganv::Canvas(width, height)
+ , _app(app)
{
- signal_event.connect(
- sigc::mem_fun(this, &PatchageCanvas::on_event));
- signal_connect.connect(
- sigc::mem_fun(this, &PatchageCanvas::connect));
- signal_disconnect.connect(
- sigc::mem_fun(this, &PatchageCanvas::disconnect));
+ signal_event.connect(sigc::mem_fun(this, &PatchageCanvas::on_event));
+ signal_connect.connect(sigc::mem_fun(this, &PatchageCanvas::connect));
+ signal_disconnect.connect(sigc::mem_fun(this, &PatchageCanvas::disconnect));
}
PatchageModule*
@@ -57,7 +54,9 @@ PatchageCanvas::find_module(const std::string& name, ModuleType type)
return NULL;
PatchageModule* io_module = NULL;
- for (ModuleIndex::const_iterator j = i; j != _module_index.end() && j->first == name; ++j) {
+ for (ModuleIndex::const_iterator j = i;
+ j != _module_index.end() && j->first == name;
+ ++j) {
if (j->second->type() == type) {
return j->second;
} else if (j->second->type() == InputOutput) {
@@ -65,7 +64,7 @@ PatchageCanvas::find_module(const std::string& name, ModuleType type)
}
}
- // Return InputOutput module for Input or Output (or NULL if not found at all)
+ // Return InputOutput module for Input or Output (or NULL if not found)
return io_module;
}
@@ -95,7 +94,8 @@ PatchageCanvas::find_port(const PortID& id)
#ifdef PATCHAGE_LIBJACK
// Alsa ports are always indexed (or don't exist at all)
if (id.type == PortID::JACK_ID) {
- jack_port_t* jack_port = jack_port_by_id(_app->jack_driver()->client(), id.id.jack_id);
+ jack_port_t* jack_port =
+ jack_port_by_id(_app->jack_driver()->client(), id.id.jack_id);
if (!jack_port)
return NULL;
@@ -104,7 +104,8 @@ PatchageCanvas::find_port(const PortID& id)
_app->jack_driver()->port_names(id, module_name, port_name);
PatchageModule* module = find_module(
- module_name, (jack_port_flags(jack_port) & JackPortIsInput) ? Input : Output);
+ module_name,
+ (jack_port_flags(jack_port) & JackPortIsInput) ? Input : Output);
if (module)
pp = dynamic_cast<PatchagePort*>(module->get_port(port_name));
@@ -125,10 +126,13 @@ PatchageCanvas::remove_port(const PortID& id)
delete port;
}
-struct RemovePortsData {
+struct RemovePortsData
+{
typedef bool (*Predicate)(const PatchagePort*);
- RemovePortsData(Predicate p) : pred(p) {}
+ RemovePortsData(Predicate p)
+ : pred(p)
+ {}
Predicate pred;
std::set<PatchageModule*> empty;
@@ -137,8 +141,8 @@ struct RemovePortsData {
static void
delete_port_if_matches(GanvPort* port, void* cdata)
{
- RemovePortsData* data = (RemovePortsData*)cdata;
- PatchagePort* pport = dynamic_cast<PatchagePort*>(Glib::wrap(port));
+ RemovePortsData* data = (RemovePortsData*)cdata;
+ PatchagePort* pport = dynamic_cast<PatchagePort*>(Glib::wrap(port));
if (pport && data->pred(pport)) {
delete pport;
}
@@ -173,8 +177,7 @@ PatchageCanvas::remove_ports(bool (*pred)(const PatchagePort*))
for_each_node(remove_ports_matching, &data);
- for (PortIndex::iterator i = _port_index.begin();
- i != _port_index.end();) {
+ for (PortIndex::iterator i = _port_index.begin(); i != _port_index.end();) {
PortIndex::iterator next = i;
++next;
if (pred(i->second)) {
@@ -184,7 +187,8 @@ PatchageCanvas::remove_ports(bool (*pred)(const PatchagePort*))
}
for (std::set<PatchageModule*>::iterator i = data.empty.begin();
- i != data.empty.end(); ++i) {
+ i != data.empty.end();
+ ++i) {
delete *i;
}
}
@@ -197,8 +201,11 @@ PatchageCanvas::find_port_by_name(const std::string& client_name,
if (i == _module_index.end())
return NULL;
- for (ModuleIndex::const_iterator j = i; j != _module_index.end() && j->first == client_name; ++j) {
- PatchagePort* port = dynamic_cast<PatchagePort*>(j->second->get_port(port_name));
+ for (ModuleIndex::const_iterator j = i;
+ j != _module_index.end() && j->first == client_name;
+ ++j) {
+ PatchagePort* port =
+ dynamic_cast<PatchagePort*>(j->second->get_port(port_name));
if (port)
return port;
}
@@ -207,8 +214,7 @@ PatchageCanvas::find_port_by_name(const std::string& client_name,
}
void
-PatchageCanvas::connect(Ganv::Node* port1,
- Ganv::Node* port2)
+PatchageCanvas::connect(Ganv::Node* port1, Ganv::Node* port2)
{
PatchagePort* p1 = dynamic_cast<PatchagePort*>(port1);
PatchagePort* p2 = dynamic_cast<PatchagePort*>(port2);
@@ -216,10 +222,10 @@ PatchageCanvas::connect(Ganv::Node* port1,
return;
if ((p1->type() == JACK_AUDIO && p2->type() == JACK_AUDIO) ||
- (p1->type() == JACK_MIDI && p2->type() == JACK_MIDI) ||
- (p1->type() == JACK_AUDIO && p2->type() == JACK_CV) ||
- (p1->type() == JACK_CV && p2->type() == JACK_CV) ||
- (p1->type() == JACK_OSC && p2->type() == JACK_OSC)) {
+ (p1->type() == JACK_MIDI && p2->type() == JACK_MIDI) ||
+ (p1->type() == JACK_AUDIO && p2->type() == JACK_CV) ||
+ (p1->type() == JACK_CV && p2->type() == JACK_CV) ||
+ (p1->type() == JACK_OSC && p2->type() == JACK_OSC)) {
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
_app->jack_driver()->connect(p1, p2);
#endif
@@ -233,8 +239,7 @@ PatchageCanvas::connect(Ganv::Node* port1,
}
void
-PatchageCanvas::disconnect(Ganv::Node* port1,
- Ganv::Node* port2)
+PatchageCanvas::disconnect(Ganv::Node* port1, Ganv::Node* port2)
{
PatchagePort* input = dynamic_cast<PatchagePort*>(port1);
PatchagePort* output = dynamic_cast<PatchagePort*>(port2);
@@ -244,8 +249,8 @@ PatchageCanvas::disconnect(Ganv::Node* port1,
if (input->is_output() && output->is_input()) {
// Damn, guessed wrong
PatchagePort* swap = input;
- input = output;
- output = swap;
+ input = output;
+ output = swap;
}
if (!input || !output || input->is_output() || output->is_input()) {
@@ -253,10 +258,8 @@ PatchageCanvas::disconnect(Ganv::Node* port1,
return;
}
- if (input->type() == JACK_AUDIO ||
- input->type() == JACK_MIDI ||
- input->type() == JACK_CV ||
- input->type() == JACK_OSC) {
+ if (input->type() == JACK_AUDIO || input->type() == JACK_MIDI ||
+ input->type() == JACK_CV || input->type() == JACK_OSC) {
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
_app->jack_driver()->disconnect(output, input);
#endif
@@ -275,7 +278,7 @@ PatchageCanvas::add_module(const std::string& name, PatchageModule* module)
_module_index.insert(std::make_pair(name, module));
// Join partners, if applicable
- PatchageModule* in_module = NULL;
+ PatchageModule* in_module = NULL;
PatchageModule* out_module = NULL;
if (module->type() == Input) {
in_module = module;
@@ -321,7 +324,8 @@ PatchageCanvas::remove_module(PatchageModule* module)
{
// Remove module from cache
for (ModuleIndex::iterator i = _module_index.find(module->get_label());
- i != _module_index.end() && i->first == module->get_label(); ++i) {
+ i != _module_index.end() && i->first == module->get_label();
+ ++i) {
if (i->second == module) {
_module_index.erase(i);
return;
diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp
index ffe43ac..35d0abb 100644
--- a/src/PatchageCanvas.hpp
+++ b/src/PatchageCanvas.hpp
@@ -26,7 +26,7 @@
#include "ganv/Canvas.hpp"
#ifdef HAVE_ALSA
- #include <alsa/asoundlib.h>
+# include <alsa/asoundlib.h>
#endif
#include <map>
@@ -37,7 +37,8 @@ class Patchage;
class PatchageModule;
class PatchagePort;
-class PatchageCanvas : public Ganv::Canvas {
+class PatchageCanvas : public Ganv::Canvas
+{
public:
PatchageCanvas(Patchage* _app, int width, int height);
@@ -50,13 +51,12 @@ public:
PatchagePort* find_port_by_name(const std::string& client_name,
const std::string& port_name);
- void connect(Ganv::Node* port1,
- Ganv::Node* port2);
+ void connect(Ganv::Node* port1, Ganv::Node* port2);
- void disconnect(Ganv::Node* port1,
- Ganv::Node* port2);
+ void disconnect(Ganv::Node* port1, Ganv::Node* port2);
- void index_port(const PortID& id, PatchagePort* port) {
+ void index_port(const PortID& id, PatchagePort* port)
+ {
_port_index.insert(std::make_pair(id, port));
}
@@ -77,10 +77,10 @@ private:
bool on_connection_event(Ganv::Edge* c, GdkEvent* ev);
typedef std::map<const PortID, PatchagePort*> PortIndex;
- PortIndex _port_index;
+ PortIndex _port_index;
typedef std::multimap<const std::string, PatchageModule*> ModuleIndex;
- ModuleIndex _module_index;
+ ModuleIndex _module_index;
};
#endif // PATCHAGE_PATCHAGECANVAS_HPP
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index b1489e3..78f0829 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -18,18 +18,18 @@
#include "patchage_config.h"
+#include "Driver.hpp"
#include "Patchage.hpp"
#include "PatchageCanvas.hpp"
#include "PatchageModule.hpp"
-#include "Driver.hpp"
#if defined(HAVE_JACK_DBUS)
-# include "JackDbusDriver.hpp"
+# include "JackDbusDriver.hpp"
#elif defined(PATCHAGE_LIBJACK)
-# include "JackDriver.hpp"
+# include "JackDriver.hpp"
#endif
#ifdef HAVE_ALSA
-# include "AlsaDriver.hpp"
+# include "AlsaDriver.hpp"
#endif
#include <boost/format.hpp>
@@ -69,12 +69,12 @@ PatchageEvent::execute(Patchage* patchage)
PatchagePort* port = driver->create_port_view(patchage, _port_1);
if (!port) {
patchage->error_msg(
- (format("Unable to create view for port `%1%'")
- % _port_1).str());
+ (format("Unable to create view for port `%1%'") % _port_1)
+ .str());
}
} else {
patchage->error_msg(
- (format("Unknown type for port `%1%'") % _port_1).str());
+ (format("Unknown type for port `%1%'") % _port_1).str());
}
} else if (_type == PORT_DESTRUCTION) {
@@ -87,11 +87,13 @@ PatchageEvent::execute(Patchage* patchage)
PatchagePort* port_2 = patchage->canvas()->find_port(_port_2);
if (!port_1)
- patchage->error_msg((format("Unable to find port `%1%' to connect")
- % _port_1).str());
+ patchage->error_msg(
+ (format("Unable to find port `%1%' to connect") % _port_1)
+ .str());
else if (!port_2)
- patchage->error_msg((format("Unable to find port `%1%' to connect")
- % _port_2).str());
+ patchage->error_msg(
+ (format("Unable to find port `%1%' to connect") % _port_2)
+ .str());
else
patchage->canvas()->make_connection(port_1, port_2);
@@ -101,11 +103,13 @@ PatchageEvent::execute(Patchage* patchage)
PatchagePort* port_2 = patchage->canvas()->find_port(_port_2);
if (!port_1)
- patchage->error_msg((format("Unable to find port `%1%' to disconnect")
- % _port_1).str());
+ patchage->error_msg(
+ (format("Unable to find port `%1%' to disconnect") % _port_1)
+ .str());
else if (!port_2)
- patchage->error_msg((format("Unable to find port `%1%' to disconnect")
- % _port_2).str());
+ patchage->error_msg(
+ (format("Unable to find port `%1%' to disconnect") % _port_2)
+ .str());
else
patchage->canvas()->remove_edge_between(port_1, port_2);
}
diff --git a/src/PatchageEvent.hpp b/src/PatchageEvent.hpp
index 4fe0bf3..2c9efb4 100644
--- a/src/PatchageEvent.hpp
+++ b/src/PatchageEvent.hpp
@@ -23,10 +23,10 @@
#include "PortID.hpp"
#ifdef PATCHAGE_LIBJACK
- #include <jack/jack.h>
+# include <jack/jack.h>
#endif
#ifdef HAVE_ALSA
- #include <alsa/asoundlib.h>
+# include <alsa/asoundlib.h>
#endif
#include <cstring>
@@ -35,9 +35,11 @@ class Patchage;
/** A Driver event to be processed by the GUI thread.
*/
-class PatchageEvent {
+class PatchageEvent
+{
public:
- enum Type {
+ enum Type
+ {
NULL_EVENT = 0,
REFRESH,
CLIENT_CREATION,
@@ -48,29 +50,29 @@ public:
DISCONNECTION
};
- explicit PatchageEvent(Type type=NULL_EVENT)
- : _str(NULL)
- , _type(type)
+ explicit PatchageEvent(Type type = NULL_EVENT)
+ : _str(NULL)
+ , _type(type)
{}
PatchageEvent(Type type, const char* str)
- : _str(g_strdup(str))
- , _type(type)
+ : _str(g_strdup(str))
+ , _type(type)
{}
- template <typename P>
+ template<typename P>
PatchageEvent(Type type, P port)
- : _str(NULL)
- , _port_1(port)
- , _type(type)
+ : _str(NULL)
+ , _port_1(port)
+ , _type(type)
{}
- template <typename P>
+ template<typename P>
PatchageEvent(Type type, P port_1, P port_2)
- : _str(NULL)
- , _port_1(port_1, false)
- , _port_2(port_2, true)
- , _type(type)
+ : _str(NULL)
+ , _port_1(port_1, false)
+ , _port_2(port_2, true)
+ , _type(type)
{}
void execute(Patchage* patchage);
diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp
index 5f3c8c0..db61392 100644
--- a/src/PatchageModule.cpp
+++ b/src/PatchageModule.cpp
@@ -20,19 +20,21 @@
#include "PatchageCanvas.hpp"
#include "PatchagePort.hpp"
-PatchageModule::PatchageModule(
- Patchage* app, const std::string& name, ModuleType type, double x, double y)
- : Module(*app->canvas().get(), name, x, y)
- , _app(app)
- , _menu(NULL)
- , _name(name)
- , _type(type)
+PatchageModule::PatchageModule(Patchage* app,
+ const std::string& name,
+ ModuleType type,
+ double x,
+ double y)
+ : Module(*app->canvas().get(), name, x, y)
+ , _app(app)
+ , _menu(NULL)
+ , _name(name)
+ , _type(type)
{
- signal_event().connect(
- sigc::mem_fun(this, &PatchageModule::on_event));
+ signal_event().connect(sigc::mem_fun(this, &PatchageModule::on_event));
signal_moved().connect(
- sigc::mem_fun(this, &PatchageModule::store_location));
+ sigc::mem_fun(this, &PatchageModule::store_location));
// Set as source by default, turned off if input ports added
set_is_source(true);
@@ -72,22 +74,19 @@ PatchageModule::update_menu()
bool
PatchageModule::show_menu(GdkEventButton* ev)
{
- _menu = new Gtk::Menu();
+ _menu = new Gtk::Menu();
Gtk::Menu::MenuList& items = _menu->items();
if (_type == InputOutput) {
- items.push_back(
- Gtk::Menu_Helpers::MenuElem(
- "_Split", sigc::mem_fun(this, &PatchageModule::split)));
+ items.push_back(Gtk::Menu_Helpers::MenuElem(
+ "_Split", sigc::mem_fun(this, &PatchageModule::split)));
update_menu();
} else {
- items.push_back(
- Gtk::Menu_Helpers::MenuElem(
- "_Join", sigc::mem_fun(this, &PatchageModule::join)));
+ items.push_back(Gtk::Menu_Helpers::MenuElem(
+ "_Join", sigc::mem_fun(this, &PatchageModule::join)));
}
- items.push_back(
- Gtk::Menu_Helpers::MenuElem(
- "_Disconnect All",
- sigc::mem_fun(this, &PatchageModule::menu_disconnect_all)));
+ items.push_back(Gtk::Menu_Helpers::MenuElem(
+ "_Disconnect All",
+ sigc::mem_fun(this, &PatchageModule::menu_disconnect_all)));
_menu->popup(ev->button, ev->time);
return true;
@@ -110,8 +109,7 @@ PatchageModule::load_location()
if (_app->conf()->get_module_location(_name, _type, loc))
move_to(loc.x, loc.y);
else
- move_to(20 + rand() % 640,
- 20 + rand() % 480);
+ move_to(20 + rand() % 640, 20 + rand() % 480);
}
void
diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp
index 14e7516..5ccc751 100644
--- a/src/PatchagePort.hpp
+++ b/src/PatchagePort.hpp
@@ -24,8 +24,8 @@
#include "PatchageModule.hpp"
#include "PortID.hpp"
-#include "ganv/Port.hpp"
#include "ganv/Module.hpp"
+#include "ganv/Port.hpp"
#include <gtkmm/menu.h>
#include <gtkmm/menushell.h>
@@ -44,29 +44,30 @@ public:
bool is_input,
uint32_t color,
bool show_human_name,
- boost::optional<int> order=boost::optional<int>())
- : Port(module,
- (show_human_name && !human_name.empty()) ? human_name : name,
- is_input,
- color)
- , _type(type)
- , _name(name)
- , _human_name(human_name)
- , _order(order)
+ boost::optional<int> order = boost::optional<int>())
+ : Port(module,
+ (show_human_name && !human_name.empty()) ? human_name : name,
+ is_input,
+ color)
+ , _type(type)
+ , _name(name)
+ , _human_name(human_name)
+ , _order(order)
{
- signal_event().connect(
- sigc::mem_fun(this, &PatchagePort::on_event));
+ signal_event().connect(sigc::mem_fun(this, &PatchagePort::on_event));
}
virtual ~PatchagePort() {}
/** Returns the full name of this port, as "modulename:portname" */
- std::string full_name() const {
+ std::string full_name() const
+ {
PatchageModule* pmod = dynamic_cast<PatchageModule*>(get_module());
return std::string(pmod->name()) + ":" + _name;
}
- void show_human_name(bool human) {
+ void show_human_name(bool human)
+ {
if (human && !_human_name.empty()) {
set_label(_human_name.c_str());
} else {
@@ -74,24 +75,24 @@ public:
}
}
- bool on_event(GdkEvent* ev) {
+ bool on_event(GdkEvent* ev)
+ {
if (ev->type != GDK_BUTTON_PRESS || ev->button.button != 3) {
return false;
}
Gtk::Menu* menu = Gtk::manage(new Gtk::Menu());
- menu->items().push_back(
- Gtk::Menu_Helpers::MenuElem(
- "Disconnect", sigc::mem_fun(this, &Port::disconnect)));
+ menu->items().push_back(Gtk::Menu_Helpers::MenuElem(
+ "Disconnect", sigc::mem_fun(this, &Port::disconnect)));
menu->popup(ev->button.button, ev->button.time);
return true;
}
- PortType type() const { return _type; }
- const std::string& name() const { return _name; }
+ PortType type() const { return _type; }
+ const std::string& name() const { return _name; }
const std::string& human_name() const { return _human_name; }
- const boost::optional<int>& order() const { return _order; }
+ const boost::optional<int>& order() const { return _order; }
private:
PortType _type;
diff --git a/src/PortID.hpp b/src/PortID.hpp
index f8e530f..01a8ec4 100644
--- a/src/PortID.hpp
+++ b/src/PortID.hpp
@@ -22,39 +22,60 @@
#include "PatchagePort.hpp"
#ifdef PATCHAGE_LIBJACK
- #include <jack/jack.h>
+# include <jack/jack.h>
#endif
#ifdef HAVE_ALSA
- #include <alsa/asoundlib.h>
+# include <alsa/asoundlib.h>
#endif
#include <cstring>
#include <iostream>
-struct PortID {
- PortID() : type(NULL_PORT_ID) { memset(&id, 0, sizeof(id)); }
- PortID(const PortID& copy) : type(copy.type) {
+struct PortID
+{
+ PortID()
+ : type(NULL_PORT_ID)
+ {
+ memset(&id, 0, sizeof(id));
+ }
+ PortID(const PortID& copy)
+ : type(copy.type)
+ {
memcpy(&id, &copy.id, sizeof(id));
}
- enum { NULL_PORT_ID, JACK_ID, ALSA_ADDR } type;
+ enum
+ {
+ NULL_PORT_ID,
+ JACK_ID,
+ ALSA_ADDR
+ } type;
#ifdef PATCHAGE_LIBJACK
- PortID(jack_port_id_t jack_id, bool ign=false)
- : type(JACK_ID) { id.jack_id = jack_id; }
+ PortID(jack_port_id_t jack_id, bool ign = false)
+ : type(JACK_ID)
+ {
+ id.jack_id = jack_id;
+ }
#endif
#ifdef HAVE_ALSA
PortID(snd_seq_addr_t addr, bool in)
- : type(ALSA_ADDR) { id.alsa_addr = addr; id.is_input = in; }
+ : type(ALSA_ADDR)
+ {
+ id.alsa_addr = addr;
+ id.is_input = in;
+ }
#endif
- union {
+ union
+ {
#ifdef PATCHAGE_LIBJACK
jack_port_id_t jack_id;
#endif
#ifdef HAVE_ALSA
- struct {
+ struct
+ {
snd_seq_addr_t alsa_addr;
bool is_input : 1;
};
@@ -75,8 +96,9 @@ operator<<(std::ostream& os, const PortID& id)
break;
case PortID::ALSA_ADDR:
#ifdef HAVE_ALSA
- return os << "alsa:" << (int)id.id.alsa_addr.client << ":" << (int)id.id.alsa_addr.port
- << ":" << (id.id.is_input ? "in" : "out");
+ return os << "alsa:" << (int)id.id.alsa_addr.client << ":"
+ << (int)id.id.alsa_addr.port << ":"
+ << (id.id.is_input ? "in" : "out");
#endif
break;
}
@@ -100,12 +122,12 @@ operator<(const PortID& a, const PortID& b)
break;
case PortID::ALSA_ADDR:
#ifdef HAVE_ALSA
- if ((a.id.alsa_addr.client < b.id.alsa_addr.client)
- || ((a.id.alsa_addr.client == b.id.alsa_addr.client)
- && a.id.alsa_addr.port < b.id.alsa_addr.port)) {
+ if ((a.id.alsa_addr.client < b.id.alsa_addr.client) ||
+ ((a.id.alsa_addr.client == b.id.alsa_addr.client) &&
+ a.id.alsa_addr.port < b.id.alsa_addr.port)) {
return true;
- } else if (a.id.alsa_addr.client == b.id.alsa_addr.client
- && a.id.alsa_addr.port == b.id.alsa_addr.port) {
+ } else if (a.id.alsa_addr.client == b.id.alsa_addr.client &&
+ a.id.alsa_addr.port == b.id.alsa_addr.port) {
return (a.id.is_input < b.id.is_input);
} else {
return false;
diff --git a/src/Queue.hpp b/src/Queue.hpp
index ab47aed..dddafc6 100644
--- a/src/Queue.hpp
+++ b/src/Queue.hpp
@@ -20,7 +20,7 @@
#include <cassert>
/** Realtime-safe single-reader single-writer queue */
-template <typename T>
+template<typename T>
class Queue
{
public:
@@ -44,23 +44,23 @@ public:
inline void pop();
private:
- std::atomic<size_t> _front; ///< Index to front of queue
- std::atomic<size_t> _back; ///< Index to back of queue (one past end)
- const size_t _size; ///< Size of `_objects` (at most _size-1)
- T* const _objects; ///< Fixed array containing queued elements
+ std::atomic<size_t> _front; ///< Index to front of queue
+ std::atomic<size_t> _back; ///< Index to back of queue (one past end)
+ const size_t _size; ///< Size of `_objects` (at most _size-1)
+ T* const _objects; ///< Fixed array containing queued elements
};
template<typename T>
Queue<T>::Queue(size_t size)
- : _front(0)
- , _back(0)
- , _size(size + 1)
- , _objects(new T[_size])
+ : _front(0)
+ , _back(0)
+ , _size(size + 1)
+ , _objects(new T[_size])
{
assert(size > 1);
}
-template <typename T>
+template<typename T>
Queue<T>::~Queue()
{
delete[] _objects;
@@ -68,7 +68,7 @@ Queue<T>::~Queue()
/** Return whether or not the queue is empty.
*/
-template <typename T>
+template<typename T>
inline bool
Queue<T>::empty() const
{
@@ -77,7 +77,7 @@ Queue<T>::empty() const
/** Return whether or not the queue is full.
*/
-template <typename T>
+template<typename T>
inline bool
Queue<T>::full() const
{
@@ -86,7 +86,7 @@ Queue<T>::full() const
/** Return the element at the front of the queue without removing it
*/
-template <typename T>
+template<typename T>
inline T&
Queue<T>::front() const
{
@@ -98,16 +98,16 @@ Queue<T>::front() const
* @returns true if `elem` was successfully pushed onto the queue,
* false otherwise (queue is full).
*/
-template <typename T>
+template<typename T>
inline bool
Queue<T>::push(const T& elem)
{
if (full()) {
return false;
} else {
- unsigned back = _back.load();
+ unsigned back = _back.load();
_objects[back] = elem;
- _back = (back + 1) % _size;
+ _back = (back + 1) % _size;
return true;
}
}
@@ -118,7 +118,7 @@ Queue<T>::push(const T& elem)
*
* @returns the element popped.
*/
-template <typename T>
+template<typename T>
inline void
Queue<T>::pop()
{
@@ -128,4 +128,4 @@ Queue<T>::pop()
_front = (_front.load() + 1) % (_size);
}
-#endif // QUEUE_HPP_INCLUDED
+#endif // QUEUE_HPP_INCLUDED
diff --git a/src/UIFile.hpp b/src/UIFile.hpp
index 343b1a6..72dd48a 100644
--- a/src/UIFile.hpp
+++ b/src/UIFile.hpp
@@ -20,7 +20,7 @@
#include "patchage_config.h"
#ifdef PATCHAGE_BINLOC
-# include "binary_location.h"
+# include "binary_location.h"
#endif
#include <gtkmm/builder.h>
@@ -30,16 +30,19 @@
#include <sstream>
#include <string>
-class UIFile {
+class UIFile
+{
public:
- inline static bool is_readable(const std::string& filename) {
+ inline static bool is_readable(const std::string& filename)
+ {
std::ifstream fs(filename.c_str());
- const bool fail = fs.fail();
+ const bool fail = fs.fail();
fs.close();
return !fail;
}
- static Glib::RefPtr<Gtk::Builder> open(const std::string& base_name) {
+ static Glib::RefPtr<Gtk::Builder> open(const std::string& base_name)
+ {
std::string ui_filename;
#ifdef PATCHAGE_BINLOC
const std::string bundle = bundle_location();
diff --git a/src/Widget.hpp b/src/Widget.hpp
index 6089d41..03c5f8e 100644
--- a/src/Widget.hpp
+++ b/src/Widget.hpp
@@ -21,10 +21,12 @@
#include <string>
-template <typename W>
-class Widget {
+template<typename W>
+class Widget
+{
public:
- Widget(Glib::RefPtr<Gtk::Builder> xml, const std::string& name) {
+ Widget(Glib::RefPtr<Gtk::Builder> xml, const std::string& name)
+ {
xml->get_widget(name, _me);
}
@@ -33,12 +35,12 @@ public:
void destroy() { delete _me; }
- W* get() { return _me; }
- const W* get() const { return _me; }
- W* operator->() { return _me; }
+ W* get() { return _me; }
+ const W* get() const { return _me; }
+ W* operator->() { return _me; }
const W* operator->() const { return _me; }
- W& operator*() { return *_me; }
- const W& operator*() const { return *_me; }
+ W& operator*() { return *_me; }
+ const W& operator*() const { return *_me; }
private:
W* _me;
diff --git a/src/main.cpp b/src/main.cpp
index 80d400d..5a8d6be 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,16 +15,14 @@
*/
#ifdef __APPLE__
+# include "binary_location.h"
-#include "binary_location.h"
+# include <gtk/gtkrc.h>
-#include <gtk/gtkrc.h>
-
-#include <unistd.h>
-
-#include <cstdlib>
-#include <string>
+# include <unistd.h>
+# include <cstdlib>
+# include <string>
#endif
#include "Patchage.hpp"
@@ -78,13 +76,13 @@ main(int argc, char** argv)
try {
- Glib::thread_init();
+ Glib::thread_init();
- Gtk::Main app(argc, argv);
+ Gtk::Main app(argc, argv);
- Patchage patchage(argc, argv);
- app.run(*patchage.window());
- patchage.save();
+ Patchage patchage(argc, argv);
+ app.run(*patchage.window());
+ patchage.save();
} catch (std::exception& e) {
std::cerr << "patchage: error: " << e.what() << std::endl;