浏览代码

obs-outputs: Set a fixed size socket buffer on Windows 7

Auto tuning apparently doesn't work very well on this version and
af6844f5c24d77ca7b4b1bcc000504d8e693a563 caused throughput
regressions.
Richard Stanway 3 年之前
父节点
当前提交
bfcc066099
共有 1 个文件被更改,包括 21 次插入0 次删除
  1. 21 0
      plugins/obs-outputs/rtmp-stream.c

+ 21 - 0
plugins/obs-outputs/rtmp-stream.c

@@ -16,6 +16,9 @@
 ******************************************************************************/
 ******************************************************************************/
 
 
 #include "rtmp-stream.h"
 #include "rtmp-stream.h"
+#ifdef _WIN32
+#include <util/windows/win-version.h>
+#endif
 
 
 #ifndef SEC_TO_NSEC
 #ifndef SEC_TO_NSEC
 #define SEC_TO_NSEC 1000000000ULL
 #define SEC_TO_NSEC 1000000000ULL
@@ -605,6 +608,24 @@ static void *send_thread(void *data)
 	os_set_thread_name("rtmp-stream: send_thread");
 	os_set_thread_name("rtmp-stream: send_thread");
 
 
 #if defined(_WIN32)
 #if defined(_WIN32)
+	// Despite MSDN claiming otherwise, send buffer auto tuning on
+	// Windows 7 doesn't seem to work very well.
+	if (get_win_ver_int() == 0x601) {
+		DWORD cur_sendbuf_size;
+		DWORD desired_sendbuf_size = 524288;
+		socklen_t int_size = sizeof(int);
+
+		if (!getsockopt(stream->rtmp.m_sb.sb_socket, SOL_SOCKET,
+				SO_SNDBUF, (char *)&cur_sendbuf_size,
+				&int_size) &&
+		    cur_sendbuf_size < desired_sendbuf_size) {
+
+			setsockopt(stream->rtmp.m_sb.sb_socket, SOL_SOCKET,
+				   SO_SNDBUF, (char *)&desired_sendbuf_size,
+				   sizeof(desired_sendbuf_size));
+		}
+	}
+
 	log_sndbuf_size(stream);
 	log_sndbuf_size(stream);
 #endif
 #endif