Use enum for exec stderr parameter (1/2)
This commit is contained in:
parent
fdf74cf850
commit
e1ffe7857f
|
@ -35,8 +35,8 @@ public:
|
|||
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:
|
||||
|
|
|
@ -383,7 +383,7 @@ ExportGraphBuilder::Encoder::init_writer (boost::shared_ptr<AudioGrapher::CmdPip
|
|||
* 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));
|
||||
|
|
|
@ -422,7 +422,7 @@ ExportHandler::finish_timespan ()
|
|||
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 ()) {
|
||||
|
|
|
@ -998,7 +998,7 @@ vstfx_get_info (const char* dllpath, enum ARDOUR::PluginType type, enum VSTScanM
|
|||
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;
|
||||
|
|
|
@ -2831,7 +2831,7 @@ AlsaDeviceReservation::acquire_device (const char* device_name)
|
|||
_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;
|
||||
|
|
|
@ -122,6 +122,12 @@ class LIBPBD_API SystemExec
|
|||
|
||||
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
|
||||
|
@ -133,7 +139,7 @@ class LIBPBD_API SystemExec
|
|||
* @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.
|
||||
|
|
|
@ -529,7 +529,7 @@ SystemExec::is_running ()
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -541,10 +541,10 @@ SystemExec::start (int stderr_mode, const char * /*vfork_exec_wrapper*/)
|
|||
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 {
|
||||
|
@ -807,7 +807,7 @@ SystemExec::is_running ()
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -889,12 +889,12 @@ SystemExec::start (int stderr_mode, const char *vfork_exec_wrapper)
|
|||
::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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user