Use enum for exec stderr parameter (1/2)
authorRobin Gareus <robin@gareus.org>
Tue, 5 Mar 2019 18:06:15 +0000 (19:06 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 5 Mar 2019 21:49:15 +0000 (22:49 +0100)
libs/ardour/ardour/system_exec.h
libs/ardour/export_graph_builder.cc
libs/ardour/export_handler.cc
libs/ardour/vst_info_file.cc
libs/backends/alsa/alsa_audiobackend.cc
libs/pbd/pbd/system_exec.h
libs/pbd/system_exec.cc

index ae865c7bff7ce040b87449688dfa8a54ae898c0e..010a076c015b8d0bd0ce8a9dece91d773ef51ee4 100644 (file)
@@ -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:
index 2fd1df2e895f8f9a280f64f6a50e215bae886a61..5afb5c1e7daa373bf9e5ccccc2a2364466289488 100644 (file)
@@ -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));
index cd3d61731d400a8d91268baa15f955520c0a16cf..c39d630d69236681cb527db5501bb61531f53e21 100644 (file)
@@ -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 ()) {
index d6d946dee6a901e17645622fe13c54cc1f2e6004..189288ce15e53d204ea77d84598ed4a7980b74d9 100644 (file)
@@ -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;
index 13551975225de078d631c05c00d2f6608692a8ca..00c6940d7c147ecb0f874525629e5b51ba3731ac 100644 (file)
@@ -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;
index 1e36c3df9fcba136adc0f70738d52babd5b98ef1..a567e3b03274a3cccd5fdabbb7c523555e972e6f 100644 (file)
@@ -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.
index b7a7f871232ac5b87e59d21f8f8721d8453e7241..23f808a0c3fe6cb49db83233698ff85d145a909c 100644 (file)
@@ -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 {