Improve headless Ardour somewhat
* Allow to exit cleanly (using access-action) * Terminate when the backend is halted * Handle various commandline arguments as advertised - print version - disable hardware optimization - set client-name - prevent port-connections * Use JACK -- previously hardour only worked if Ardour was compiled with JACK as *only* backend. Other backends are listed before JACK, set_default_backend() never picks JACK unless it's the only one. Other backends need configuration, or EngineState from config. This is currently handled in the GUI's engine-dialog..
This commit is contained in:
parent
1801c33ee4
commit
dc4dc048a9
@ -2,14 +2,20 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <glibmm.h>
|
||||||
|
|
||||||
|
#include "pbd/convert.h"
|
||||||
#include "pbd/failed_constructor.h"
|
#include "pbd/failed_constructor.h"
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
#include "pbd/debug.h"
|
#include "pbd/debug.h"
|
||||||
|
|
||||||
#include "ardour/ardour.h"
|
#include "ardour/ardour.h"
|
||||||
#include "ardour/audioengine.h"
|
#include "ardour/audioengine.h"
|
||||||
|
#include "ardour/revision.h"
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
|
|
||||||
|
#include "control_protocol/control_protocol.h"
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -23,12 +29,16 @@ using namespace PBD;
|
|||||||
|
|
||||||
static const char* localedir = LOCALEDIR;
|
static const char* localedir = LOCALEDIR;
|
||||||
|
|
||||||
|
static string backend_client_name;
|
||||||
|
static string backend_name = "JACK";
|
||||||
|
static volatile bool run_headless = true;
|
||||||
|
|
||||||
TestReceiver test_receiver;
|
TestReceiver test_receiver;
|
||||||
|
|
||||||
/** @param dir Session directory.
|
/** @param dir Session directory.
|
||||||
* @param state Session state file, without .ardour suffix.
|
* @param state Session state file, without .ardour suffix.
|
||||||
*/
|
*/
|
||||||
Session *
|
static Session *
|
||||||
load_session (string dir, string state)
|
load_session (string dir, string state)
|
||||||
{
|
{
|
||||||
SessionEvent::create_per_thread_pool ("test", 512);
|
SessionEvent::create_per_thread_pool ("test", 512);
|
||||||
@ -40,8 +50,8 @@ load_session (string dir, string state)
|
|||||||
|
|
||||||
AudioEngine* engine = AudioEngine::create ();
|
AudioEngine* engine = AudioEngine::create ();
|
||||||
|
|
||||||
if (!engine->set_default_backend ()) {
|
if (!engine->set_backend (backend_name, backend_client_name, "")) {
|
||||||
std::cerr << "Cannot create Audio/MIDI engine\n";
|
std::cerr << "Cannot set Audio/MIDI engine backend\n";
|
||||||
::exit (1);
|
::exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,15 +65,43 @@ load_session (string dir, string state)
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
string session_name = "";
|
static void
|
||||||
string backend_client_name = "ardour";
|
access_action (const std::string& action_group, const std::string& action_item)
|
||||||
string backend_session_uuid;
|
{
|
||||||
bool just_version = false;
|
if (action_group == "Common" && action_item == "Quit") {
|
||||||
bool use_vst = true;
|
run_headless = false;
|
||||||
bool try_hw_optimization = true;
|
}
|
||||||
bool no_connect_ports = false;
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
|
engine_halted (const char* reason)
|
||||||
|
{
|
||||||
|
cerr << "The audio backend has either been shutdown";
|
||||||
|
if (reason && strlen (reason) > 0) {
|
||||||
|
cerr << ": " << reason;
|
||||||
|
} else {
|
||||||
|
cerr << ".";
|
||||||
|
}
|
||||||
|
cerr << endl;
|
||||||
|
run_headless = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_version ()
|
||||||
|
{
|
||||||
|
cout
|
||||||
|
<< PROGRAM_NAME
|
||||||
|
<< VERSIONSTRING
|
||||||
|
<< " (built using "
|
||||||
|
<< ARDOUR::revision
|
||||||
|
#ifdef __GNUC__
|
||||||
|
<< " and GCC version " << __VERSION__
|
||||||
|
#endif
|
||||||
|
<< ')'
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
print_help ()
|
print_help ()
|
||||||
{
|
{
|
||||||
cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
|
cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
|
||||||
@ -103,6 +141,11 @@ int main (int argc, char* argv[])
|
|||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
|
bool use_vst = true;
|
||||||
|
bool try_hw_optimization = true;
|
||||||
|
|
||||||
|
backend_client_name = PBD::downcase (std::string(PROGRAM_NAME));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
c = getopt_long (argc, argv, optstring, longopts, &option_index);
|
c = getopt_long (argc, argv, optstring, longopts, &option_index);
|
||||||
|
|
||||||
@ -115,7 +158,8 @@ int main (int argc, char* argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
just_version = true;
|
print_version ();
|
||||||
|
::exit (0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -146,7 +190,7 @@ int main (int argc, char* argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
no_connect_ports = true;
|
ARDOUR::Port::set_connecting_blocked (true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
@ -155,10 +199,6 @@ int main (int argc, char* argv[])
|
|||||||
#endif /* WINDOWS_VST_SUPPORT */
|
#endif /* WINDOWS_VST_SUPPORT */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U':
|
|
||||||
backend_session_uuid = optarg;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
print_help ();
|
print_help ();
|
||||||
::exit (1);
|
::exit (1);
|
||||||
@ -170,7 +210,7 @@ int main (int argc, char* argv[])
|
|||||||
::exit (1);
|
::exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ARDOUR::init (false, true, localedir)) {
|
if (!ARDOUR::init (use_vst, try_hw_optimization, localedir)) {
|
||||||
cerr << "Ardour failed to initialize\n" << endl;
|
cerr << "Ardour failed to initialize\n" << endl;
|
||||||
::exit (1);
|
::exit (1);
|
||||||
}
|
}
|
||||||
@ -193,9 +233,15 @@ int main (int argc, char* argv[])
|
|||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PBD::ScopedConnectionList con;
|
||||||
|
BasicUI::AccessAction.connect_same_thread (con, boost::bind (&access_action, _1, _2));
|
||||||
|
AudioEngine::instance()->Halted.connect_same_thread (con, boost::bind (&engine_halted, _1));
|
||||||
|
|
||||||
s->request_transport_speed (1.0);
|
s->request_transport_speed (1.0);
|
||||||
|
|
||||||
sleep (-1);
|
while (run_headless) {
|
||||||
|
Glib::usleep (500000);
|
||||||
|
}
|
||||||
|
|
||||||
AudioEngine::instance()->remove_session ();
|
AudioEngine::instance()->remove_session ();
|
||||||
delete s;
|
delete s;
|
||||||
|
Loading…
Reference in New Issue
Block a user