]> git.sesse.net Git - vlc/commitdiff
udp: adjust receive buffer for windows 7 and earlier
authorIlkka Ollakka <ileoo@videolan.org>
Thu, 19 Mar 2015 06:52:30 +0000 (08:52 +0200)
committerIlkka Ollakka <ileoo@videolan.org>
Fri, 20 Mar 2015 14:10:22 +0000 (16:10 +0200)
Try to detect runtime what windows version it is running to see if
receive buffers should be increased or leave to OS handling.
Fixes #14200

src/network/udp.c

index b2c8a501ad30bbf4197705cfa199ca31bd5e1566..d33b13a11f0c5d2498e68b60a114f3a15a2fabb6 100644 (file)
@@ -97,6 +97,23 @@ static int net_SetupDgramSocket (vlc_object_t *p_obj, int fd,
 #endif
 
 #if defined (_WIN32)
+
+    /* Check windows version so we know if we need to increase receive buffers
+     * for Windows 7 and earlier
+
+     * SetSocketMediaStreamingMode is present in win 8 and later, so we set
+     * receive buffer if that isn't present
+     */
+    HINSTANCE h_Network = LoadLibraryW(L"Windows.Networking.dll");
+    if( (h_Network == NULL) ||
+        (GetProcAddress( h_Network, "SetSocketMediaStreamingMode" ) == NULL ) )
+    {
+        setsockopt (fd, SOL_SOCKET, SO_RCVBUF,
+                         (void *)&(int){ 0x80000 }, sizeof (int));
+    }
+    if( h_Network )
+        FreeLibrary( h_Network );
+
     if (net_SockAddrIsMulticast (ptr->ai_addr, ptr->ai_addrlen)
      && (sizeof (struct sockaddr_storage) >= ptr->ai_addrlen))
     {