5 #include "pbd/failed_constructor.h"
9 #include "ardour/ardour.h"
10 #include "ardour/audioengine.h"
11 #include "ardour/session.h"
16 using namespace ARDOUR;
19 #ifdef PLATFORM_WINDOWS
20 #define sleep(X) Sleep((X) * 1000)
23 static const char* localedir = LOCALEDIR;
25 TestReceiver test_receiver;
27 /** @param dir Session directory.
28 * @param state Session state file, without .ardour suffix.
31 load_session (string dir, string state)
33 SessionEvent::create_per_thread_pool ("test", 512);
35 test_receiver.listen_to (error);
36 test_receiver.listen_to (info);
37 test_receiver.listen_to (fatal);
38 test_receiver.listen_to (warning);
40 AudioEngine* engine = AudioEngine::create ();
42 if (!engine->set_default_backend ()) {
43 std::cerr << "Cannot create Audio/MIDI engine\n";
49 if (engine->start () != 0) {
50 std::cerr << "Cannot start Audio/MIDI engine\n";
54 Session* session = new Session (*engine, dir, state);
55 engine->set_session (session);
59 string session_name = "";
60 string backend_client_name = "ardour";
61 string backend_session_uuid;
62 bool just_version = false;
64 bool try_hw_optimization = true;
65 bool no_connect_ports = false;
70 cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
71 << " DIR Directory/Folder to load session from\n"
72 << " SNAPSHOT_NAME Name of session/snapshot to load (without .ardour at end\n"
73 << " -v, --version Show version information\n"
74 << " -h, --help Print this message\n"
75 << " -c, --name <name> Use a specific backend client name, default is ardour\n"
76 << " -d, --disable-plugins Disable all plugins in an existing session\n"
77 << " -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n"
78 << " -O, --no-hw-optimizations Disable h/w specific optimizations\n"
79 << " -P, --no-connect-ports Do not connect any ports at startup\n"
80 #ifdef WINDOWS_VST_SUPPORT
81 << " -V, --novst Do not use VST support\n"
86 int main (int argc, char* argv[])
88 const char *optstring = "vhdD:c:VOU:P";
90 const struct option longopts[] = {
91 { "version", 0, 0, 'v' },
92 { "help", 0, 0, 'h' },
93 { "disable-plugins", 1, 0, 'd' },
94 { "debug", 1, 0, 'D' },
95 { "name", 1, 0, 'c' },
96 { "novst", 0, 0, 'V' },
97 { "no-hw-optimizations", 0, 0, 'O' },
98 { "uuid", 1, 0, 'U' },
99 { "no-connect-ports", 0, 0, 'P' },
103 int option_index = 0;
107 c = getopt_long (argc, argv, optstring, longopts, &option_index);
127 backend_client_name = optarg;
131 ARDOUR::Session::set_disable_all_loaded_plugins (true);
135 if (PBD::parse_debug_options (optarg)) {
141 try_hw_optimization = false;
145 no_connect_ports = true;
149 #ifdef WINDOWS_VST_SUPPORT
151 #endif /* WINDOWS_VST_SUPPORT */
155 backend_session_uuid = optarg;
169 if (!ARDOUR::init (false, true, localedir)) {
170 cerr << "Ardour failed to initialize\n" << endl;
177 s = load_session (argv[optind], argv[optind+1]);
178 } catch (failed_constructor& e) {
179 cerr << "failed_constructor: " << e.what() << "\n";
181 } catch (AudioEngine::PortRegistrationFailure& e) {
182 cerr << "PortRegistrationFailure: " << e.what() << "\n";
184 } catch (exception& e) {
185 cerr << "exception: " << e.what() << "\n";
188 cerr << "unknown exception.\n";
192 s->request_transport_speed (1.0);
196 AudioEngine::instance()->remove_session ();
198 AudioEngine::instance()->stop ();
200 AudioEngine::destroy ();