mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
player/{command,scripting}: log subprocess execution
Useful for debugging purposes and sanity checks. Remove unused function while at it.
This commit is contained in:
@@ -21,10 +21,6 @@
|
||||
|
||||
#include "subprocess.h"
|
||||
|
||||
void mp_devnull(void *ctx, char *data, size_t size)
|
||||
{
|
||||
}
|
||||
|
||||
const char *mp_subprocess_err_str(int num)
|
||||
{
|
||||
// Note: these are visible to the public client API
|
||||
@@ -37,3 +33,17 @@ const char *mp_subprocess_err_str(int num)
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
void mp_subprocess(struct mp_log *log,
|
||||
struct mp_subprocess_opts *opts,
|
||||
struct mp_subprocess_result *res)
|
||||
{
|
||||
mp_verbose(log, "Starting subprocess: [%s", opts->args[0]);
|
||||
char **arg = &opts->args[1];
|
||||
while (*arg)
|
||||
mp_verbose(log, ", %s", *arg++);
|
||||
mp_verbose(log, "]\n");
|
||||
mp_subprocess2(opts, res);
|
||||
if (res->error < 0)
|
||||
mp_err(log, "Subprocess failed: %s\n", mp_subprocess_err_str(res->error));
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ typedef void (*subprocess_read_cb)(void *ctx, char *data, size_t size);
|
||||
// Not filling the buffer means EOF.
|
||||
typedef void (*subprocess_write_cb)(void *ctx);
|
||||
|
||||
void mp_devnull(void *ctx, char *data, size_t size);
|
||||
|
||||
#define MP_SUBPROCESS_MAX_FDS 10
|
||||
|
||||
struct mp_subprocess_fd {
|
||||
@@ -64,7 +62,7 @@ struct mp_subprocess_opts {
|
||||
};
|
||||
|
||||
struct mp_subprocess_result {
|
||||
int error; // one of MP_SUBPROCESS_* (>0 on error)
|
||||
int error; // one of MP_SUBPROCESS_* (<0 on error)
|
||||
// NB: if WIFEXITED applies, error==0, and this is WEXITSTATUS
|
||||
// on win32, this can use the full 32 bit
|
||||
// if started with detach==true, this is always 0
|
||||
@@ -85,4 +83,9 @@ const char *mp_subprocess_err_str(int num);
|
||||
void mp_subprocess2(struct mp_subprocess_opts *opts,
|
||||
struct mp_subprocess_result *res);
|
||||
|
||||
struct mp_log;
|
||||
void mp_subprocess(struct mp_log *log,
|
||||
struct mp_subprocess_opts *opts,
|
||||
struct mp_subprocess_result *res);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user