merge 5674:5682 and 5689-5694 from mixbus branch
[ardour.git] / gtk2_ardour / main.cc
index 5d79cf038df9d15a2cff7ca8dec31c0ebb7d6c8f..e0df2eadcfa7b59e168e2f4599758c5489f656a4 100644 (file)
@@ -241,10 +241,48 @@ fixup_bundle_environment ()
 
 #endif
 
+static gboolean
+tell_about_jack_death (void* /* ignored */)
+{
+  if (AudioEngine::instance()->processed_frames() == 0) {
+    /* died during startup */
+    MessageDialog msg (_("JACK exited"), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK);
+    msg.set_position (Gtk::WIN_POS_CENTER);
+    msg.set_secondary_text (_(
+                             "JACK exited unexpectedly, and without notifying Ardour.\n\
+\n\
+This could be due to misconfiguration or to an error inside JACK.\n\
+\n\
+Click OK to exit Ardour."));
+    
+    msg.run ();
+    _exit (0);
+
+  } else {
+
+    /* engine has already run, so this is a mid-session JACK death */
+
+    MessageDialog* msg = manage (new MessageDialog (_("JACK exited"), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_NONE));
+    msg->set_secondary_text (_(
+"JACK exited unexpectedly, and without notifying Ardour.\n\
+\n\
+This is probably due to an error inside JACK. You should restart JACK\n\
+and reconnect Ardour to it, or exit Ardour now. You cannot save your\n\
+session at this time, because we would lose your connection information.\n"));
+    msg->present ();
+  }
+}
+
 static void
 sigpipe_handler (int sig)
 {
-       cerr << _("SIGPIPE received - JACK has probably died") << endl;
+        static bool done_the_jack_thing = false;
+
+       if (!done_the_jack_thing) {
+         AudioEngine::instance()->died ();
+         g_idle_add (tell_about_jack_death, 0);
+         done_the_jack_thing =  true;
+       }
 }
 
 #ifdef VST_SUPPORT