summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-27 23:12:34 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-02-27 23:12:34 +0000
commit490a015043f105f3c80bdbde187166c469f3d63f (patch)
treefb3b05c7f4074b47df08e859eff17aefa3e815d8 /osdep
parent67f9e11d9336028e374b4c03b5632a8e28a54f7d (diff)
downloadmpv-490a015043f105f3c80bdbde187166c469f3d63f.tar.bz2
mpv-490a015043f105f3c80bdbde187166c469f3d63f.tar.xz
Make -slave also work with the normal console on Windows.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30780 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'osdep')
-rw-r--r--osdep/getch2-win.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c
index 45f68e8196..dd6268b06a 100644
--- a/osdep/getch2-win.c
+++ b/osdep/getch2-win.c
@@ -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;
}