io: support `mp_make_wakeup_pipe()` on Windows
This PR makes mp_make_wakeup_pipe() work on Windows, as discussed in #14933.
Note: I do not aim to undeprecate the C API, but only to undeprecate the Lua API and make it cross-platform. I do not deny that there are workarounds to achieve the purpose (i.e. custom event loop), but IMO making the existing API cross-platform is simplest and most straighforward.
Sample Lua code for testing (work on both Windows and POSIX):
local uv = require('luv')
local fd = mp.get_wakeup_pipe()
local h = uv.new_pipe(false)
h:open(fd)
h:read_start(function(err)
if err ~= nil then
error(err)
end
print("waken up")
mp.dispatch_events(false)
end)
function _G.mp_event_loop()
while mp.keep_running do
uv.run("once")
end
end
Download the artifacts for this pull request:
Does this commit change anything with the behaviour of named pipes on Windows as before?
Does this commit change anything with the behaviour of named pipes on Windows as before?
I did not get you. This PR uses named pipes to implement mp_make_wakeup_pipe(). mp_make_wakeup_pipe() is not supported on Windows before this PR, so it is certain that there are not existing usages of it on Windows, and this PR cannot cause any breaking changes. This PR is not related to other usages of named pipes besides in mp_make_wakeup_pipe().
Right, I'll better explain myself..
I was referring to this: https://mpv.io/manual/master/#command-prompt-example i.e. using the JSON IPC interface with named pipes on Windows.
But it does not seem that this commit is actually related, from a quick glance.
Edit:
Well, not actually this specific example with command prompt and echo.. the short paragraph below that one, actually.
Right, I'll better explain myself..
I was referring to this: https://mpv.io/manual/master/#command-prompt-example i.e. using the JSON IPC interface with named pipes on Windows.
But it does not seem that this commit is actually related, from a quick glance.
Edit:
Well, not actually this specific example with command prompt and
echo.. the short paragraph below that one, actually.
Yes, this PR has nothing to do with JSON IPC, which does not rely on mp_make_wakeup_pipe().