merge with master and fix 2 conflicts
[ardour.git] / libs / ardour / test / load_session.cc
1 #include "test_util.h"
2 #include "pbd/failed_constructor.h"
3 #include "ardour/ardour.h"
4 #include "ardour/audioengine.h"
5 #include "ardour/session.h"
6 #include <iostream>
7 #include <cstdlib>
8
9 using namespace std;
10 using namespace ARDOUR;
11
12 static const char* localedir = LOCALEDIR;
13
14 int main (int argc, char* argv[])
15 {
16         if (argc != 3) {
17                 cerr << "Syntax: " << argv[0] << " <dir> <snapshot-name>\n";
18                 exit (EXIT_FAILURE);
19         }
20
21         ARDOUR::init (false, true, localedir);
22
23         Session* s = 0;
24         
25         try {
26                 s = load_session (argv[1], argv[2]);
27         } catch (failed_constructor& e) {
28                 cerr << "failed_constructor: " << e.what() << "\n";
29                 exit (EXIT_FAILURE);
30         } catch (AudioEngine::PortRegistrationFailure& e) {
31                 cerr << "PortRegistrationFailure: " << e.what() << "\n";
32                 exit (EXIT_FAILURE);
33         } catch (exception& e) {
34                 cerr << "exception: " << e.what() << "\n";
35                 exit (EXIT_FAILURE);
36         } catch (...) {
37                 cerr << "unknown exception.\n";
38                 exit (EXIT_FAILURE);
39         }
40
41         AudioEngine::instance()->remove_session ();
42         delete s;
43         AudioEngine::instance()->stop ();
44
45         AudioEngine::destroy ();
46
47         return 0;
48 }