Coverage Report

Created: 2025-10-27 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mpv/osdep/subprocess.c
Line
Count
Source
1
/*
2
 * This file is part of mpv.
3
 *
4
 * mpv is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * mpv is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with mpv.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
#include "common/common.h"
19
#include "common/msg.h"
20
#include "common/msg_control.h"
21
22
#include "subprocess.h"
23
24
const char *mp_subprocess_err_str(int num)
25
4.70k
{
26
    // Note: these are visible to the public client API
27
4.70k
    switch (num) {
28
0
    case MP_SUBPROCESS_OK:              return "success";
29
0
    case MP_SUBPROCESS_EKILLED_BY_US:   return "killed";
30
0
    case MP_SUBPROCESS_EINIT:           return "init";
31
4.70k
    case MP_SUBPROCESS_EUNSUPPORTED:    return "unsupported";
32
0
    case MP_SUBPROCESS_EGENERIC:        // fall through
33
0
    default:                            return "unknown";
34
4.70k
    }
35
4.70k
}
36
37
void mp_subprocess(struct mp_log *log,
38
                   struct mp_subprocess_opts *opts,
39
                   struct mp_subprocess_result *res)
40
4.70k
{
41
4.70k
    mp_verbose(log, "Starting subprocess: [%s", opts->args[0]);
42
4.70k
    char **arg = &opts->args[1];
43
9.41k
    while (*arg)
44
4.70k
        mp_verbose(log, ", %s", *arg++);
45
4.70k
    mp_verbose(log, "]\n");
46
4.70k
    mp_subprocess2(opts, res);
47
4.70k
    if (res->error < 0) {
48
4.70k
        int lev = res->error == MP_SUBPROCESS_EKILLED_BY_US ? MSGL_V : MSGL_ERR;
49
4.70k
        mp_msg(log, lev, "Subprocess failed: %s\n", mp_subprocess_err_str(res->error));
50
4.70k
    }
51
4.70k
}