From 3b22404e07df265af221112e2970084a15766c9a Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 23 Jan 2013 15:47:49 +0100 Subject: mp_msg, getch2: unix tty background support Now, when backgrounded, mpv plays and outputs messages to stdout, but statusline is not output. Background<->foreground transitions are detected by signals and polling the process groups. --- core/input/input.c | 2 ++ core/mp_msg.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'core') diff --git a/core/input/input.c b/core/input/input.c index 1eedadf039..8b473dda43 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -32,6 +32,7 @@ #include #include "osdep/io.h" +#include "osdep/getch2.h" #include "input.h" #include "core/mp_fifo.h" @@ -1503,6 +1504,7 @@ static void read_all_fd_events(struct input_ctx *ictx, int time) static void read_all_events(struct input_ctx *ictx, int time) { + getch2_poll(); #ifdef CONFIG_COCOA cocoa_events_read_all_events(ictx, time); #else diff --git a/core/mp_msg.c b/core/mp_msg.c index 2e6f148438..85cbe9c1fa 100644 --- a/core/mp_msg.c +++ b/core/mp_msg.c @@ -31,6 +31,10 @@ #include #endif +#ifndef __MINGW32__ +#include +#endif + #include "core/mp_msg.h" /* maximum message length of mp_msg */ @@ -78,6 +82,13 @@ void mp_msg_init(void){ SetConsoleMode(hSTDERR, cmode); GetConsoleScreenBufferInfo(hSTDOUT, &cinfo); stdoutAttrs = cinfo.wAttributes; +#endif +#ifndef __MINGW32__ + struct sigaction sa; + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGTTOU, &sa, NULL); // just write to stdout if you have to #endif int i; char *env = getenv("MPV_VERBOSE"); @@ -98,6 +109,13 @@ void mp_msg_init(void){ int mp_msg_test(int mod, int lev) { +#ifndef __MINGW32__ + if (lev == MSGL_STATUS) { + // skip status line output if we are not in the foreground process group + if (tcgetpgrp(0) != getpgrp()) + return false; + } +#endif return lev <= (mp_msg_levels[mod] == -2 ? mp_msg_level_all + verbose : mp_msg_levels[mod]); } -- cgit v1.2.3