Add EngineControl::stop_engine method to show errors when stopping engine
authorTim Mayberry <mojofunk@gmail.com>
Sat, 3 Oct 2015 04:09:45 +0000 (14:09 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Tue, 6 Oct 2015 03:29:57 +0000 (13:29 +1000)
This replaces using ARDOUR_UI::disconnect_from_session which is only used by the
EngineControl class. ARDOUR_UI::disconnect_from_session also disconnects from
the AudioEngine::Halted signal which seems unnecessary as Halted is not emitted
when stopping the engine and calling update_sample_rate() which is already
handled when the AudioEngine::Stopped signal is emitted.

gtk2_ardour/engine_dialog.cc
gtk2_ardour/engine_dialog.h

index f76008cc438aa3e76eb877d4aec843a8991159b1..82b7645161aca86ec337657738a08049788c01d6 100644 (file)
@@ -419,6 +419,18 @@ EngineControl::start_engine ()
        return true;
 }
 
+bool
+EngineControl::stop_engine ()
+{
+       if (ARDOUR::AudioEngine::instance()->stop()) {
+               MessageDialog msg(*this,
+                                 ARDOUR::AudioEngine::instance()->get_last_backend_error());
+               msg.run();
+               return false;
+       }
+       return true;
+}
+
 void
 EngineControl::on_response (int response_id)
 {
@@ -2260,13 +2272,12 @@ EngineControl::push_state_to_backend (bool start)
 
        if (was_running) {
                if (restart_required) {
-                       if (ARDOUR_UI::instance()->disconnect_from_engine ()) {
+                       if (ARDOUR::AudioEngine::instance()->stop()) {
                                return -1;
                        }
                }
        }
 
-
        if (change_driver && backend->set_driver (get_driver())) {
                error << string_compose (_("Cannot set driver to %1"), get_driver()) << endmsg;
                return -1;
@@ -2578,7 +2589,7 @@ EngineControl::on_switch_page (GtkNotebookPage*, guint page_num)
 
                if (ARDOUR::AudioEngine::instance()->running()) {
                        // TODO - mark as 'stopped for latency
-                       ARDOUR_UI::instance()->disconnect_from_engine ();
+                       stop_engine ();
                }
 
                {
@@ -2885,9 +2896,9 @@ void
 EngineControl::connect_disconnect_click()
 {
        if (ARDOUR::AudioEngine::instance()->running()) {
-               ARDOUR_UI::instance()->disconnect_from_engine ();
+               stop_engine ();
        } else {
-               ARDOUR_UI::instance()->reconnect_to_engine ();
+               start_engine ();
        }
 }
 
index ea56b94852680ad7b3a6b60db235a244274ad458..7fc0106b36110a0526ff5a38d4f4d84d0d0c5fa9 100644 (file)
@@ -300,6 +300,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
     void post_push ();
     void update_sensitivity ();
        bool start_engine ();
+       bool stop_engine ();
 
     /* latency measurement */
     void latency_button_clicked ();