mirror of
https://github.com/videolan/vlc.git
synced 2024-11-27 03:47:46 +08:00
compat: poll: work around event loss on WIN32
Signed-off-by: Steve Lhomme <robux4@videolabs.io>
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit 3e0d833a3f
)
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
This commit is contained in:
parent
7e6f3f45de
commit
776c8d73fb
@ -109,7 +109,7 @@ int (poll) (struct pollfd *fds, unsigned nfds, int timeout)
|
||||
# include <windows.h>
|
||||
# include <winsock2.h>
|
||||
|
||||
int poll(struct pollfd *fds, unsigned nfds, int timeout)
|
||||
static int poll_compat(struct pollfd *fds, unsigned nfds, int timeout)
|
||||
{
|
||||
DWORD to = (timeout >= 0) ? (DWORD)timeout : INFINITE;
|
||||
|
||||
@ -251,4 +251,21 @@ int poll(struct pollfd *fds, unsigned nfds, int timeout)
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int poll(struct pollfd *fds, unsigned nfds, int timeout)
|
||||
{
|
||||
if (timeout == -1)
|
||||
{
|
||||
/* HACK: In some cases, we lose some events because events are
|
||||
* destroyed and recreated only when we need to poll. In order to work
|
||||
* arround this issue, we try to call the poll compat function every
|
||||
* 100ms (in case of infinite timeout). */
|
||||
int ret;
|
||||
while ((ret = poll_compat(fds, nfds, 100)) == 0);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return poll_compat(fds, nfds, timeout);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user