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
21 #define sleep(X) Sleep((X) * 1000)
24 static const char* localedir = LOCALEDIR;
26 TestReceiver test_receiver;
28 /** @param dir Session directory.
29 * @param state Session state file, without .ardour suffix.
32 load_session (string dir, string state)
34 SessionEvent::create_per_thread_pool ("test", 512);
36 test_receiver.listen_to (error);
37 test_receiver.listen_to (info);
38 test_receiver.listen_to (fatal);
39 test_receiver.listen_to (warning);
41 AudioEngine* engine = AudioEngine::create ();
43 if (!engine->set_default_backend ()) {
44 std::cerr << "Cannot create Audio/MIDI engine\n";
50 if (engine->start () != 0) {
51 std::cerr << "Cannot start Audio/MIDI engine\n";
55 Session* session = new Session (*engine, dir, state);
56 engine->set_session (session);
60 string session_name = "";
61 string backend_client_name = "ardour";
62 string backend_session_uuid;
63 bool just_version = false;
65 bool try_hw_optimization = true;
66 bool no_connect_ports = false;
71 cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
72 << " DIR Directory/Folder to load session from\n"
73 << " SNAPSHOT_NAME Name of session/snapshot to load (without .ardour at end\n"
74 << " -v, --version Show version information\n"
75 << " -h, --help Print this message\n"
76 << " -c, --name <name> Use a specific backend client name, default is ardour\n"
77 << " -d, --disable-plugins Disable all plugins in an existing session\n"
78 << " -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n"
79 << " -O, --no-hw-optimizations Disable h/w specific optimizations\n"
80 << " -P, --no-connect-ports Do not connect any ports at startup\n"
81 #ifdef WINDOWS_VST_SUPPORT
82 << " -V, --novst Do not use VST support\n"
87 int main (int argc, char* argv[])
89 const char *optstring = "vhdD:c:VOU:P";
91 const struct option longopts[] = {
92 { "version", 0, 0, 'v' },
93 { "help", 0, 0, 'h' },
94 { "disable-plugins", 1, 0, 'd' },
95 { "debug", 1, 0, 'D' },
96 { "name", 1, 0, 'c' },
97 { "novst", 0, 0, 'V' },
98 { "no-hw-optimizations", 0, 0, 'O' },
99 { "uuid", 1, 0, 'U' },
100 { "no-connect-ports", 0, 0, 'P' },
104 int option_index = 0;
108 c = getopt_long (argc, argv, optstring, longopts, &option_index);
128 backend_client_name = optarg;
132 ARDOUR::Session::set_disable_all_loaded_plugins (true);
136 if (PBD::parse_debug_options (optarg)) {
142 try_hw_optimization = false;
146 no_connect_ports = true;
150 #ifdef WINDOWS_VST_SUPPORT
152 #endif /* WINDOWS_VST_SUPPORT */
156 backend_session_uuid = optarg;
170 if (!ARDOUR::init (false, true, localedir)) {
171 cerr << "Ardour failed to initialize\n" << endl;
178 s = load_session (argv[optind], argv[optind+1]);
179 } catch (failed_constructor& e) {
180 cerr << "failed_constructor: " << e.what() << "\n";
182 } catch (AudioEngine::PortRegistrationFailure& e) {
183 cerr << "PortRegistrationFailure: " << e.what() << "\n";
185 } catch (exception& e) {
186 cerr << "exception: " << e.what() << "\n";
189 cerr << "unknown exception.\n";
193 s->request_transport_speed (1.0);
197 AudioEngine::instance()->remove_session ();
199 AudioEngine::instance()->stop ();
201 AudioEngine::destroy ();