summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-11-25 06:12:28 +0000
committerDavid Robillard <d@drobilla.net>2011-11-25 06:12:28 +0000
commita0d6e0d2ff7abdcfcd78d4002f2dc42f4cde82ed (patch)
tree0c581c8ed03ca280e03b6ec2827ff41fb6c617b8
parent572adb6873294bf2f26062cf297660aa449eb675 (diff)
downloadpatchage-a0d6e0d2ff7abdcfcd78d4002f2dc42f4cde82ed.tar.gz
patchage-a0d6e0d2ff7abdcfcd78d4002f2dc42f4cde82ed.tar.bz2
patchage-a0d6e0d2ff7abdcfcd78d4002f2dc42f4cde82ed.zip
Log (almost) everything to the messages window instead of the console.
Remove latency and load stuff in favour of plain old messages. Remove status bar. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@3627 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/AlsaDriver.cpp88
-rw-r--r--src/JackDbusDriver.cpp58
-rw-r--r--src/JackDbusDriver.hpp5
-rw-r--r--src/JackDriver.cpp91
-rw-r--r--src/JackDriver.hpp3
-rw-r--r--src/Patchage.cpp119
-rw-r--r--src/Patchage.hpp29
-rw-r--r--src/PatchageCanvas.cpp12
-rw-r--r--src/PatchageCanvas.hpp2
-rw-r--r--src/PatchageEvent.cpp29
-rw-r--r--src/patchage.ui161
11 files changed, 144 insertions, 453 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index c0f7eef..8ec2d36 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -19,8 +19,9 @@
#include <string>
#include <utility>
+#include <boost/format.hpp>
+
#include "raul/SharedPtr.hpp"
-#include "raul/log.hpp"
#include "AlsaDriver.hpp"
#include "Patchage.hpp"
@@ -30,6 +31,7 @@
using std::endl;
using std::string;
+using boost::format;
AlsaDriver::AlsaDriver(Patchage* app)
: _app(app)
@@ -50,10 +52,10 @@ AlsaDriver::attach(bool /*launch_daemon*/)
{
int ret = snd_seq_open(&_seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
if (ret) {
- _app->status_msg("[ALSA] Unable to attach");
+ _app->error_msg("Alsa: Unable to attach.");
_seq = NULL;
} else {
- _app->status_msg("[ALSA] Attached");
+ _app->info_msg("Alsa: Attached.");
snd_seq_set_client_name(_seq, "Patchage");
@@ -63,7 +65,7 @@ AlsaDriver::attach(bool /*launch_daemon*/)
ret = pthread_create(&_refresh_thread, &attr, &AlsaDriver::refresh_main, this);
if (ret)
- Raul::error << "Couldn't start refresh thread" << endl;
+ _app->error_msg("Alsa: Failed to start refresh thread.");
signal_attached.emit();
}
@@ -78,7 +80,7 @@ AlsaDriver::detach()
snd_seq_close(_seq);
_seq = NULL;
signal_detached.emit();
- _app->status_msg("[ALSA] Detached");
+ _app->info_msg("Alsa: Detached.");
}
}
@@ -131,7 +133,7 @@ AlsaDriver::refresh()
if (ignore(addr)) {
continue;
}
-
+
create_port_view_internal(_app, addr, parent, port);
}
}
@@ -146,7 +148,7 @@ AlsaDriver::refresh()
if (ignore(*addr)) {
continue;
}
-
+
PatchagePort* port = _app->canvas()->find_port(PortID(*addr, false));
if (!port) {
continue;
@@ -166,7 +168,7 @@ AlsaDriver::refresh()
_app->canvas()->add_connection(port,
port2,
port->color() + 0x22222200);
-
+
snd_seq_query_subscribe_set_index(
subsinfo, snd_seq_query_subscribe_get_index(subsinfo) + 1);
}
@@ -209,10 +211,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)
+ Patchage* patchage,
+ uint8_t client_id,
+ const std::string& client_name,
+ ModuleType type)
{
PatchageModule* m = find_module(client_id, type);
if (!m) {
@@ -226,10 +228,10 @@ AlsaDriver::find_or_create_module(
void
AlsaDriver::create_port_view_internal(
- Patchage* patchage,
- snd_seq_addr_t addr,
- PatchageModule*& m,
- PatchagePort*& port)
+ Patchage* patchage,
+ snd_seq_addr_t addr,
+ PatchageModule*& m,
+ PatchagePort*& port)
{
if (ignore(addr))
return;
@@ -277,9 +279,9 @@ AlsaDriver::create_port_view_internal(
}
/*cout << "ALSA PORT: " << client_name << " : " << port_name
- << " is_application = " << is_application
- << " is_duplex = " << is_duplex
- << " split = " << split << endl;*/
+ << " is_application = " << is_application
+ << " is_duplex = " << is_duplex
+ << " split = " << split << endl;*/
if (!split) {
m = find_or_create_module(_app, addr.client, client_name, InputOutput);
@@ -309,7 +311,7 @@ AlsaDriver::create_port_view_internal(
PatchagePort*
AlsaDriver::create_port(PatchageModule& parent,
- const string& name, bool is_input, snd_seq_addr_t addr)
+ const string& name, bool is_input, snd_seq_addr_t addr)
{
PatchagePort* ret = new PatchagePort(
parent, ALSA_MIDI, name, is_input,
@@ -376,7 +378,7 @@ AlsaDriver::connect(PatchagePort* src_port,
PortAddrs::const_iterator d = _port_addrs.find(dst_port);
if (s == _port_addrs.end() || d == _port_addrs.end()) {
- Raul::error << "[ALSA] Attempt to connect port with no address" << endl;
+ _app->error_msg("Alsa: Attempt to connect port with no address.");
return false;
}
@@ -385,7 +387,7 @@ AlsaDriver::connect(PatchagePort* src_port,
if (src.id.alsa_addr.client == dst.id.alsa_addr.client
&& src.id.alsa_addr.port == dst.id.alsa_addr.port) {
- Raul::warn << "[ALSA] Refusing to connect port to itself" << endl;
+ _app->warning_msg("Alsa: Refusing to connect port to itself.");
return false;
}
@@ -401,22 +403,23 @@ AlsaDriver::connect(PatchagePort* src_port,
// Already connected (shouldn't happen)
if (!snd_seq_get_port_subscription(_seq, subs)) {
- Raul::error << "[ALSA] Attempt to double subscribe ports" << endl;
+ _app->error_msg("Alsa: Attempt to double subscribe ports.");
result = false;
}
int ret = snd_seq_subscribe_port(_seq, subs);
if (ret < 0) {
- Raul::error << "[ALSA] Subscription failed: " << snd_strerror(ret) << endl;
+ _app->error_msg((format("Alsa: Subscription failed (%1%).")
+ % snd_strerror(ret)).str());
result = false;
}
if (result)
- _app->status_msg(string("[ALSA] Connected ")
- + src_port->full_name() + " -> " + dst_port->full_name());
+ _app->info_msg(string("Alsa: Connected ")
+ + src_port->full_name() + " => " + dst_port->full_name());
else
- _app->status_msg(string("[ALSA] Unable to connect ")
- + src_port->full_name() + " -> " + dst_port->full_name());
+ _app->error_msg(string("Alsa: Unable to connect ")
+ + src_port->full_name() + " => " + dst_port->full_name());
return (!result);
}
@@ -433,7 +436,7 @@ AlsaDriver::disconnect(PatchagePort* src_port,
PortAddrs::const_iterator d = _port_addrs.find(dst_port);
if (s == _port_addrs.end() || d == _port_addrs.end()) {
- Raul::error << "[ALSA] Attempt to connect port with no address" << endl;
+ _app->error_msg("Alsa: Attempt to connect port with no address");
return false;
}
@@ -450,18 +453,20 @@ AlsaDriver::disconnect(PatchagePort* src_port,
// Not connected (shouldn't happen)
if (snd_seq_get_port_subscription(_seq, subs) != 0) {
- Raul::error << "[ALSA] Attempt to unsubscribe ports that are not subscribed." << endl;
+ _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) {
- Raul::error << "[ALSA] Unsubscription failed: " << snd_strerror(ret) << endl;
+ _app->error_msg(string("Alsa: Unable to disconnect ")
+ + src_port->full_name() + " => " + dst_port->full_name()
+ + "(" + snd_strerror(ret) + ")");
return false;
}
- _app->status_msg(string("[ALSA] Disconnected ")
- + src_port->full_name() + " -> " + dst_port->full_name());
+ _app->info_msg(string("Alsa: Disconnected ")
+ + src_port->full_name() + " => " + dst_port->full_name());
return true;
}
@@ -474,22 +479,23 @@ 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) {
- Raul::error << "[ALSA] Error creating port: " << snd_strerror(ret) << endl;
+ _app->error_msg((format("Alsa: Error creating port (%1%): ")
+ % snd_strerror(ret)).str());
return false;
}
// Subscribe the port to the system announcer
ret = snd_seq_connect_from(_seq,
- snd_seq_port_info_get_port(port_info),
- SND_SEQ_CLIENT_SYSTEM,
- SND_SEQ_PORT_SYSTEM_ANNOUNCE);
+ snd_seq_port_info_get_port(port_info),
+ SND_SEQ_CLIENT_SYSTEM,
+ SND_SEQ_PORT_SYSTEM_ANNOUNCE);
if (ret) {
- Raul::error << "[ALSA] Could not connect to system announcer port: "
- << snd_strerror(ret) << endl;
+ _app->error_msg((format("Alsa: Failed to connect to system announce port (%1%)")
+ % snd_strerror(ret)).str());
return false;
}
@@ -508,7 +514,7 @@ void
AlsaDriver::_refresh_main()
{
if (!create_refresh_port()) {
- Raul::error << "[ALSA] Could not create listen port, auto-refresh will not work." << endl;
+ _app->error_msg("Alsa: Could not create listen port, auto-refresh disabled.");
return;
}
diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp
index e00bcef..672957e 100644
--- a/src/JackDbusDriver.cpp
+++ b/src/JackDbusDriver.cpp
@@ -54,9 +54,6 @@
#define JACKDBUS_PORT_TYPE_AUDIO 0
#define JACKDBUS_PORT_TYPE_MIDI 1
-//#define LOG_TO_STD
-#define LOG_TO_STATUS
-
//#define USE_FULL_REFRESH
JackDriver::JackDriver(Patchage* app)
@@ -65,7 +62,6 @@ JackDriver::JackDriver(Patchage* app)
, _server_responding(false)
, _server_started(false)
, _graph_version(0)
- , _max_dsp_load(0.0)
{
dbus_error_init(&_dbus_error);
}
@@ -1010,44 +1006,6 @@ JackDriver::reset_xruns()
dbus_message_unref(reply_ptr);
}
-float
-JackDriver::get_max_dsp_load()
-{
- DBusMessage* reply_ptr;
- double load;
-
- if (_server_responding && !_server_started) {
- return 0.0;
- }
-
- 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)) {
- dbus_message_unref(reply_ptr);
- dbus_error_free(&_dbus_error);
- error_msg("decoding reply of GetLoad failed.");
- return 0.0;
- }
-
- dbus_message_unref(reply_ptr);
-
- load /= 100.0; // dbus returns it in percents, we use 0..1
-
- if (load > _max_dsp_load) {
- _max_dsp_load = load;
- }
-
- return _max_dsp_load;
-}
-
-void
-JackDriver::reset_max_dsp_load()
-{
- _max_dsp_load = 0.0;
-}
-
PatchagePort*
JackDriver::create_port_view(
Patchage* patchage,
@@ -1059,24 +1017,12 @@ JackDriver::create_port_view(
void
JackDriver::error_msg(const std::string& msg) const
{
-#if defined(LOG_TO_STATUS)
- _app->status_msg((std::string)"[JACKDBUS] " + msg);
-#endif
-
-#if defined(LOG_TO_STD)
- cerr << (std::string)"[JACKDBUS] " << msg << endl;
-#endif
+ _app->error_msg((std::string)"Jack: " + msg);
}
void
JackDriver::info_msg(const std::string& msg) const
{
-#if defined(LOG_TO_STATUS)
- _app->status_msg((std::string)"[JACKDBUS] " + msg);
-#endif
-
-#if defined(LOG_TO_STD)
- cerr << (std::string)"[JACKDBUS] " << msg << endl;
-#endif
+ _app->info_msg((std::string)"Jack: " + msg);
}
diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp
index 12e43b2..fa6d61c 100644
--- a/src/JackDbusDriver.hpp
+++ b/src/JackDbusDriver.hpp
@@ -57,9 +57,6 @@ public:
size_t get_xruns();
void reset_xruns();
- float get_max_dsp_load();
- void reset_max_dsp_load();
-
float sample_rate();
jack_nframes_t buffer_size();
bool set_buffer_size(jack_nframes_t size);
@@ -156,8 +153,6 @@ private:
bool _server_started;
dbus_uint64_t _graph_version;
-
- float _max_dsp_load;
};
#endif // PATCHAGE_JACKDBUSDRIVER_HPP
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index bde9dd9..c706ed6 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -19,6 +19,8 @@
#include <set>
#include <string>
+#include <boost/format.hpp>
+
#include <jack/jack.h>
#include <jack/statistics.h>
#include <jack/thread.h>
@@ -35,6 +37,7 @@
using std::endl;
using std::string;
+using boost::format;
JackDriver::JackDriver(Patchage* app)
: _app(app)
@@ -67,7 +70,7 @@ JackDriver::attach(bool launch_daemon)
jack_options_t options = (!launch_daemon) ? JackNoStartServer : JackNullOption;
_client = jack_client_open("Patchage", options, NULL);
if (_client == NULL) {
- _app->status_msg("[JACK] Unable to create client");
+ _app->error_msg("Jack: Unable to create client.");
_is_activated = false;
} else {
jack_client_t* const client = _client;
@@ -77,7 +80,6 @@ JackDriver::attach(bool launch_daemon)
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_buffer_size_callback(client, jack_buffer_size_cb, this);
jack_set_xrun_callback(client, jack_xrun_cb, this);
_buffer_size = jack_get_buffer_size(client);
@@ -85,9 +87,18 @@ JackDriver::attach(bool launch_daemon)
if (!jack_activate(client)) {
_is_activated = true;
signal_attached.emit();
- _app->status_msg("[JACK] Attached");
+ std::stringstream ss;
+ _app->info_msg("Jack: Attached.");
+ const jack_nframes_t buffer_size = this->buffer_size();
+ const jack_nframes_t sample_rate = this->sample_rate();
+ if (sample_rate != 0) {
+ const int latency_ms = lrintf((buffer_size * 1000 / (float)sample_rate));
+ ss << "Jack: Latency: " << buffer_size << " frames @ "
+ << (sample_rate / 1000) << "kHz (" << latency_ms << "ms).";
+ _app->info_msg(ss.str());
+ }
} else {
- _app->status_msg("[JACK] ERROR: Failed to attach");
+ _app->error_msg("Jack: Client activation failed.");
_is_activated = false;
}
}
@@ -104,7 +115,7 @@ JackDriver::detach()
}
_is_activated = false;
signal_detached.emit();
- _app->status_msg("[JACK] Detached");
+ _app->info_msg("Jack: Detached.");
}
static bool
@@ -129,7 +140,8 @@ JackDriver::create_port_view(Patchage* patchage,
jack_port_t* jack_port = jack_port_by_id(_client, id.id.jack_id);
if (!jack_port) {
- Raul::error << "[JACK] Failed to find port with ID " << id << endl;
+ _app->error_msg((format("Jack: Failed to find port with ID `%1%'.")
+ % id).str());;
return NULL;
}
@@ -175,7 +187,8 @@ JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id)
} else if (!strcmp(type_str, JACK_DEFAULT_MIDI_TYPE)) {
port_type = JACK_MIDI;
} else {
- Raul::warn << jack_port_name(port) << " has unknown type \'" << type_str << "\'" << endl;
+ _app->warning_msg((format("Jack: Port `%1%' has unknown type `%2'.")
+ % jack_port_name(port) % type_str).str());
return NULL;
}
@@ -352,11 +365,11 @@ JackDriver::connect(PatchagePort* src_port,
int result = jack_connect(_client, src_port->full_name().c_str(), dst_port->full_name().c_str());
if (result == 0)
- _app->status_msg(string("[JACK] Connected ")
- + src_port->full_name() + " -> " + dst_port->full_name());
+ _app->info_msg(string("Jack: Connected ")
+ + src_port->full_name() + " => " + dst_port->full_name());
else
- _app->status_msg(string("[JACK] Unable to connect ")
- + src_port->full_name() + " -> " + dst_port->full_name());
+ _app->error_msg(string("Jack: Unable to connect ")
+ + src_port->full_name() + " => " + dst_port->full_name());
return (!result);
}
@@ -375,11 +388,11 @@ JackDriver::disconnect(PatchagePort* const src_port,
int result = jack_disconnect(_client, src_port->full_name().c_str(), dst_port->full_name().c_str());
if (result == 0)
- _app->status_msg(string("[JACK] Disconnected ")
- + src_port->full_name() + " -> " + dst_port->full_name());
+ _app->info_msg(string("Jack: Disconnected ")
+ + src_port->full_name() + " => " + dst_port->full_name());
else
- _app->status_msg(string("[JACK] Unable to disconnect ")
- + src_port->full_name() + " -> " + dst_port->full_name());
+ _app->error_msg(string("Jack: Unable to disconnect ")
+ + src_port->full_name() + " => " + dst_port->full_name());
return (!result);
}
@@ -424,26 +437,6 @@ JackDriver::jack_port_connect_cb(jack_port_id_t src, jack_port_id_t dst, int con
}
int
-JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver)
-{
- JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
- assert(me->_client);
-
- jack_reset_max_delayed_usecs(me->_client);
-
- if (buffer_size == 0) {
- Raul::error << "Jack is insane and reporting a buffer size of 0" << endl;
- return 0;
- }
-
- me->_buffer_size = buffer_size;
- me->reset_xruns();
- me->reset_max_dsp_load();
-
- return 0;
-}
-
-int
JackDriver::jack_xrun_cb(void* jack_driver)
{
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
@@ -451,6 +444,10 @@ JackDriver::jack_xrun_cb(void* jack_driver)
++me->_xruns;
me->_xrun_delay = jack_get_xrun_delayed_usecs(me->_client);
+
+ me->_app->warning_msg((format("Jack: xrun of %1%ms.")
+ % me->_xrun_delay).str());
+
jack_reset_max_delayed_usecs(me->_client);
return 0;
@@ -459,9 +456,9 @@ JackDriver::jack_xrun_cb(void* jack_driver)
void
JackDriver::jack_shutdown_cb(void* jack_driver)
{
- Raul::info << "[JACK] Shutdown" << endl;
assert(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->_is_activated = false;
@@ -471,7 +468,7 @@ JackDriver::jack_shutdown_cb(void* jack_driver)
void
JackDriver::error_cb(const char* msg)
{
- Raul::error << "[JACK] " << msg << endl;
+ Raul::error << "jack error: " << msg << endl;
}
jack_nframes_t
@@ -503,31 +500,13 @@ JackDriver::set_buffer_size(jack_nframes_t size)
}
if (jack_set_buffer_size(_client, size)) {
- _app->status_msg("[JACK] ERROR: Unable to set buffer size");
+ _app->error_msg("[JACK] Unable to set buffer size");
return false;
} else {
return true;
}
}
-float
-JackDriver::get_max_dsp_load()
-{
- const float max_delay = jack_get_max_delayed_usecs(_client);
- const float rate = sample_rate();
- const float size = buffer_size();
- const float period = size / rate * 1000000.0f; // usec
-
- return (max_delay > period) ? 1.0 : (max_delay / period);
-}
-
-void
-JackDriver::reset_max_dsp_load()
-{
- if (_client)
- jack_reset_max_delayed_usecs(_client);
-}
-
void
JackDriver::process_events(Patchage* app)
{
diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp
index 8162f9e..aa4d3e4 100644
--- a/src/JackDriver.hpp
+++ b/src/JackDriver.hpp
@@ -67,9 +67,6 @@ public:
uint32_t get_xruns() { return _xruns; }
void reset_xruns();
- float get_max_dsp_load();
- void reset_max_dsp_load();
-
jack_client_t* client() { return _client; }
jack_nframes_t sample_rate() { return jack_get_sample_rate(_client); }
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index bb9c98c..706b1d2 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -56,8 +56,6 @@
#include "AlsaDriver.hpp"
#endif
-#define LOG_TO_STATUS 1
-
using std::cout;
using std::endl;
using std::string;
@@ -78,7 +76,6 @@ Patchage::Patchage(int argc, char** argv)
, INIT_WIDGET(_about_win)
, INIT_WIDGET(_main_scrolledwin)
, INIT_WIDGET(_main_win)
- , INIT_WIDGET(_main_xrun_progress)
, INIT_WIDGET(_menu_alsa_connect)
, INIT_WIDGET(_menu_alsa_disconnect)
, INIT_WIDGET(_menu_file_quit)
@@ -92,18 +89,13 @@ Patchage::Patchage(int argc, char** argv)
, INIT_WIDGET(_menu_view_arrange)
, INIT_WIDGET(_menu_view_messages)
, INIT_WIDGET(_menu_view_refresh)
- , INIT_WIDGET(_menu_view_statusbar)
, INIT_WIDGET(_menu_zoom_in)
, INIT_WIDGET(_menu_zoom_out)
, INIT_WIDGET(_menu_zoom_normal)
, INIT_WIDGET(_messages_clear_but)
, INIT_WIDGET(_messages_close_but)
, INIT_WIDGET(_messages_win)
- , INIT_WIDGET(_latency_frames_label)
- , INIT_WIDGET(_latency_ms_label)
- , INIT_WIDGET(_sample_rate_label)
, INIT_WIDGET(_status_text)
- , INIT_WIDGET(_statusbar)
, _attach(true)
, _driver_detached(false)
, _refresh(false)
@@ -183,8 +175,6 @@ Patchage::Patchage(int argc, char** argv)
sigc::mem_fun(this, &Patchage::refresh));
_menu_view_arrange->signal_activate().connect(
sigc::mem_fun(this, &Patchage::on_arrange));
- _menu_view_statusbar->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::on_view_statusbar));
_menu_view_messages->signal_toggled().connect(
sigc::mem_fun(this, &Patchage::on_show_messages));
_menu_help_about->signal_activate().connect(
@@ -203,6 +193,14 @@ Patchage::Patchage(int argc, char** argv)
_messages_win->signal_delete_event().connect(
sigc::mem_fun(this, &Patchage::on_messages_delete));
+ _error_tag = Gtk::TextTag::create();
+ _error_tag->property_foreground() = "#FF0000";
+ _status_text->get_buffer()->get_tag_table()->add(_error_tag);
+
+ _warning_tag = Gtk::TextTag::create();
+ _warning_tag->property_foreground() = "#FFFF00";
+ _status_text->get_buffer()->get_tag_table()->add(_warning_tag);
+
_canvas->show();
_main_win->present();
@@ -277,8 +275,6 @@ Patchage::attach()
_enable_refresh = true;
refresh();
-
- update_statusbar();
}
bool
@@ -322,66 +318,6 @@ Patchage::idle_callback()
_refresh = false;
_driver_detached = false;
- // Update load every 10 idle callbacks
- static int count = 0;
- if (++count == 10) {
- update_load();
- count = 0;
- }
-
- return true;
-}
-
-void
-Patchage::update_statusbar()
-{
-#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
- if (_enable_refresh && _jack_driver->is_attached()) {
- _enable_refresh = false;
-
- const jack_nframes_t buffer_size = _jack_driver->buffer_size();
- const jack_nframes_t sample_rate = _jack_driver->sample_rate();
-
- std::stringstream ss;
- ss << buffer_size;
- _latency_frames_label->set_text(ss.str());
-
- ss.str("");
- ss << (sample_rate / 1000);
- _sample_rate_label->set_text(ss.str());
-
- ss.str("");
- if (sample_rate != 0)
- ss << buffer_size * 1000 / sample_rate;
- _latency_ms_label->set_text(ss.str());
-
- _enable_refresh = true;
- }
-#endif
-}
-
-bool
-Patchage::update_load()
-{
-#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
- if (!_jack_driver->is_attached())
- return true;
-
- char tmp_buf[8];
- snprintf(tmp_buf, sizeof(tmp_buf), "%u", _jack_driver->get_xruns());
-
- _main_xrun_progress->set_text(string(tmp_buf) + " Dropouts");
-
- static float last_max_dsp_load = 0;
-
- const float max_dsp_load = _jack_driver->get_max_dsp_load();
-
- if (max_dsp_load != last_max_dsp_load) {
- _main_xrun_progress->set_fraction(max_dsp_load);
- last_max_dsp_load = max_dsp_load;
- }
-#endif
-
return true;
}
@@ -434,33 +370,25 @@ Patchage::store_window_location()
void
Patchage::error_msg(const std::string& msg)
{
-#if defined(LOG_TO_STATUS)
- status_msg(msg);
-#endif
-#if defined(LOG_TO_STD)
- cerr << msg << endl;
-#endif
+ Glib::RefPtr<Gtk::TextBuffer> buffer = _status_text->get_buffer();
+ buffer->insert_with_tag(buffer->end(), msg + "\n", _error_tag);
+ _status_text->scroll_to_mark(buffer->get_insert(), 0);
}
void
Patchage::info_msg(const std::string& msg)
{
-#if defined(LOG_TO_STATUS)
- status_msg(msg);
-#endif
-#if defined(LOG_TO_STD)
- cerr << msg << endl;
-#endif
+ Glib::RefPtr<Gtk::TextBuffer> buffer = _status_text->get_buffer();
+ buffer->insert(buffer->end(), msg + "\n");
+ _status_text->scroll_to_mark(buffer->get_insert(), 0);
}
void
-Patchage::status_msg(const string& msg)
+Patchage::warning_msg(const std::string& msg)
{
- if (_status_text->get_buffer()->size() > 0)
- _status_text->get_buffer()->insert(_status_text->get_buffer()->end(), "\n");
-
- _status_text->get_buffer()->insert(_status_text->get_buffer()->end(), msg);
- _status_text->scroll_to_mark(_status_text->get_buffer()->get_insert(), 0);
+ Glib::RefPtr<Gtk::TextBuffer> buffer = _status_text->get_buffer();
+ buffer->insert_with_tag(buffer->end(), msg + "\n", _warning_tag);
+ _status_text->scroll_to_mark(buffer->get_insert(), 0);
}
void
@@ -482,8 +410,6 @@ void
Patchage::connect_widgets()
{
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
- _jack_driver->signal_attached.connect(
- sigc::mem_fun(this, &Patchage::update_statusbar));
_jack_driver->signal_attached.connect(sigc::bind(
sigc::mem_fun(*_menu_jack_connect, &Gtk::MenuItem::set_sensitive), false));
_jack_driver->signal_attached.connect(
@@ -714,15 +640,6 @@ Patchage::on_store_positions()
_state_manager->save(_settings_filename);
}
-void
-Patchage::on_view_statusbar()
-{
- if (_menu_view_statusbar->get_active())
- _statusbar->show();
- else
- _statusbar->hide();
-}
-
bool
Patchage::on_scroll(GdkEventScroll* ev)
{
diff --git a/src/Patchage.hpp b/src/Patchage.hpp
index 2597178..8ff3ff5 100644
--- a/src/Patchage.hpp
+++ b/src/Patchage.hpp
@@ -33,7 +33,6 @@
#include <gtkmm/menuitem.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/statusbar.h>
#include <gtkmm/textview.h>
#include <gtkmm/viewport.h>
#include <gtkmm/window.h>
@@ -77,10 +76,10 @@ public:
inline void queue_refresh() { _refresh = true; }
inline void driver_detached() { _driver_detached = true; }
- void clear_load();
void info_msg(const std::string& msg);
void error_msg(const std::string& msg);
- void status_msg(const std::string& msg);
+ void warning_msg(const std::string& msg);
+
void update_state();
void store_window_location();
@@ -95,7 +94,6 @@ protected:
void on_quit();
void on_show_messages();
void on_store_positions();
- void on_view_statusbar();
void on_zoom_in();
void on_zoom_out();
void on_zoom_normal();
@@ -105,7 +103,6 @@ protected:
void zoom(double z);
bool idle_callback();
bool update_load();
- void update_statusbar();
void buffer_size_changed();
@@ -133,7 +130,6 @@ protected:
Widget<Gtk::AboutDialog> _about_win;
Widget<Gtk::ScrolledWindow> _main_scrolledwin;
Widget<Gtk::Window> _main_win;
- Widget<Gtk::ProgressBar> _main_xrun_progress;
Widget<Gtk::MenuItem> _menu_alsa_connect;
Widget<Gtk::MenuItem> _menu_alsa_disconnect;
Widget<Gtk::MenuItem> _menu_file_quit;
@@ -147,28 +143,25 @@ protected:
Widget<Gtk::MenuItem> _menu_view_arrange;
Widget<Gtk::CheckMenuItem> _menu_view_messages;
Widget<Gtk::MenuItem> _menu_view_refresh;
- Widget<Gtk::CheckMenuItem> _menu_view_statusbar;
Widget<Gtk::ImageMenuItem> _menu_zoom_in;
Widget<Gtk::ImageMenuItem> _menu_zoom_out;
Widget<Gtk::ImageMenuItem> _menu_zoom_normal;
Widget<Gtk::Button> _messages_clear_but;
Widget<Gtk::Button> _messages_close_but;
Widget<Gtk::Dialog> _messages_win;
- Widget<Gtk::Label> _latency_frames_label;
- Widget<Gtk::Label> _latency_ms_label;
- Widget<Gtk::Label> _sample_rate_label;
Widget<Gtk::TextView> _status_text;
- Widget<Gtk::Statusbar> _statusbar;
- bool _attach;
- bool _driver_detached;
- bool _refresh;
- bool _enable_refresh;
- bool _jack_driver_autoattach;
+ Glib::RefPtr<Gtk::TextTag> _error_tag;
+ Glib::RefPtr<Gtk::TextTag> _warning_tag;
+
+ bool _attach;
+ bool _driver_detached;
+ bool _refresh;
+ bool _enable_refresh;
+ bool _jack_driver_autoattach;
#ifdef HAVE_ALSA
- bool _alsa_driver_autoattach;
+ bool _alsa_driver_autoattach;
#endif
-
};
#endif // PATCHAGE_PATCHAGE_HPP
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp
index 175d837..148466e 100644
--- a/src/PatchageCanvas.cpp
+++ b/src/PatchageCanvas.cpp
@@ -194,7 +194,7 @@ PatchageCanvas::connect(FlowCanvas::Connectable* port1,
_app->alsa_driver()->connect(p1, p2);
#endif
} else {
- status_message("WARNING: Cannot make connection, incompatible port types.");
+ _app->warning_msg("Cannot make connection, incompatible port types.");
}
}
@@ -215,7 +215,7 @@ PatchageCanvas::disconnect(FlowCanvas::Connectable* port1,
}
if (!input || !output || input->is_output() || output->is_input()) {
- status_message("ERROR: Attempt to disconnect mismatched/unknown ports");
+ _app->error_msg("Attempt to disconnect mismatched/unknown ports.");
return;
}
@@ -229,17 +229,11 @@ PatchageCanvas::disconnect(FlowCanvas::Connectable* port1,
_app->alsa_driver()->disconnect(output, input);
#endif
} else {
- status_message("ERROR: Attempt to disconnect ports with mismatched types");
+ _app->error_msg("Attempt to disconnect ports with mismatched types.");
}
}
void
-PatchageCanvas::status_message(const string& msg)
-{
- _app->status_msg(string("[Canvas] ").append(msg));
-}
-
-void
PatchageCanvas::add_module(const std::string& name, PatchageModule* module)
{
_module_index.insert(std::make_pair(name, module));
diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp
index 5262a5e..4889e9c 100644
--- a/src/PatchageCanvas.hpp
+++ b/src/PatchageCanvas.hpp
@@ -55,8 +55,6 @@ public:
void disconnect(FlowCanvas::Connectable* port1,
FlowCanvas::Connectable* port2);
- void status_message(const std::string& msg);
-
void index_port(const PortID& id, PatchagePort* port) {
_port_index.insert(std::make_pair(id, port));
}
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index 65cef28..818859c 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -14,7 +14,8 @@
* along with Patchage. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "raul/log.hpp"
+#include <boost/format.hpp>
+
#include "raul/SharedPtr.hpp"
#include "patchage-config.h"
@@ -33,6 +34,7 @@
#endif
using std::endl;
+using boost::format;
void
PatchageEvent::execute(Patchage* patchage)
@@ -65,10 +67,14 @@ PatchageEvent::execute(Patchage* patchage)
if (driver) {
PatchagePort* port = driver->create_port_view(patchage, _port_1);
- if (!port)
- Raul::error << "Unable to create port view: " << _port_1 << endl;
+ if (!port) {
+ patchage->error_msg(
+ (format("Unable to create view for port `%1%'")
+ % _port_1).str());
+ }
} else {
- Raul::error << "Attempt to create port with unknown type: " << _port_1 << endl;
+ patchage->error_msg(
+ (format("Unknown type for port `%1%'") % _port_1).str());
}
} else if (_type == PORT_DESTRUCTION) {
@@ -81,11 +87,14 @@ PatchageEvent::execute(Patchage* patchage)
PatchagePort* port_2 = patchage->canvas()->find_port(_port_2);
if (!port_1)
- Raul::error << "Unable to find port `" << _port_1 << "' to connect" << endl;
+ patchage->error_msg((format("Unable to find port `%1%' to connect")
+ % _port_1).str());
else if (!port_2)
- Raul::error << "Unable to find port `" << _port_2 << "' to connect" << endl;
+ patchage->error_msg((format("Unable to find port `%1' to connect")
+ % _port_2).str());
else
- patchage->canvas()->add_connection(port_1, port_2, port_1->color() + 0x22222200);
+ patchage->canvas()->add_connection(
+ port_1, port_2, port_1->color() + 0x22222200);
} else if (_type == DISCONNECTION) {
@@ -93,9 +102,11 @@ PatchageEvent::execute(Patchage* patchage)
PatchagePort* port_2 = patchage->canvas()->find_port(_port_2);
if (!port_1)
- Raul::error << "Unable to find port `" << _port_1 << "' to disconnect" << endl;
+ patchage->error_msg((format("Unable to find port `%1' to disconnect")
+ % _port_1).str());
else if (!port_2)
- Raul::error << "Unable to find port `" << _port_2 << "' to disconnect" << endl;
+ patchage->error_msg((format("Unable to find port `%1' to disconnect")
+ % _port_2).str());
else
patchage->canvas()->remove_connection(port_1, port_2);
}
diff --git a/src/patchage.ui b/src/patchage.ui
index 0df10fc..68aed08 100644
--- a/src/patchage.ui
+++ b/src/patchage.ui
@@ -885,18 +885,6 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
</object>
</child>
<child>
- <object class="GtkCheckMenuItem" id="menu_view_statusbar">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">_Statusbar</property>
- <property name="use_underline">True</property>
- <property name="active">True</property>
- <accelerator key="b" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="on_menu_view_toolbar_activate" swapped="no"/>
- </object>
- </child>
- <child>
<object class="GtkSeparatorMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -910,8 +898,8 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
- <accelerator key="plus" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="equal" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ <accelerator key="plus" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
<child>
@@ -1020,142 +1008,6 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkStatusbar" id="statusbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="label10">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Latency: </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="latency_frames_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">1024</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="frames_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes"> frames @ </property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="sample_rate_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">48</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">1</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes"> kHz (</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="latency_ms_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">21</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label11">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes"> ms)</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">6</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkProgressBar" id="main_xrun_progress">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="pulse_step">0.10000000149</property>
- <property name="text" translatable="yes">0 Dropouts</property>
- <property name="show_text">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="padding">2</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">1</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
</child>
</object>
@@ -1168,7 +1020,9 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Patchage - Messages</property>
<property name="window_position">center-on-parent</property>
+ <property name="icon_name">patchage</property>
<property name="type_hint">dialog</property>
+ <property name="transient_for">main_win</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3">
<property name="visible">True</property>
@@ -1187,7 +1041,7 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="receives_default">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
@@ -1204,9 +1058,10 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
- <property name="receives_default">False</property>
+ <property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
@@ -1236,7 +1091,7 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
<property name="width_request">640</property>
<property name="height_request">480</property>
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="can_focus">False</property>
<property name="editable">False</property>
<property name="wrap_mode">word</property>
<property name="cursor_visible">False</property>
@@ -1245,7 +1100,7 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>