5 #ifndef PLATFORM_WINDOWS
11 #include "pbd/convert.h"
12 #include "pbd/crossthread.h"
13 #include "pbd/failed_constructor.h"
14 #include "pbd/error.h"
15 #include "pbd/debug.h"
17 #include "ardour/ardour.h"
18 #include "ardour/audioengine.h"
19 #include "ardour/revision.h"
20 #include "ardour/session.h"
22 #include "control_protocol/control_protocol.h"
27 using namespace ARDOUR;
30 static const char* localedir = LOCALEDIR;
32 static string backend_client_name;
33 static string backend_name = "JACK";
34 static CrossThreadChannel xthread (true);
35 static TestReceiver test_receiver;
37 /** @param dir Session directory.
38 * @param state Session state file, without .ardour suffix.
41 load_session (string dir, string state)
43 SessionEvent::create_per_thread_pool ("test", 512);
45 test_receiver.listen_to (error);
46 test_receiver.listen_to (info);
47 test_receiver.listen_to (fatal);
48 test_receiver.listen_to (warning);
50 AudioEngine* engine = AudioEngine::create ();
52 if (!engine->set_backend (backend_name, backend_client_name, "")) {
53 std::cerr << "Cannot set Audio/MIDI engine backend\n";
57 if (engine->start () != 0) {
58 std::cerr << "Cannot start Audio/MIDI engine\n";
62 Session* session = new Session (*engine, dir, state);
63 engine->set_session (session);
68 access_action (const std::string& action_group, const std::string& action_item)
70 if (action_group == "Common" && action_item == "Quit") {
71 xthread.deliver ('x');
76 engine_halted (const char* reason)
78 cerr << "The audio backend has been shutdown";
79 if (reason && strlen (reason) > 0) {
80 cerr << ": " << reason;
85 xthread.deliver ('x');
88 #ifndef PLATFORM_WINDOWS
89 static void wearedone (int) {
90 cerr << "caught signal - terminating." << endl;
91 xthread.deliver ('x');
104 << " and GCC version " << __VERSION__
113 cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
114 << " DIR Directory/Folder to load session from\n"
115 << " SNAPSHOT_NAME Name of session/snapshot to load (without .ardour at end\n"
116 << " -v, --version Show version information\n"
117 << " -h, --help Print this message\n"
118 << " -c, --name <name> Use a specific backend client name, default is ardour\n"
119 << " -d, --disable-plugins Disable all plugins in an existing session\n"
120 << " -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n"
121 << " -O, --no-hw-optimizations Disable h/w specific optimizations\n"
122 << " -P, --no-connect-ports Do not connect any ports at startup\n"
123 #ifdef WINDOWS_VST_SUPPORT
124 << " -V, --novst Do not use VST support\n"
129 int main (int argc, char* argv[])
131 const char *optstring = "vhBdD:c:VOU:P";
133 const struct option longopts[] = {
134 { "version", 0, 0, 'v' },
135 { "help", 0, 0, 'h' },
136 { "bypass-plugins", 1, 0, 'B' },
137 { "disable-plugins", 1, 0, 'd' },
138 { "debug", 1, 0, 'D' },
139 { "name", 1, 0, 'c' },
140 { "novst", 0, 0, 'V' },
141 { "no-hw-optimizations", 0, 0, 'O' },
142 { "uuid", 1, 0, 'U' },
143 { "no-connect-ports", 0, 0, 'P' },
147 int option_index = 0;
151 bool try_hw_optimization = true;
153 backend_client_name = PBD::downcase (std::string(PROGRAM_NAME));
156 c = getopt_long (argc, argv, optstring, longopts, &option_index);
177 backend_client_name = optarg;
181 ARDOUR::Session::set_bypass_all_loaded_plugins (true);
185 ARDOUR::Session::set_disable_all_loaded_plugins (true);
189 if (PBD::parse_debug_options (optarg)) {
195 try_hw_optimization = false;
199 ARDOUR::Port::set_connecting_blocked (true);
203 #ifdef WINDOWS_VST_SUPPORT
205 #endif /* WINDOWS_VST_SUPPORT */
219 if (!ARDOUR::init (use_vst, try_hw_optimization, localedir)) {
220 cerr << "Ardour failed to initialize\n" << endl;
227 s = load_session (argv[optind], argv[optind+1]);
228 } catch (failed_constructor& e) {
229 cerr << "failed_constructor: " << e.what() << "\n";
231 } catch (AudioEngine::PortRegistrationFailure& e) {
232 cerr << "PortRegistrationFailure: " << e.what() << "\n";
234 } catch (exception& e) {
235 cerr << "exception: " << e.what() << "\n";
238 cerr << "unknown exception.\n";
242 PBD::ScopedConnectionList con;
243 BasicUI::AccessAction.connect_same_thread (con, boost::bind (&access_action, _1, _2));
244 AudioEngine::instance()->Halted.connect_same_thread (con, boost::bind (&engine_halted, _1));
246 #ifndef PLATFORM_WINDOWS
247 signal(SIGINT, wearedone);
248 signal(SIGTERM, wearedone);
251 s->request_transport_speed (1.0);
254 do {} while (0 == xthread.receive (msg, true));
256 AudioEngine::instance()->remove_session ();
258 AudioEngine::instance()->stop ();
260 AudioEngine::destroy ();