mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 07:33:46 +01:00
encoding: when output is pipe: or pipe:1, avoid mp_msg to stdout
I am aware this detection may occur too late, depending on other settings, but at least it usually works and is portable. Where the output fd can be changed, though, it'd be better to force a similar behaviour via file descriptor use: use pipe:3 as output to FD 3, and change the calling program to expect the stream on FD 3.
This commit is contained in:
parent
df8a481eba
commit
0c1d95e81b
@ -117,6 +117,11 @@ struct encode_lavc_context *encode_lavc_init(struct encode_output_conf *options)
|
||||
{
|
||||
struct encode_lavc_context *ctx;
|
||||
|
||||
if (options->file && (
|
||||
!strcmp(options->file, "pipe:") ||
|
||||
!strcmp(options->file, "pipe:1")))
|
||||
mp_msg_stdout_in_use = 1;
|
||||
|
||||
ctx = talloc_zero(NULL, struct encode_lavc_context);
|
||||
encode_lavc_discontinuity(ctx);
|
||||
ctx->options = options;
|
||||
|
@ -37,6 +37,8 @@
|
||||
|
||||
#include "core/mp_msg.h"
|
||||
|
||||
bool mp_msg_stdout_in_use = 0;
|
||||
|
||||
/* maximum message length of mp_msg */
|
||||
#define MSGSIZE_MAX 6144
|
||||
|
||||
@ -225,7 +227,8 @@ static void print_msg_module(FILE* stream, int mod)
|
||||
void mp_msg_va(int mod, int lev, const char *format, va_list va)
|
||||
{
|
||||
char tmp[MSGSIZE_MAX];
|
||||
FILE *stream = lev == MSGL_STATUS ? stderr : stdout;
|
||||
FILE *stream =
|
||||
(mp_msg_stdout_in_use || (lev == MSGL_STATUS)) ? stderr : stdout;
|
||||
static int header = 1;
|
||||
// indicates if last line printed was a status line
|
||||
static int statusline;
|
||||
|
@ -142,4 +142,6 @@ void mp_msg(int mod, int lev, const char *format, ... ) PRINTF_ATTRIBUTE(3, 4);
|
||||
void mp_tmsg(int mod, int lev, const char *format, ... ) PRINTF_ATTRIBUTE(3, 4);
|
||||
#define mp_dbg mp_msg
|
||||
|
||||
extern bool mp_msg_stdout_in_use;
|
||||
|
||||
#endif /* MPLAYER_MP_MSG_H */
|
||||
|
Loading…
Reference in New Issue
Block a user