diff options
-rw-r--r-- | DOCS/man/mpv.rst | 5 | ||||
-rw-r--r-- | osdep/win32-console-wrapper.c | 7 | ||||
-rw-r--r-- | stream/stream_file.c | 7 |
3 files changed, 13 insertions, 6 deletions
diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst index 3d76a266f0..be55c167f7 100644 --- a/DOCS/man/mpv.rst +++ b/DOCS/man/mpv.rst @@ -654,9 +654,8 @@ PROTOCOLS absolute path. ``fd://123`` - Read data from the given UNIX FD (for example 123). This is similar to - piping data to stdin via ``-``, but can use an arbitrary file descriptor. - Will not work correctly on MS Windows. + Read data from the given file descriptor (for example 123). This is similar + to piping data to stdin via ``-``, but can use an arbitrary file descriptor. ``edl://[edl specification as in edl-mpv.rst]`` Stitch together parts of multiple files and play them. diff --git a/osdep/win32-console-wrapper.c b/osdep/win32-console-wrapper.c index 8cebcf8c83..778d699161 100644 --- a/osdep/win32-console-wrapper.c +++ b/osdep/win32-console-wrapper.c @@ -37,6 +37,7 @@ void cr_perror(const wchar_t *prefix) int cr_runproc(wchar_t *name, wchar_t *cmdline) { STARTUPINFO si; + STARTUPINFO our_si; PROCESS_INFORMATION pi; DWORD retval = 1; @@ -47,6 +48,12 @@ int cr_runproc(wchar_t *name, wchar_t *cmdline) si.hStdError = GetStdHandle(STD_ERROR_HANDLE); si.dwFlags |= STARTF_USESTDHANDLES; + // Copy the list of inherited CRT file descriptors to the new process + our_si.cb = sizeof(our_si); + GetStartupInfo(&our_si); + si.lpReserved2 = our_si.lpReserved2; + si.cbReserved2 = our_si.cbReserved2; + ZeroMemory(&pi, sizeof(pi)); if (!CreateProcessW(name, cmdline, NULL, NULL, TRUE, 0, diff --git a/stream/stream_file.c b/stream/stream_file.c index 527261edd7..ce9f9d9739 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -262,9 +262,6 @@ static int open_f(stream_t *stream) MP_INFO(stream, "Writing to stdout...\n"); p->fd = 1; } -#ifdef __MINGW32__ - setmode(p->fd, O_BINARY); -#endif p->close = false; } else { mode_t openmode = S_IRUSR | S_IWUSR; @@ -298,6 +295,10 @@ static int open_f(stream_t *stream) p->close = true; } +#ifdef __MINGW32__ + setmode(p->fd, O_BINARY); +#endif + off_t len = lseek(p->fd, 0, SEEK_END); lseek(p->fd, 0, SEEK_SET); if (len != (off_t)-1) { |