History

ffmpeg: fix reading from stdin on windows

Based on code by Rolf Siegrist Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer committed 15 years ago

Commit ca4d71b1 parent 31dfc492 files · +29 −1Browse files

Unified · Split

2 files
  1. configure +2 −0
  2. ffmpeg.c +27 −1
configure+2−0
@@ -1101,6 +1101,7 @@ HAVE_LIST=" · 1100 unmodified lines
1101 memalign1101 memalign
1102 mkstemp1102 mkstemp
1103 mmap1103 mmap
1104 PeekNamedPipe
1104 posix_memalign1105 posix_memalign
1105 round1106 round
1106 roundf1107 roundf
@@ -2842,6 +2843,7 @@ check_func strerror_r · 1735 unmodified lines
2842check_func strptime2843check_func strptime
2843check_func strtok_r2844check_func strtok_r
2844check_func_headers conio.h kbhit2845check_func_headers conio.h kbhit
2846check_func_headers windows.h PeekNamedPipe
2845check_func_headers io.h setmode2847check_func_headers io.h setmode
2846check_func_headers lzo/lzo1x.h lzo1x_999_compress2848check_func_headers lzo/lzo1x.h lzo1x_999_compress
2847check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi2849check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
ffmpeg.c+27−1
@@ -487,9 +487,9 @@ static void term_init(void) · 486 unmodified lines
487/* read a key without blocking */487/* read a key without blocking */
488static int read_key(void)488static int read_key(void)
489{489{
490 unsigned char ch;
490#if HAVE_TERMIOS_H491#if HAVE_TERMIOS_H
491 int n = 1;492 int n = 1;
492 unsigned char ch;
493 struct timeval tv;493 struct timeval tv;
494 fd_set rfds;494 fd_set rfds;
495 495
@@ -509,6 +509,32 @@ static int read_key(void) · 13 unmodified lines
509 return n;509 return n;
510 }510 }
511#elif HAVE_KBHIT511#elif HAVE_KBHIT
512# if HAVE_PEEKNAMEDPIPE
513 static int is_pipe;
514 static HANDLE input_handle;
515 DWORD dw, nchars;
516 if(!input_handle){
517 input_handle = GetStdHandle(STD_INPUT_HANDLE);
518 is_pipe = !GetConsoleMode(input_handle, &dw);
519 }
520
521 if (stdin->_cnt > 0) {
522 read(0, &ch, 1);
523 return ch;
524 }
525 if (is_pipe) {
526 /* When running under a GUI, you will end here. */
527 if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL))
528 return -1;
529 //Read it
530 if(nchars != 0) {
531 read(0, &ch, 1);
532 return ch;
533 }else{
534 return -1;
535 }
536 }
537# endif
512 if(kbhit())538 if(kbhit())
513 return(getch());539 return(getch());
514#endif540#endif

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