Revert "Do no modify terminal parameters using termios.h"
This reverts commit cb48e245e6e770f146220fac0a8bd4dc1a5e006c. Reason being we like pressing "q" to quit ffmpeg. Conflicts: ffmpeg.c Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
93dfda8896
commit
8b8bf89e52
2
configure
vendored
2
configure
vendored
@ -1118,6 +1118,7 @@ HAVE_LIST="
|
|||||||
sys_soundcard_h
|
sys_soundcard_h
|
||||||
sys_videoio_h
|
sys_videoio_h
|
||||||
ten_operands
|
ten_operands
|
||||||
|
termios_h
|
||||||
threads
|
threads
|
||||||
truncf
|
truncf
|
||||||
vfp_args
|
vfp_args
|
||||||
@ -2803,6 +2804,7 @@ check_header poll.h
|
|||||||
check_header sys/mman.h
|
check_header sys/mman.h
|
||||||
check_header sys/resource.h
|
check_header sys/resource.h
|
||||||
check_header sys/select.h
|
check_header sys/select.h
|
||||||
|
check_header termios.h
|
||||||
check_header vdpau/vdpau.h
|
check_header vdpau/vdpau.h
|
||||||
check_header vdpau/vdpau_x11.h
|
check_header vdpau/vdpau_x11.h
|
||||||
check_header X11/extensions/XvMClib.h
|
check_header X11/extensions/XvMClib.h
|
||||||
|
60
ffmpeg.c
60
ffmpeg.c
@ -69,7 +69,12 @@
|
|||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_KBHIT
|
#if HAVE_TERMIOS_H
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#elif HAVE_KBHIT
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#endif
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -338,6 +343,12 @@ typedef struct AVInputFile {
|
|||||||
int nb_streams; /* nb streams we are aware of */
|
int nb_streams; /* nb streams we are aware of */
|
||||||
} AVInputFile;
|
} AVInputFile;
|
||||||
|
|
||||||
|
#if HAVE_TERMIOS_H
|
||||||
|
|
||||||
|
/* init terminal so that we can grab keys */
|
||||||
|
static struct termios oldtty;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_AVFILTER
|
#if CONFIG_AVFILTER
|
||||||
|
|
||||||
static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
|
static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
|
||||||
@ -425,6 +436,9 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
|
|||||||
static void term_exit(void)
|
static void term_exit(void)
|
||||||
{
|
{
|
||||||
av_log(NULL, AV_LOG_QUIET, "");
|
av_log(NULL, AV_LOG_QUIET, "");
|
||||||
|
#if HAVE_TERMIOS_H
|
||||||
|
tcsetattr (0, TCSANOW, &oldtty);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile int received_sigterm = 0;
|
static volatile int received_sigterm = 0;
|
||||||
@ -439,6 +453,26 @@ sigterm_handler(int sig)
|
|||||||
|
|
||||||
static void term_init(void)
|
static void term_init(void)
|
||||||
{
|
{
|
||||||
|
#if HAVE_TERMIOS_H
|
||||||
|
struct termios tty;
|
||||||
|
|
||||||
|
tcgetattr (0, &tty);
|
||||||
|
oldtty = tty;
|
||||||
|
atexit(term_exit);
|
||||||
|
|
||||||
|
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
|
||||||
|
|INLCR|IGNCR|ICRNL|IXON);
|
||||||
|
tty.c_oflag |= OPOST;
|
||||||
|
tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
|
||||||
|
tty.c_cflag &= ~(CSIZE|PARENB);
|
||||||
|
tty.c_cflag |= CS8;
|
||||||
|
tty.c_cc[VMIN] = 1;
|
||||||
|
tty.c_cc[VTIME] = 0;
|
||||||
|
|
||||||
|
tcsetattr (0, TCSANOW, &tty);
|
||||||
|
signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
|
||||||
|
#endif
|
||||||
|
|
||||||
signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
|
signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
|
||||||
signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */
|
signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */
|
||||||
#ifdef SIGXCPU
|
#ifdef SIGXCPU
|
||||||
@ -449,7 +483,25 @@ static void term_init(void)
|
|||||||
/* read a key without blocking */
|
/* read a key without blocking */
|
||||||
static int read_key(void)
|
static int read_key(void)
|
||||||
{
|
{
|
||||||
#if HAVE_KBHIT
|
#if HAVE_TERMIOS_H
|
||||||
|
int n = 1;
|
||||||
|
unsigned char ch;
|
||||||
|
struct timeval tv;
|
||||||
|
fd_set rfds;
|
||||||
|
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
FD_SET(0, &rfds);
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
n = select(1, &rfds, NULL, NULL, &tv);
|
||||||
|
if (n > 0) {
|
||||||
|
n = read(0, &ch, 1);
|
||||||
|
if (n == 1)
|
||||||
|
return ch;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
#elif HAVE_KBHIT
|
||||||
if(kbhit())
|
if(kbhit())
|
||||||
return(getch());
|
return(getch());
|
||||||
#endif
|
#endif
|
||||||
@ -2467,11 +2519,7 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
|
|
||||||
if (!using_stdin) {
|
if (!using_stdin) {
|
||||||
if(verbose >= 0)
|
if(verbose >= 0)
|
||||||
#if HAVE_KBHIT
|
|
||||||
fprintf(stderr, "Press [q] to stop encoding\n");
|
fprintf(stderr, "Press [q] to stop encoding\n");
|
||||||
#else
|
|
||||||
fprintf(stderr, "Press ctrl-c to stop encoding\n");
|
|
||||||
#endif
|
|
||||||
url_set_interrupt_cb(decode_interrupt_cb);
|
url_set_interrupt_cb(decode_interrupt_cb);
|
||||||
}
|
}
|
||||||
term_init();
|
term_init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user