From d80c4704e230bc1dc3e31fd4426c082399d10cf0 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 17 Nov 2012 15:12:23 +0100 Subject: [PATCH] Add auto TCP window size --- command.cc | 2 +- defines.h | 12 ++++++++---- vdr.cc | 2 +- vopts.cc | 19 ++++++++++--------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/command.cc b/command.cc index 463d2ec..32616e5 100644 --- a/command.cc +++ b/command.cc @@ -958,7 +958,7 @@ void Command::doJustConnected(VConnect* vconnect) else { logger->log("Command", Log::INFO, "TCP window size not found, setting 2048"); - vdr->setReceiveWindow(2048); // Default + if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default } config = vdr->configLoad("Advanced", "Disable WOL"); diff --git a/defines.h b/defines.h index ae606a6..4ed4f15 100644 --- a/defines.h +++ b/defines.h @@ -50,7 +50,8 @@ long long getTimeMS(); /* #define STRTOULL _strtoui64 */ #define STRTOUL strtoul #define CLOSESOCKET closesocket - #define DEFAULT_TCP_WINDOWSIZENR 1 /*=2048*/ + #define DEFAULT_TCP_WINDOWSIZE 2048 + #define DEFAULT_TCP_WINDOWSIZENR 2 /*=2048*/ #define PLAYER_MAX_STREAMING_BUFFERS 120 // for video in uints of 50000 KB #define VOMP_HAS_EXIT @@ -112,7 +113,8 @@ long long getTimeMS(); //#define VPE_LIBAV_SUPPORT // #define VPE_LIBAV_MPEG2_TRANSCODING - #define DEFAULT_TCP_WINDOWSIZENR 6 /*=2048*/ + #define DEFAULT_TCP_WINDOWSIZE 0 + #define DEFAULT_TCP_WINDOWSIZENR 0 /*=2048*/ #define PLAYER_MAX_STREAMING_BUFFERS 120 // for video in uints of 50000 KB #define TV_NORM_SWITCHABLE #define HANDLE_VT_SWITCHING @@ -130,7 +132,8 @@ long long getTimeMS(); #define Audio_TYPE AudioMVP #define Video_TYPE VideoMVP #define Surface_TYPE SurfaceMVP //deprecated - #define DEFAULT_TCP_WINDOWSIZENR 1 /*=2048*/ + #define DEFAULT_TCP_WINDOWSIZE 2048 /*=2048*/ + #define DEFAULT_TCP_WINDOWSIZENR 2 /*=2048*/ #define PLAYER_MAX_STREAMING_BUFFERS 11 // for video in uints of 50000 KB #define PAL_WSS #define MVP_REMOTE_TYPES @@ -149,7 +152,8 @@ long long getTimeMS(); #define Audio_TYPE AudioNMT #define Video_TYPE VideoNMT #define Surface_TYPE SurfaceDirectFB //deprecated - #define DEFAULT_TCP_WINDOWSIZENR 1 /*=2048*/ + #define DEFAULT_TCP_WINDOWSIZE 2048 + #define DEFAULT_TCP_WINDOWSIZENR 2 /*=2048*/ #define PLAYER_MAX_STREAMING_BUFFERS 11 // for video in uints of 50000 KB #define VOMP_LINUX_CLOCK CLOCK_REALTIME diff --git a/vdr.cc b/vdr.cc index 33ed8ec..f16b481 100644 --- a/vdr.cc +++ b/vdr.cc @@ -265,7 +265,7 @@ void VDR::disconnect() void VDR::setReceiveWindow(size_t size) { - if (connected) tcp->setReceiveWindow(size); + if (connected && size) tcp->setReceiveWindow(size); } /////////////////////////////////////////////////////// diff --git a/vopts.cc b/vopts.cc index 20a18f3..d4ab0b3 100644 --- a/vopts.cc +++ b/vopts.cc @@ -68,7 +68,7 @@ VOpts::VOpts() static const char* options7[] = {"All", "FTA only"}; static const char* options15[] = {"Alphabetical", "Chronological"}; - static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"}; + static const char* options13[] = {"Auto","1024", "2048", "4096", "8192", "16384", "32768", "65536"}; static const char* options14[] = {"No", "Yes"}; // Get list of languages from VDR and construct options table LangCode = VDR::getInstance()->getLanguageList(); @@ -234,7 +234,7 @@ VOpts::VOpts() option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 199, -1, -99, NULL); options.push_back(option); wop->addOptionLine(option); - option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 7, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13); + option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 8, /*1*/DEFAULT_TCP_WINDOWSIZENR, 0, options13); options.push_back(option); wop->addOptionLine(option); #ifdef PAL_WSS @@ -420,13 +420,14 @@ void VOpts::doSave() case 13: { size_t newTCPsize = 2048; - if (options[i]->userSetChoice == 0) newTCPsize = 1024; - else if (options[i]->userSetChoice == 1) newTCPsize = 2048; - else if (options[i]->userSetChoice == 2) newTCPsize = 4096; - else if (options[i]->userSetChoice == 3) newTCPsize = 8192; - else if (options[i]->userSetChoice == 4) newTCPsize = 16384; - else if (options[i]->userSetChoice == 5) newTCPsize = 32768; - else if (options[i]->userSetChoice == 6) newTCPsize = 65536; + if (options[i]->userSetChoice == 0) newTCPsize = 0; //zero means auto + else if (options[i]->userSetChoice == 1) newTCPsize = 1024; + else if (options[i]->userSetChoice == 2) newTCPsize = 2048; + else if (options[i]->userSetChoice == 3) newTCPsize = 4096; + else if (options[i]->userSetChoice == 4) newTCPsize = 8192; + else if (options[i]->userSetChoice == 5) newTCPsize = 16384; + else if (options[i]->userSetChoice == 6) newTCPsize = 32768; + else if (options[i]->userSetChoice == 7) newTCPsize = 65536; Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize); VDR::getInstance()->setReceiveWindow(newTCPsize); break; -- 2.39.5