Add "exit-when-halted" halted option for arlua
This is useful when when the ardour-lua is started by a command based wrapper that cannot poll the engine state.
This commit is contained in:
parent
551be058f2
commit
b42c72e49f
@ -50,7 +50,9 @@ static PBD::ScopedConnectionList engine_connections;
|
|||||||
static PBD::ScopedConnectionList session_connections;
|
static PBD::ScopedConnectionList session_connections;
|
||||||
static Session* session = NULL;
|
static Session* session = NULL;
|
||||||
static LuaState* lua;
|
static LuaState* lua;
|
||||||
|
|
||||||
static bool keep_running = true;
|
static bool keep_running = true;
|
||||||
|
static bool terminate_when_halted = false;
|
||||||
|
|
||||||
/* extern VST functions */
|
/* extern VST functions */
|
||||||
int vstfx_init (void*) { return 0; }
|
int vstfx_init (void*) { return 0; }
|
||||||
@ -83,9 +85,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* note: iostreams are already thread-safe: no external
|
/* note: iostreams are already thread-safe: no external
|
||||||
lock required.
|
* lock required. */
|
||||||
*/
|
|
||||||
|
|
||||||
std::cout << prefix << str << std::endl;
|
std::cout << prefix << str << std::endl;
|
||||||
|
|
||||||
if (chn == Transmitter::Fatal) {
|
if (chn == Transmitter::Fatal) {
|
||||||
@ -139,8 +139,7 @@ static void
|
|||||||
init ()
|
init ()
|
||||||
{
|
{
|
||||||
if (!ARDOUR::init (false, true, localedir)) {
|
if (!ARDOUR::init (false, true, localedir)) {
|
||||||
cerr << "Ardour failed to initialize\n"
|
cerr << "Ardour failed to initialize\n" << endl;
|
||||||
<< endl;
|
|
||||||
::exit (EXIT_FAILURE);
|
::exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +379,15 @@ do_quit (lua_State* L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
engine_halted (const char* err)
|
||||||
|
{
|
||||||
|
if (terminate_when_halted) {
|
||||||
|
cerr << "Engine halted: " << err << "\n";
|
||||||
|
::exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ****************************************************************************/
|
/* ****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -425,6 +433,8 @@ setup_lua ()
|
|||||||
lua_setglobal (L, "AudioEngine");
|
lua_setglobal (L, "AudioEngine");
|
||||||
|
|
||||||
AudioEngine::instance ()->stop ();
|
AudioEngine::instance ()->stop ();
|
||||||
|
|
||||||
|
AudioEngine::instance()->Halted.connect_same_thread (engine_connections, boost::bind (&engine_halted, _1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -523,6 +533,8 @@ usage ()
|
|||||||
-h, --help display this help and exit\n\
|
-h, --help display this help and exit\n\
|
||||||
-i, --interactive enter interactive mode after executing 'script',\n\
|
-i, --interactive enter interactive mode after executing 'script',\n\
|
||||||
force the interpreter to run interactively\n\
|
force the interpreter to run interactively\n\
|
||||||
|
-X, --exit-when-halted terminate when the audio-engine halts\n\
|
||||||
|
unexpectedly.\n\
|
||||||
-V, --version print version information and exit\n\
|
-V, --version print version information and exit\n\
|
||||||
\n");
|
\n");
|
||||||
printf ("\n\
|
printf ("\n\
|
||||||
@ -536,12 +548,13 @@ Ardour at your finger tips...\n\
|
|||||||
int
|
int
|
||||||
main (int argc, char** argv)
|
main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
const char* optstring = "hiV";
|
const char* optstring = "hiVX";
|
||||||
|
|
||||||
const struct option longopts[] = {
|
const struct option longopts[] = {
|
||||||
{ "help", 0, 0, 'h' },
|
{ "help", 0, 0, 'h' },
|
||||||
{ "interactive", 0, 0, 'i' },
|
{ "interactive", 0, 0, 'i' },
|
||||||
{ "version", 0, 0, 'V' },
|
{ "version", 0, 0, 'V' },
|
||||||
|
{ "exit-when-halted", 0, 0, 'X' },
|
||||||
};
|
};
|
||||||
|
|
||||||
bool interactive = false;
|
bool interactive = false;
|
||||||
@ -564,6 +577,10 @@ main (int argc, char** argv)
|
|||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'X':
|
||||||
|
terminate_when_halted = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cerr << "Error: unrecognized option. See --help for usage information.\n";
|
cerr << "Error: unrecognized option. See --help for usage information.\n";
|
||||||
::exit (EXIT_FAILURE);
|
::exit (EXIT_FAILURE);
|
||||||
|
Loading…
Reference in New Issue
Block a user