changed: Move read cache logic from DVDPlayer to CFile
authorarnova <arnova@void.org>
Wed, 16 Oct 2013 11:13:02 +0000 (13:13 +0200)
committerarnova <arnova@void.org>
Wed, 23 Oct 2013 13:50:15 +0000 (15:50 +0200)
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamFile.cpp
xbmc/filesystem/File.cpp

index 2e88e97..6c05ece 100644 (file)
@@ -54,29 +54,8 @@ bool CDVDInputStreamFile::Open(const char* strFile, const std::string& content)
 
   unsigned int flags = READ_TRUNCATED | READ_BITRATE | READ_CHUNKED;
 
-  /* 
-   * There are 4 buffer modes available (configurable in as.xml)
-   * 0) Buffer all internet filesystems (like 2 but additionally also ftp, webdav, etc.) (default)
-   * 1) Buffer all filesystems (including local)
-   * 2) Only buffer true internet filesystems (streams) (http, etc.)
-   * 3) No buffer
-   */
-
-  if (g_advancedSettings.m_networkBufferMode == 3)
-  {
-    flags |= READ_NO_CACHE;
-  }
-  else if (g_advancedSettings.m_networkBufferMode == 0 || g_advancedSettings.m_networkBufferMode == 2)
-  {
-    if (URIUtils::IsInternetStream(CURL(strFile), (g_advancedSettings.m_networkBufferMode == 0) ) )
-      flags |= READ_CACHED;
-    else
-      flags |= READ_NO_CACHE;
-  }
-  else if (!URIUtils::IsOnDVD(strFile) && !URIUtils::IsBluray(strFile))
-  {
-    flags |= READ_CACHED; // Force cache for all others (in buffer mode 3)
-  }
+  if (URIUtils::IsOnDVD(strFile) || URIUtils::IsBluray(strFile))
+    flags |= READ_NO_CACHE; // Never cache these
 
   if (content == "video/mp4" || content == "video/x-msvideo" || content == "video/avi")
     flags |= READ_MULTI_STREAM;
index 7b8d8b5..cb1f839 100644 (file)
@@ -33,6 +33,7 @@
 #include "Util.h"
 #include "URL.h"
 #include "utils/StringUtils.h"
+#include "settings/AdvancedSettings.h"
 
 #include "commons/Exception.h"
 
@@ -229,14 +230,31 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
     }
 
     CURL url(URIUtils::SubstitutePath(strFileName));
-    bool isInternetStream = URIUtils::IsInternetStream(url, true);
-    if ( (flags & READ_NO_CACHE) == 0 && isInternetStream && !CUtil::IsPicture(strFileName) )
-      m_flags |= READ_CACHED;
+
+    /* 
+     * There are 4 buffer modes available (configurable in as.xml)
+     * 0) Buffer all internet filesystems (like 2 but additionally also ftp, webdav, etc.) (default)
+     * 1) Buffer all filesystems (including local)
+     * 2) Only buffer true internet filesystems (streams) (http, etc.)
+     * 3) No buffer
+     */
+    if ( (flags & READ_NO_CACHE) == 0 && !CUtil::IsPicture(strFileName) )
+    {
+      if (g_advancedSettings.m_networkBufferMode == 0 || g_advancedSettings.m_networkBufferMode == 2)
+      {
+        if (URIUtils::IsInternetStream(url, (g_advancedSettings.m_networkBufferMode == 0) ) )
+          flags |= READ_CACHED;
+      }
+      else if (g_advancedSettings.m_networkBufferMode == 1)
+      {
+        flags |= READ_CACHED; // Force cache for all others (in buffer mode 1)
+      }
+    }
 
     if (m_flags & READ_CACHED)
     {
       // for internet stream, if it contains multiple stream, file cache need handle it specially.
-      m_pFile = new CFileCache((m_flags & READ_MULTI_STREAM)!=0 && isInternetStream);
+      m_pFile = new CFileCache((m_flags & READ_MULTI_STREAM) != 0 && URIUtils::IsInternetStream(url, true));
       return m_pFile->Open(url);
     }