]> git.sesse.net Git - vlc/commitdiff
Win32: wake up select every split tenth of seconds (fix #1949)
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 18 Jan 2009 14:57:47 +0000 (16:57 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 18 Jan 2009 15:01:31 +0000 (17:01 +0200)
src/network/poll.c

index dc1482c8750013d2c8dfadfc40fab83c4aac3e68..553a7e59d72fa1a4dc8142a2d4c10b6a6993ff4e 100644 (file)
@@ -85,6 +85,18 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
             FD_SET (fd, &exset);
     }
 
+#ifndef HAVE_ALERTABLE_SELECT
+# warning FIXME! Fix cancellation and remove this crap.
+resume:
+    vlc_testcancel ();
+
+    if ((timeout < 0) || (timeout > 50))
+    {
+        tv.tv_sec = 0;
+        tv.tv_usec = 50;
+    }
+    else
+#endif
     if (timeout >= 0)
     {
         div_t d = div (timeout, 1000);
@@ -94,6 +106,18 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
 
     val = select (val + 1, &rdset, &wrset, &exset,
                   (timeout >= 0) ? &tv : NULL);
+
+#ifndef HAVE_ALERTABLE_SELECT
+# warning FIXME! Fix cancellation and remove this crap.
+    if (val == 0)
+    {
+        if (timeout > 0)
+            timeout -= (timeout > 50) ? 50 : timeout;
+        if (timeout != 0)
+            goto resume;
+    }
+#endif
+
     if (val == -1)
         return -1;