[MPlayer-cvslog] r34009 - trunk/udp_sync.c

reimar subversion at mplayerhq.hu
Wed Aug 24 20:54:09 CEST 2011


Author: reimar
Date: Wed Aug 24 20:54:08 2011
New Revision: 34009

Log:
Fix udp-slave on Windows: Make sure WSAStartup is called
before networking functions are used and fix inverted
set_blocking behaviour.

Modified:
   trunk/udp_sync.c

Modified: trunk/udp_sync.c
==============================================================================
--- trunk/udp_sync.c	Tue Aug 23 22:04:40 2011	(r34008)
+++ trunk/udp_sync.c	Wed Aug 24 20:54:08 2011	(r34009)
@@ -57,11 +57,23 @@ float udp_seek_threshold = 1.0;   // how
 // how far off is still considered equal
 #define UDP_TIMING_TOLERANCE 0.02
 
+static void startup(void)
+{
+#if HAVE_WINSOCK2_H
+    static int wsa_started;
+    if (!wsa_started) {
+        WSADATA wd;
+        WSAStartup(0x0202, &wd);
+        wsa_started = 1;
+    }
+#endif
+}
+
 static void set_blocking(int fd, int blocking)
 {
     long sock_flags;
 #if HAVE_WINSOCK2_H
-    sock_flags = blocking;
+    sock_flags = !blocking;
     ioctlsocket(fd, FIONBIO, &sock_flags);
 #else
     sock_flags = fcntl(fd, F_GETFL, 0);
@@ -86,6 +98,7 @@ static int get_udp(int blocking, double 
         struct timeval tv = { .tv_sec = 30 };
         struct sockaddr_in servaddr = { 0 };
 
+        startup();
         sockfd = socket(AF_INET, SOCK_DGRAM, 0);
         if (sockfd == -1)
             return -1;
@@ -133,6 +146,7 @@ void send_udp(const char *send_to_ip, in
         static const int one = 1;
         int ip_valid = 0;
 
+        startup();
         sockfd = socket(AF_INET, SOCK_DGRAM, 0);
         if (sockfd == -1)
             exit_player(EXIT_ERROR);


More information about the MPlayer-cvslog mailing list