vlc | branch: master | Ilkka Ollakka <[email protected]> | Thu Mar 19 08:52:30 
2015 +0200| [ca1e15692ce9acc2d421c302434efd10eec64d27] | committer: Ilkka 
Ollakka

udp: adjust receive buffer for windows 7 and earlier

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca1e15692ce9acc2d421c302434efd10eec64d27
---

 src/network/udp.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/network/udp.c b/src/network/udp.c
index b2c8a50..d33b13a 100644
--- a/src/network/udp.c
+++ b/src/network/udp.c
@@ -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))
     {

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to