summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Patchage.cpp67
-rw-r--r--src/Patchage.hpp3
2 files changed, 31 insertions, 39 deletions
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index cc746b7..b5123b6 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -166,9 +166,6 @@ Patchage::Patchage(int argc, char** argv)
, _connector(_log)
, _pane_initialized(false)
, _attach(true)
- , _driver_detached(false)
- , _refresh(false)
- , _enable_refresh(true)
, _jack_driver_autoattach(true)
#ifdef HAVE_ALSA
, _alsa_driver_autoattach(true)
@@ -386,8 +383,6 @@ Patchage::~Patchage()
void
Patchage::attach()
{
- _enable_refresh = false;
-
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
if (_jack_driver_autoattach) {
_jack_driver->attach(true);
@@ -400,8 +395,6 @@ Patchage::attach()
}
#endif
- _enable_refresh = true;
-
process_events();
refresh();
update_toolbar();
@@ -420,32 +413,6 @@ Patchage::idle_callback()
// Process any events from drivers
process_events();
- // Do a full refresh
- if (_refresh) {
- refresh();
- } else if (_driver_detached) {
-#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
- if (_jack_driver && !_jack_driver->is_attached()) {
- _canvas->remove_ports([](const PatchagePort* port) {
- return (port->type() == PortType::jack_audio ||
- port->type() == PortType::jack_midi ||
- port->type() == PortType::jack_osc ||
- port->type() == PortType::jack_cv);
- });
- }
-#endif
-#ifdef HAVE_ALSA
- if (_alsa_driver && !_alsa_driver->is_attached()) {
- _canvas->remove_ports([](const PatchagePort* port) {
- return port->type() == PortType::alsa_midi;
- });
- }
-#endif
- }
-
- _refresh = false;
- _driver_detached = false;
-
// Update load every 5 idle callbacks
static int count = 0;
if (++count == 5) {
@@ -519,7 +486,7 @@ Patchage::refresh()
handle_event(*this, event);
};
- if (_canvas && _enable_refresh) {
+ if (_canvas) {
_canvas->clear();
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
@@ -541,12 +508,24 @@ Patchage::driver_attached(const ClientType type)
case ClientType::jack:
_menu_jack_connect->set_sensitive(false);
_menu_jack_disconnect->set_sensitive(true);
- refresh();
+
+ if (_jack_driver) {
+ _jack_driver->refresh([this](const PatchageEvent& event) {
+ handle_event(*this, event);
+ });
+ }
+
break;
case ClientType::alsa:
_menu_alsa_connect->set_sensitive(false);
_menu_alsa_disconnect->set_sensitive(true);
- refresh();
+
+ if (_alsa_driver) {
+ _alsa_driver->refresh([this](const PatchageEvent& event) {
+ handle_event(*this, event);
+ });
+ }
+
break;
}
}
@@ -558,10 +537,26 @@ Patchage::driver_detached(const ClientType type)
case ClientType::jack:
_menu_jack_connect->set_sensitive(true);
_menu_jack_disconnect->set_sensitive(false);
+
+ if (_jack_driver && !_jack_driver->is_attached()) {
+ _canvas->remove_ports([](const PatchagePort* port) {
+ return (port->type() == PortType::jack_audio ||
+ port->type() == PortType::jack_midi ||
+ port->type() == PortType::jack_osc ||
+ port->type() == PortType::jack_cv);
+ });
+ }
+
break;
+
case ClientType::alsa:
_menu_alsa_connect->set_sensitive(true);
_menu_alsa_disconnect->set_sensitive(false);
+
+ _canvas->remove_ports([](const PatchagePort* port) {
+ return port->type() == PortType::alsa_midi;
+ });
+
break;
}
}
diff --git a/src/Patchage.hpp b/src/Patchage.hpp
index b0c2630..f153bd3 100644
--- a/src/Patchage.hpp
+++ b/src/Patchage.hpp
@@ -211,9 +211,6 @@ protected:
bool _pane_initialized;
bool _attach;
- bool _driver_detached;
- bool _refresh;
- bool _enable_refresh;
bool _jack_driver_autoattach;
#ifdef HAVE_ALSA
bool _alsa_driver_autoattach;