mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
win32: fix fd://
Windows definitely supports Unix-style fd inheritance. This mostly worked when launched from mpv.exe, though mpv should change the file mode to O_BINARY. When launched from mpv.com, the wrapper must pass the list of handles (stored in the undocumented lpReserved2 and cbReserved2 fields) to the mpv process.
This commit is contained in:
parent
82e81421d7
commit
c19f634e6c
@ -654,9 +654,8 @@ PROTOCOLS
|
|||||||
absolute path.
|
absolute path.
|
||||||
|
|
||||||
``fd://123``
|
``fd://123``
|
||||||
Read data from the given UNIX FD (for example 123). This is similar to
|
Read data from the given file descriptor (for example 123). This is similar
|
||||||
piping data to stdin via ``-``, but can use an arbitrary file descriptor.
|
to piping data to stdin via ``-``, but can use an arbitrary file descriptor.
|
||||||
Will not work correctly on MS Windows.
|
|
||||||
|
|
||||||
``edl://[edl specification as in edl-mpv.rst]``
|
``edl://[edl specification as in edl-mpv.rst]``
|
||||||
Stitch together parts of multiple files and play them.
|
Stitch together parts of multiple files and play them.
|
||||||
|
@ -37,6 +37,7 @@ void cr_perror(const wchar_t *prefix)
|
|||||||
int cr_runproc(wchar_t *name, wchar_t *cmdline)
|
int cr_runproc(wchar_t *name, wchar_t *cmdline)
|
||||||
{
|
{
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
|
STARTUPINFO our_si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
DWORD retval = 1;
|
DWORD retval = 1;
|
||||||
|
|
||||||
@ -47,6 +48,12 @@ int cr_runproc(wchar_t *name, wchar_t *cmdline)
|
|||||||
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
si.dwFlags |= STARTF_USESTDHANDLES;
|
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));
|
ZeroMemory(&pi, sizeof(pi));
|
||||||
|
|
||||||
if (!CreateProcessW(name, cmdline, NULL, NULL, TRUE, 0,
|
if (!CreateProcessW(name, cmdline, NULL, NULL, TRUE, 0,
|
||||||
|
@ -262,9 +262,6 @@ static int open_f(stream_t *stream)
|
|||||||
MP_INFO(stream, "Writing to stdout...\n");
|
MP_INFO(stream, "Writing to stdout...\n");
|
||||||
p->fd = 1;
|
p->fd = 1;
|
||||||
}
|
}
|
||||||
#ifdef __MINGW32__
|
|
||||||
setmode(p->fd, O_BINARY);
|
|
||||||
#endif
|
|
||||||
p->close = false;
|
p->close = false;
|
||||||
} else {
|
} else {
|
||||||
mode_t openmode = S_IRUSR | S_IWUSR;
|
mode_t openmode = S_IRUSR | S_IWUSR;
|
||||||
@ -298,6 +295,10 @@ static int open_f(stream_t *stream)
|
|||||||
p->close = true;
|
p->close = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
setmode(p->fd, O_BINARY);
|
||||||
|
#endif
|
||||||
|
|
||||||
off_t len = lseek(p->fd, 0, SEEK_END);
|
off_t len = lseek(p->fd, 0, SEEK_END);
|
||||||
lseek(p->fd, 0, SEEK_SET);
|
lseek(p->fd, 0, SEEK_SET);
|
||||||
if (len != (off_t)-1) {
|
if (len != (off_t)-1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user