History

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

Michael Niedermayer committed 15 years ago

Commit 8b8bf891 parent 93dfda82 files · +56 −6Browse files

Unified · Split

2 files
  1. configure +2 −0
  2. ffmpeg.c +54 −6
configure+2−0
@@ -1118,6 +1118,7 @@ HAVE_LIST=" · 1117 unmodified lines
1118 sys_soundcard_h1118 sys_soundcard_h
1119 sys_videoio_h1119 sys_videoio_h
1120 ten_operands1120 ten_operands
1121 termios_h
1121 threads1122 threads
1122 truncf1123 truncf
1123 vfp_args1124 vfp_args
@@ -2803,6 +2804,7 @@ check_header poll.h · 1679 unmodified lines
2803check_header sys/mman.h2804check_header sys/mman.h
2804check_header sys/resource.h2805check_header sys/resource.h
2805check_header sys/select.h2806check_header sys/select.h
2807check_header termios.h
2806check_header vdpau/vdpau.h2808check_header vdpau/vdpau.h
2807check_header vdpau/vdpau_x11.h2809check_header vdpau/vdpau_x11.h
2808check_header X11/extensions/XvMClib.h2810check_header X11/extensions/XvMClib.h
ffmpeg.c+54−6
@@ -69,7 +69,12 @@ · 68 unmodified lines
69#include <sys/select.h>69#include <sys/select.h>
70#endif70#endif
71 71
72#if HAVE_KBHIT72#if HAVE_TERMIOS_H
73#include <fcntl.h>
74#include <sys/ioctl.h>
75#include <sys/time.h>
76#include <termios.h>
77#elif HAVE_KBHIT
73#include <conio.h>78#include <conio.h>
74#endif79#endif
75#include <time.h>80#include <time.h>
@@ -338,6 +343,12 @@ typedef struct AVInputFile { · 262 unmodified lines
338 int nb_streams; /* nb streams we are aware of */343 int nb_streams; /* nb streams we are aware of */
339} AVInputFile;344} AVInputFile;
340 345
346#if HAVE_TERMIOS_H
347
348/* init terminal so that we can grab keys */
349static struct termios oldtty;
350#endif
351
341#if CONFIG_AVFILTER352#if CONFIG_AVFILTER
342 353
343static int configure_filters(AVInputStream *ist, AVOutputStream *ost)354static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
@@ -425,6 +436,9 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) · 81 unmodified lines
425static void term_exit(void)436static void term_exit(void)
426{437{
427 av_log(NULL, AV_LOG_QUIET, "");438 av_log(NULL, AV_LOG_QUIET, "");
439#if HAVE_TERMIOS_H
440 tcsetattr (0, TCSANOW, &oldtty);
441#endif
428}442}
429 443
430static volatile int received_sigterm = 0;444static volatile int received_sigterm = 0;
@@ -439,6 +453,26 @@ sigterm_handler(int sig) · 8 unmodified lines
439 453
440static void term_init(void)454static void term_init(void)
441{455{
456#if HAVE_TERMIOS_H
457 struct termios tty;
458
459 tcgetattr (0, &tty);
460 oldtty = tty;
461 atexit(term_exit);
462
463 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
464 |INLCR|IGNCR|ICRNL|IXON);
465 tty.c_oflag |= OPOST;
466 tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
467 tty.c_cflag &= ~(CSIZE|PARENB);
468 tty.c_cflag |= CS8;
469 tty.c_cc[VMIN] = 1;
470 tty.c_cc[VTIME] = 0;
471
472 tcsetattr (0, TCSANOW, &tty);
473 signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
474#endif
475
442 signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */476 signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
443 signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */477 signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */
444#ifdef SIGXCPU478#ifdef SIGXCPU
@@ -449,7 +483,25 @@ static void term_init(void) · 4 unmodified lines
449/* read a key without blocking */483/* read a key without blocking */
450static int read_key(void)484static int read_key(void)
451{485{
452#if HAVE_KBHIT486#if HAVE_TERMIOS_H
487 int n = 1;
488 unsigned char ch;
489 struct timeval tv;
490 fd_set rfds;
491
492 FD_ZERO(&rfds);
493 FD_SET(0, &rfds);
494 tv.tv_sec = 0;
495 tv.tv_usec = 0;
496 n = select(1, &rfds, NULL, NULL, &tv);
497 if (n > 0) {
498 n = read(0, &ch, 1);
499 if (n == 1)
500 return ch;
501
502 return n;
503 }
504#elif HAVE_KBHIT
453 if(kbhit())505 if(kbhit())
454 return(getch());506 return(getch());
455#endif507#endif
@@ -2467,11 +2519,7 @@ static int transcode(AVFormatContext **output_files, · 2011 unmodified lines
2467 2519
2468 if (!using_stdin) {2520 if (!using_stdin) {
2469 if(verbose >= 0)2521 if(verbose >= 0)
2470#if HAVE_KBHIT
2471 fprintf(stderr, "Press [q] to stop encoding\n");2522 fprintf(stderr, "Press [q] to stop encoding\n");
2472#else
2473 fprintf(stderr, "Press ctrl-c to stop encoding\n");
2474#endif
2475 url_set_interrupt_cb(decode_interrupt_cb);2523 url_set_interrupt_cb(decode_interrupt_cb);
2476 }2524 }
2477 term_init();2525 term_init();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t