SystemExec (std::string c, const std::map<char, std::string> subs);
~SystemExec ();
- int start (int stderr_mode = 1) {
- return PBD::SystemExec::start(stderr_mode, _vfork_exec_wrapper);
+ int start (StdErrMode stderr_mode = IgnoreAndClose) {
+ return PBD::SystemExec::start (stderr_mode, _vfork_exec_wrapper);
}
private:
* SystemExec is deleted when writer is destroyed */
ARDOUR::SystemExec* exec = new ARDOUR::SystemExec (ffmpeg_exe, argp);
PBD::info << "Encode command: { " << exec->to_s () << "}" << endmsg;
- if (exec->start(0)) {
+ if (exec->start ()) {
throw ExportFailed ("External encoder (ffmpeg) cannot be started.");
}
writer.reset (new AudioGrapher::CmdPipeWriter<T> (exec, writer_filename));
ARDOUR::SystemExec *se = new ARDOUR::SystemExec(fmt->command(), subs);
info << "Post-export command line : {" << se->to_s () << "}" << endmsg;
se->ReadStdout.connect_same_thread(command_connection, boost::bind(&ExportHandler::command_output, this, _1, _2));
- int ret = se->start (2);
+ int ret = se->start (SystemExec::MergeWithStdin);
if (ret == 0) {
// successfully started
while (se->is_running ()) {
ARDOUR::SystemExec scanner (scanner_bin_path, argp);
PBD::ScopedConnectionList cons;
scanner.ReadStdout.connect_same_thread (cons, boost::bind (&parse_scanner_output, _1 ,_2));
- if (scanner.start (2 /* send stderr&stdout via signal */)) {
+ if (scanner.start (ARDOUR::SystemExec::MergeWithStdin)) {
PBD::error << string_compose (_("Cannot launch VST scanner app '%1': %2"), scanner_bin_path, strerror (errno)) << endmsg;
close_error_log ();
return infos;
_device_reservation->ReadStdout.connect_same_thread (_reservation_connection, boost::bind (&AlsaDeviceReservation::reservation_stdout, this, _1 ,_2));
_device_reservation->Terminated.connect_same_thread (_reservation_connection, boost::bind (&AlsaDeviceReservation::release_device, this));
- if (_device_reservation->start(0)) {
+ if (_device_reservation->start (SystemExec::ShareWithParent)) {
PBD::warning << _("AlsaAudioBackend: Device Request failed.") << endmsg;
release_device();
return false;
std::string to_s() const;
+ enum StdErrMode {
+ ShareWithParent = 0,
+ IgnoreAndClose = 1,
+ MergeWithStdin = 2
+ };
+
/** fork and execute the given program
*
* @param stderr_mode select what to do with program's standard error
* @return If the process is already running or was launched successfully
* the function returns zero (0). A negative number indicates an error.
*/
- int start (int stderr_mode, const char *_vfork_exec_wrapper);
+ int start (StdErrMode, const char *_vfork_exec_wrapper);
/** kill running child-process
*
* if a child process exists trt to shut it down by closing its STDIN.
}
int
-SystemExec::start (int stderr_mode, const char * /*vfork_exec_wrapper*/)
+SystemExec::start (StdErrMode stderr_mode, const char * /*vfork_exec_wrapper*/)
{
char* working_dir = 0;
create_pipe(stdinP, true);
create_pipe(stdoutP, false);
- if (stderr_mode == 2) {
+ if (stderr_mode == MergeWithStdin) {
/* merge stout & stderr */
DuplicateHandle(GetCurrentProcess(), stdoutP[1], GetCurrentProcess(), &stderrP[1], 0, TRUE, DUPLICATE_SAME_ACCESS);
- } else if (stderr_mode == 1) {
+ } else if (stderr_mode == IgnoreAndClose) {
//TODO read/flush this pipe or close it...
create_pipe(stderrP, false);
} else {
}
int
-SystemExec::start (int stderr_mode, const char *vfork_exec_wrapper)
+SystemExec::start (StdErrMode stderr_mode, const char *vfork_exec_wrapper)
{
if (is_running ()) {
return 0;
::dup2 (pout[1], STDOUT_FILENO);
}
- if (stderr_mode == 2) {
+ if (stderr_mode == MergeWithStdin) {
/* merge STDERR into output */
if (pout[1] != STDERR_FILENO) {
::dup2(pout[1], STDERR_FILENO);
}
- } else if (stderr_mode == 1) {
+ } else if (stderr_mode == IgnoreAndClose) {
/* ignore STDERR */
::close(STDERR_FILENO);
} else {