Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added: option to enable video buffering optimized for slow networks, …

…when enabled this will do cached reads from the lan, using 50% of free ram as buffer, with 25 mb as lower and 512 as upper limits
  • Loading branch information...
commit 323084f2fb587ca064b44076b1f079fdddd2cc61 1 parent de4cd8d
bobo1on1 authored
View
1  language/English/strings.xml
@@ -1251,6 +1251,7 @@
<string id="13551">Off</string>
<string id="13552">%.1f Second</string>
<string id="13553">%.1f Seconds</string>
+ <string id="13554">Optimize cache for Wi-Fi/HomePlug</string>
<string id="13600">Apple remote</string>
View
7 xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamFile.cpp
@@ -23,6 +23,7 @@
#include "filesystem/File.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
+#include "settings/GUISettings.h"
using namespace XFILE;
@@ -51,8 +52,12 @@ bool CDVDInputStreamFile::Open(const char* strFile, const std::string& content)
if (!m_pFile)
return false;
+ unsigned int flags = READ_TRUNCATED | READ_BITRATE | READ_CHUNKED;
+ if (URIUtils::IsOnLAN(strFile) && g_guiSettings.GetBool("videoplayer.slownetworkcache"))
+ flags |= READ_CACHED | READ_ADAPTIVE_CACHE_SIZE;
+
// open file in binary mode
- if (!m_pFile->Open(strFile, READ_TRUNCATED | READ_BITRATE | READ_CHUNKED))
+ if (!m_pFile->Open(strFile, flags))
{
delete m_pFile;
m_pFile = NULL;
View
2  xbmc/filesystem/File.cpp
@@ -232,7 +232,7 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
if (m_flags & READ_CACHED)
{
- m_pFile = new CFileCache();
+ m_pFile = new CFileCache((m_flags & READ_ADAPTIVE_CACHE_SIZE) != 0);
return m_pFile->Open(url);
}
View
3  xbmc/filesystem/File.h
@@ -60,6 +60,9 @@ class IFileCallback
/* calcuate bitrate for file while reading */
#define READ_BITRATE 0x10
+/* base cache size on amount of free ram */
+#define READ_ADAPTIVE_CACHE_SIZE 0x20
+
class CFileStreamBuffer;
class CFile
View
28 xbmc/filesystem/FileCache.cpp
@@ -19,6 +19,7 @@
*
*/
+#include <limits.h>
#include "threads/SystemClock.h"
#include "utils/AutoPtrHandle.h"
#include "FileCache.h"
@@ -79,7 +80,7 @@ class CWriteRate
};
-CFileCache::CFileCache()
+CFileCache::CFileCache(bool adaptiveSize /*= false*/)
{
m_bDeleteCache = true;
m_nSeekResult = 0;
@@ -87,10 +88,33 @@ CFileCache::CFileCache()
m_readPos = 0;
m_writePos = 0;
if (g_advancedSettings.m_cacheMemBufferSize == 0)
+ {
m_pCache = new CSimpleFileCache();
+ }
else
- m_pCache = new CCircularCache(g_advancedSettings.m_cacheMemBufferSize
+ {
+ unsigned int cachesize;
+ if (adaptiveSize)
+ {
+ //set cache size of 50% of free ram, with m_cacheMemBufferSize as lower limit and m_maxCacheSize as upper
+ MEMORYSTATUSEX stat;
+ stat.dwLength = sizeof(MEMORYSTATUSEX);
+ GlobalMemoryStatusEx(&stat);
+ unsigned int cacheram = std::min(stat.ullAvailPhys / 2, (uint64_t)UINT_MAX);
@Memphiz
Memphiz added a note

ullAvailPhys? Whats that? A typo?

@bobo1on1 Owner

I think it stands for unsigned long long.

@Memphiz
Memphiz added a note

Thought it should stand for fullAvailPhys ;) ... learned something...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ cachesize = std::max(cacheram, g_advancedSettings.m_cacheMemBufferSize);
+ cachesize = std::min(cachesize, g_advancedSettings.m_maxCacheSize);
+
+ CLog::Log(LOGDEBUG,"CFileCache::Open - free ram:%" PRIi64 " MB, cache size set to %i MB",
+ stat.ullAvailPhys / (1024 * 1024), cachesize / (1024 * 1024));
+ }
+ else
+ {
+ cachesize = g_advancedSettings.m_cacheMemBufferSize;
+ }
+ m_pCache = new CCircularCache(cachesize
, std::max<unsigned int>( g_advancedSettings.m_cacheMemBufferSize / 4, 1024 * 1024));
+ }
m_seekPossible = 0;
m_cacheFull = false;
}
View
2  xbmc/filesystem/FileCache.h
@@ -32,7 +32,7 @@ namespace XFILE
class CFileCache : public IFile, public CThread
{
public:
- CFileCache();
+ CFileCache(bool adaptiveSize = false);
CFileCache(CCacheStrategy *pCache, bool bDeleteCache=true);
virtual ~CFileCache();
View
2  xbmc/settings/AdvancedSettings.cpp
@@ -277,6 +277,7 @@ void CAdvancedSettings::Initialize()
m_measureRefreshrate = false;
m_cacheMemBufferSize = 1024 * 1024 * 20;
+ m_maxCacheSize = 512 * 1024 * 1024;
m_jsonOutputCompact = true;
m_jsonTcpPort = 9090;
@@ -646,6 +647,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
XMLUtils::GetInt(pElement, "curlretries", m_curlretries, 0, 10);
XMLUtils::GetBoolean(pElement,"disableipv6", m_curlDisableIPV6);
XMLUtils::GetUInt(pElement, "cachemembuffersize", m_cacheMemBufferSize);
+ XMLUtils::GetUInt(pElement, "maxcachesize", m_maxCacheSize);
}
pElement = pRootElement->FirstChildElement("jsonrpc");
View
1  xbmc/settings/AdvancedSettings.h
@@ -308,6 +308,7 @@ class CAdvancedSettings
int m_guiDirtyRegionNoFlipTimeout;
unsigned int m_cacheMemBufferSize;
+ unsigned int m_maxCacheSize;
bool m_jsonOutputCompact;
unsigned int m_jsonTcpPort;
View
2  xbmc/settings/GUISettings.cpp
@@ -696,6 +696,8 @@ void CGUISettings::Initialize()
#endif
AddSeparator(vp, "videoplayer.sep5");
AddBool(vp, "videoplayer.teletextenabled", 23050, true);
+ AddSeparator(vp, "videoplayer.sep6");
+ AddBool(vp, "videoplayer.slownetworkcache", 13554, false);
CSettingsCategory* vid = AddCategory(5, "myvideos", 14081);
Please sign in to comment.
Something went wrong with that request. Please try again.