From 14921f4a865f0eb06b45cd70e3ee71e42a8148e0 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Tue, 14 Dec 2010 20:19:36 +0000
Subject: Add -J (or --no-jack) option to avoid auto-connecting to JACK at
 startup (fix ticket #524). Better --help output, support -h as well.

git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2683 a436a847-0d15-0410-975c-d299462d15a1
---
 src/Patchage.cpp | 17 ++++++++++++++---
 src/Patchage.hpp |  1 +
 2 files changed, 15 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index 9b3a299..26d1127 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -100,6 +100,7 @@ Patchage::Patchage(int argc, char** argv)
 	, _alsa_driver_autoattach(true)
 #endif
 	, _jack_driver(NULL)
+	, _jack_driver_autoattach(true)
 	, _state_manager(NULL)
 	, _attach(true)
 	, _driver_detached(false)
@@ -140,12 +141,21 @@ Patchage::Patchage(int argc, char** argv)
 	_canvas = boost::shared_ptr<PatchageCanvas>(new PatchageCanvas(this, 1600*2, 1200*2));
 
 	while (argc > 0) {
-		if (!strcmp(*argv, "--help")) {
-			cout << "Usage: patchage [OPTIONS]\nOptions: --no-alsa" << endl;
+		if (!strcmp(*argv, "-h") || !strcmp(*argv, "--help")) {
+			cout << "Usage: patchage [OPTIONS]" << endl;
+			cout << "Visually connect JACK and ALSA Audio/MIDI ports." << endl << endl;
+			cout << "Options:" << endl;
+			cout << "\t-h  --help     Show this help" << endl;
+			cout << "\t-A  --no-alsa  Do not automatically attach to ALSA" << endl;
+			cout << "\t-J  --no-jack  Do not automatically attack to JACK" << endl;
 			exit(0);
 #ifdef HAVE_ALSA
 		} else if (!strcmp(*argv, "-A") || !strcmp(*argv, "--no-alsa")) {
 			_alsa_driver_autoattach = false;
+#endif
+#if defined(USE_LIBJACK) || defined(HAVE_JACK_DBUS)
+		} else if (!strcmp(*argv, "-J") || !strcmp(*argv, "--no-jack")) {
+			_jack_driver_autoattach = false;
 #endif
 		}
 
@@ -295,7 +305,8 @@ Patchage::attach()
 	_enable_refresh = false;
 
 #if defined(USE_LIBJACK) || defined(HAVE_JACK_DBUS)
-	_jack_driver->attach(true);
+	if (_jack_driver_autoattach)
+		_jack_driver->attach(true);
 #endif
 
 #ifdef HAVE_ALSA
diff --git a/src/Patchage.hpp b/src/Patchage.hpp
index 86d40f3..ee3eba5 100644
--- a/src/Patchage.hpp
+++ b/src/Patchage.hpp
@@ -127,6 +127,7 @@ protected:
 	std::set< boost::shared_ptr<FlowCanvas::Module> > _pending_resize;
 
 	JackDriver*   _jack_driver;
+	bool          _jack_driver_autoattach;
 	StateManager* _state_manager;
 
 	Gtk::Main* _gtk_main;
-- 
cgit v1.2.1