changeset 30738:25622198a15a

Make -slave also work with the normal console on Windows.
author reimar
date Sat, 27 Feb 2010 23:12:34 +0000
parents 8a9667eccbf7
children 9e7e36fd3ba3
files osdep/getch2-win.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/osdep/getch2-win.c	Sat Feb 27 23:09:15 2010 +0000
+++ b/osdep/getch2-win.c	Sat Feb 27 23:12:34 2010 +0000
@@ -35,11 +35,16 @@
 int mp_input_slave_cmd_func(int fd,char* dest,int size){
   DWORD retval;
   HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
-  if(!PeekNamedPipe(in, NULL, size, &retval, NULL, NULL) || !retval){
+  if(PeekNamedPipe(in, NULL, size, &retval, NULL, NULL)){
+    if (size > retval) size = retval;
+  } else {
+    if (WaitForSingleObject(in, 0))
+      size = 0;
+  }
+  if(!size){
 	  return MP_INPUT_NOTHING;
   }
-  if(retval>size)retval=size;
-  ReadFile(in, dest, retval, &retval, NULL);
+  ReadFile(in, dest, size, &retval, NULL);
   if(retval)return retval;
   return MP_INPUT_NOTHING;
 }