aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kodi.xcodeproj/project.pbxproj8
-rw-r--r--project/VS2010Express/XBMC.vcxproj4
-rw-r--r--project/VS2010Express/XBMC.vcxproj.filters8
-rw-r--r--xbmc/filesystem/CMakeLists.txt2
-rw-r--r--xbmc/filesystem/Makefile.in1
-rw-r--r--xbmc/filesystem/MemBufferCache.cpp227
-rw-r--r--xbmc/filesystem/MemBufferCache.h61
7 files changed, 2 insertions, 309 deletions
diff --git a/Kodi.xcodeproj/project.pbxproj b/Kodi.xcodeproj/project.pbxproj
index 556e6bcdf0..ce0e9a740d 100644
--- a/Kodi.xcodeproj/project.pbxproj
+++ b/Kodi.xcodeproj/project.pbxproj
@@ -1154,7 +1154,6 @@
E38E1FFB0D25F9FD00618676 /* DNSNameCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16890D25F9FA00618676 /* DNSNameCache.cpp */; };
E38E1FFC0D25F9FD00618676 /* DynamicDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E168C0D25F9FA00618676 /* DynamicDll.cpp */; };
E38E1FFF0D25F9FD00618676 /* FileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16920D25F9FA00618676 /* FileItem.cpp */; };
- E38E20010D25F9FD00618676 /* MemBufferCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16970D25F9FA00618676 /* MemBufferCache.cpp */; };
E38E20020D25F9FD00618676 /* CacheStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16990D25F9FA00618676 /* CacheStrategy.cpp */; };
E38E20030D25F9FD00618676 /* CDDADirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E169B0D25F9FA00618676 /* CDDADirectory.cpp */; };
E38E20040D25F9FD00618676 /* cddb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E169D0D25F9FA00618676 /* cddb.cpp */; };
@@ -1628,7 +1627,6 @@
E4991276174E5D8F00741B6D /* ISO9660Directory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16F30D25F9FA00618676 /* ISO9660Directory.cpp */; };
E4991277174E5D8F00741B6D /* ISOFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF93D6771444A8B0007C6459 /* ISOFile.cpp */; };
E4991278174E5D8F00741B6D /* LibraryDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1F6EB913ECCFA7001726AB /* LibraryDirectory.cpp */; };
- E4991279174E5D8F00741B6D /* MemBufferCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16970D25F9FA00618676 /* MemBufferCache.cpp */; };
E499127A174E5D8F00741B6D /* MultiPathDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E17080D25F9FA00618676 /* MultiPathDirectory.cpp */; };
E499127B174E5D8F00741B6D /* MultiPathFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F50629780E57B9680066625A /* MultiPathFile.cpp */; };
E499127C174E5D9900741B6D /* DirectoryNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E170B0D25F9FA00618676 /* DirectoryNode.cpp */; };
@@ -4219,8 +4217,6 @@
E38E168D0D25F9FA00618676 /* DynamicDll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicDll.h; sourceTree = "<group>"; };
E38E16920D25F9FA00618676 /* FileItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileItem.cpp; sourceTree = "<group>"; };
E38E16930D25F9FA00618676 /* FileItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileItem.h; sourceTree = "<group>"; };
- E38E16970D25F9FA00618676 /* MemBufferCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemBufferCache.cpp; sourceTree = "<group>"; };
- E38E16980D25F9FA00618676 /* MemBufferCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemBufferCache.h; sourceTree = "<group>"; };
E38E16990D25F9FA00618676 /* CacheStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStrategy.cpp; sourceTree = "<group>"; };
E38E169A0D25F9FA00618676 /* CacheStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStrategy.h; sourceTree = "<group>"; };
E38E169B0D25F9FA00618676 /* CDDADirectory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CDDADirectory.cpp; sourceTree = "<group>"; };
@@ -8247,8 +8243,6 @@
DF93D6781444A8B0007C6459 /* ISOFile.h */,
7C1F6EB913ECCFA7001726AB /* LibraryDirectory.cpp */,
7C1F6EBA13ECCFA7001726AB /* LibraryDirectory.h */,
- E38E16970D25F9FA00618676 /* MemBufferCache.cpp */,
- E38E16980D25F9FA00618676 /* MemBufferCache.h */,
E38E17080D25F9FA00618676 /* MultiPathDirectory.cpp */,
E38E17090D25F9FA00618676 /* MultiPathDirectory.h */,
F50629780E57B9680066625A /* MultiPathFile.cpp */,
@@ -9716,7 +9710,6 @@
EDED2E971C878EF8000F5E80 /* AddonCallbacksAudioDSP.cpp in Sources */,
E38E1FFC0D25F9FD00618676 /* DynamicDll.cpp in Sources */,
E38E1FFF0D25F9FD00618676 /* FileItem.cpp in Sources */,
- E38E20010D25F9FD00618676 /* MemBufferCache.cpp in Sources */,
E38E20020D25F9FD00618676 /* CacheStrategy.cpp in Sources */,
E38E20030D25F9FD00618676 /* CDDADirectory.cpp in Sources */,
E38E20040D25F9FD00618676 /* cddb.cpp in Sources */,
@@ -11023,7 +11016,6 @@
68AE5BE81C92421800C4D527 /* PeripheralAddonTranslator.cpp in Sources */,
E4991277174E5D8F00741B6D /* ISOFile.cpp in Sources */,
E4991278174E5D8F00741B6D /* LibraryDirectory.cpp in Sources */,
- E4991279174E5D8F00741B6D /* MemBufferCache.cpp in Sources */,
E499127A174E5D8F00741B6D /* MultiPathDirectory.cpp in Sources */,
76AEFB3D1C8F79D500EF2EC0 /* AddonCallbacksGUI.cpp in Sources */,
E499127B174E5D8F00741B6D /* MultiPathFile.cpp in Sources */,
diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj
index 780b6029fb..0c88bc4743 100644
--- a/project/VS2010Express/XBMC.vcxproj
+++ b/project/VS2010Express/XBMC.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -402,7 +402,6 @@ copy "..\Win32BuildSetup\dependencies\python27.dll" "$(TargetDir)"</Command>
<ClCompile Include="..\..\xbmc\filesystem\ISO9660Directory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\ISOFile.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\LibraryDirectory.cpp" />
- <ClCompile Include="..\..\xbmc\filesystem\MemBufferCache.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\MultiPathDirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\MultiPathFile.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\MusicDatabaseDirectory.cpp" />
@@ -1399,7 +1398,6 @@ copy "..\Win32BuildSetup\dependencies\python27.dll" "$(TargetDir)"</Command>
<ClInclude Include="..\..\xbmc\filesystem\DirectoryCache.h" />
<ClInclude Include="..\..\xbmc\filesystem\FavouritesDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\FileCache.h" />
- <ClInclude Include="..\..\xbmc\filesystem\MemBufferCache.h" />
<ClInclude Include="..\..\xbmc\filesystem\AddonsDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\BlurayDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\CacheStrategy.h" />
diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters
index 43758b2252..d9458f7a49 100644
--- a/project/VS2010Express/XBMC.vcxproj.filters
+++ b/project/VS2010Express/XBMC.vcxproj.filters
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="win32">
@@ -2091,9 +2091,6 @@
<ClCompile Include="..\..\xbmc\filesystem\FileCache.cpp">
<Filter>filesystem</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\filesystem\MemBufferCache.cpp">
- <Filter>filesystem</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\MediaSource.cpp">
<Filter>utils</Filter>
</ClCompile>
@@ -5242,9 +5239,6 @@
<ClInclude Include="..\..\xbmc\platform\XbmcContext.h">
<Filter>platform</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\filesystem\MemBufferCache.h">
- <Filter>filesystem</Filter>
- </ClInclude>
<ClInclude Include="..\..\xbmc\filesystem\CircularCache.h">
<Filter>filesystem</Filter>
</ClInclude>
diff --git a/xbmc/filesystem/CMakeLists.txt b/xbmc/filesystem/CMakeLists.txt
index 617fd9ae85..da0f782661 100644
--- a/xbmc/filesystem/CMakeLists.txt
+++ b/xbmc/filesystem/CMakeLists.txt
@@ -29,7 +29,6 @@ set(SOURCES AddonsDirectory.cpp
ISO9660Directory.cpp
ISOFile.cpp
LibraryDirectory.cpp
- MemBufferCache.cpp
MultiPathDirectory.cpp
MultiPathFile.cpp
MusicDatabaseDirectory.cpp
@@ -112,7 +111,6 @@ set(HEADERS AddonsDirectory.h
ISOFile.h
iso9660.h
LibraryDirectory.h
- MemBufferCache.h
MultiPathDirectory.h
MultiPathFile.h
MusicDatabaseDirectory.h
diff --git a/xbmc/filesystem/Makefile.in b/xbmc/filesystem/Makefile.in
index 33fb32a570..a137f8fe83 100644
--- a/xbmc/filesystem/Makefile.in
+++ b/xbmc/filesystem/Makefile.in
@@ -31,7 +31,6 @@ SRCS += iso9660.cpp
SRCS += ISO9660Directory.cpp
SRCS += ISOFile.cpp
SRCS += LibraryDirectory.cpp
-SRCS += MemBufferCache.cpp
SRCS += MultiPathDirectory.cpp
SRCS += MultiPathFile.cpp
SRCS += MusicDatabaseDirectory.cpp
diff --git a/xbmc/filesystem/MemBufferCache.cpp b/xbmc/filesystem/MemBufferCache.cpp
deleted file mode 100644
index 264ce044e9..0000000000
--- a/xbmc/filesystem/MemBufferCache.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) 2005-2014 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifdef TARGET_POSIX
-#include "threads/SystemClock.h"
-#include "linux/PlatformDefs.h"
-#endif
-#include "settings/AdvancedSettings.h"
-#include "MemBufferCache.h"
-#include "utils/log.h"
-#include "threads/SingleLock.h"
-
-#include <math.h>
-
-using namespace XFILE;
-
-#define SEEK_CHECK_RET(x) if (!(x)) return -1;
-
-MemBufferCache::MemBufferCache()
- : CCacheStrategy()
-{
- m_nStartPosition = 0;
- m_buffer.Create(g_advancedSettings.m_cacheMemBufferSize + 1);
- m_HistoryBuffer.Create(g_advancedSettings.m_cacheMemBufferSize + 1);
- m_forwardBuffer.Create(g_advancedSettings.m_cacheMemBufferSize + 1);
-}
-
-
-MemBufferCache::~MemBufferCache()
-{
- m_buffer.Destroy();
- m_HistoryBuffer.Destroy();
- m_forwardBuffer.Destroy();
-}
-
-int MemBufferCache::Open()
-{
- m_nStartPosition = 0;
- m_buffer.Clear();
- m_HistoryBuffer.Clear();
- m_forwardBuffer.Clear();
- return CACHE_RC_OK;
-}
-
-void MemBufferCache::Close()
-{
- m_buffer.Clear();
- m_HistoryBuffer.Clear();
- m_forwardBuffer.Clear();
-}
-
-size_t MemBufferCache::GetMaxWriteSize(const size_t& iRequestSize)
-{
- CSingleLock lock(m_sync);
-
- // must also check the forward buffer.
- // if we have leftovers from the previous seek - we need not read anymore until they are utilized
- return (m_forwardBuffer.getMaxReadSize() == 0 && iRequestSize <= m_buffer.getMaxWriteSize()) ? iRequestSize : 0;
-}
-
-int MemBufferCache::WriteToCache(const char *pBuffer, size_t iSize)
-{
- CSingleLock lock(m_sync);
- unsigned int nToWrite = m_buffer.getMaxWriteSize() ;
-
- // must also check the forward buffer.
- // if we have leftovers from the previous seek - we need not read anymore until they are utilized
- if (nToWrite == 0 || m_forwardBuffer.getMaxReadSize() > 0)
- return 0;
-
- if (nToWrite > iSize)
- nToWrite = iSize;
-
- if (!m_buffer.WriteData((char*)pBuffer, nToWrite))
- {
- CLog::Log(LOGWARNING,"%s, failed to write %d bytes to buffer. max buffer size: %d", __FUNCTION__, nToWrite, m_buffer.getMaxWriteSize());
- nToWrite = 0;
- }
-
- m_written.Set();
-
- return nToWrite;
-}
-
-int MemBufferCache::ReadFromCache(char *pBuffer, size_t iMaxSize)
-{
- CSingleLock lock(m_sync);
- if ( m_buffer.getMaxReadSize() == 0 ) {
- return m_bEndOfInput ? 0 : CACHE_RC_WOULD_BLOCK;
- }
-
- int nRead = iMaxSize;
- if ((size_t) m_buffer.getMaxReadSize() < iMaxSize)
- nRead = m_buffer.getMaxReadSize();
-
- if (nRead > 0)
- {
- if (!m_buffer.ReadData(pBuffer, nRead))
- {
- CLog::Log(LOGWARNING, "%s, failed to read %d bytes from buffer. max read size: %d", __FUNCTION__, nRead, m_buffer.getMaxReadSize());
- return 0;
- }
-
- // copy to history so we can seek back
- if ((int) m_HistoryBuffer.getMaxWriteSize() < nRead)
- m_HistoryBuffer.SkipBytes(nRead);
- m_HistoryBuffer.WriteData(pBuffer, nRead);
-
- m_nStartPosition += nRead;
- }
-
- // check forward buffer and copy it when enough space is available
- if (m_forwardBuffer.getMaxReadSize() > 0 && m_buffer.getMaxWriteSize() >= m_forwardBuffer.getMaxReadSize())
- {
- m_buffer.Append(m_forwardBuffer);
- m_forwardBuffer.Clear();
- }
-
- if (nRead > 0)
- m_space.Set();
-
- return nRead;
-}
-
-int64_t MemBufferCache::WaitForData(unsigned int iMinAvail, unsigned int millis)
-{
- if (millis == 0 || IsEndOfInput())
- return m_buffer.getMaxReadSize();
-
- XbmcThreads::EndTime endTime(millis);
- while (!IsEndOfInput() && (unsigned int) m_buffer.getMaxReadSize() < iMinAvail && !endTime.IsTimePast() )
- m_written.WaitMSec(50); // may miss the deadline. shouldn't be a problem.
-
- return m_buffer.getMaxReadSize();
-}
-
-int64_t MemBufferCache::Seek(int64_t iFilePosition)
-{
- CSingleLock lock(m_sync);
-
- // if seek is a bit over what we have, try to wait a few seconds for the data to be available.
- // we try to avoid a (heavy) seek on the source
- if (iFilePosition > m_nStartPosition + m_buffer.getMaxReadSize() &&
- iFilePosition < m_nStartPosition + m_buffer.getMaxReadSize() + 100000)
- {
- int nRequired = (int)(iFilePosition - (m_nStartPosition + m_buffer.getMaxReadSize()));
- lock.Leave();
- WaitForData(nRequired + 1, 5000);
- lock.Enter();
- }
-
- // check if seek is inside the current buffer
- if (iFilePosition >= m_nStartPosition && iFilePosition < m_nStartPosition + m_buffer.getMaxReadSize())
- {
- unsigned int nOffset = (unsigned int)(iFilePosition - m_nStartPosition);
- // copy to history so we can seek back
- if (m_HistoryBuffer.getMaxWriteSize() < nOffset)
- m_HistoryBuffer.SkipBytes(nOffset);
-
- if (!m_buffer.ReadData(m_HistoryBuffer, nOffset))
- {
- CLog::Log(LOGERROR, "%s, failed to copy %d bytes to history", __FUNCTION__, nOffset);
- }
-
- m_nStartPosition = iFilePosition;
- m_space.Set();
- return m_nStartPosition;
- }
-
- int64_t iHistoryStart = m_nStartPosition - m_HistoryBuffer.getMaxReadSize();
- if (iFilePosition < m_nStartPosition && iFilePosition >= iHistoryStart)
- {
- CRingBuffer saveHist, saveUnRead;
- int64_t nToSkip = iFilePosition - iHistoryStart;
- SEEK_CHECK_RET(m_HistoryBuffer.ReadData(saveHist, (int)nToSkip));
-
- SEEK_CHECK_RET(saveUnRead.Copy(m_buffer));
-
- SEEK_CHECK_RET(m_buffer.Copy(m_HistoryBuffer));
- int nSpace = m_buffer.getMaxWriteSize();
- int nToCopy = saveUnRead.getMaxReadSize();
-
- if (nToCopy < nSpace)
- nSpace = nToCopy;
-
- SEEK_CHECK_RET(saveUnRead.ReadData(m_buffer, nSpace));
- nToCopy -= nSpace;
- if (nToCopy > 0)
- m_forwardBuffer.Copy(saveUnRead);
-
- m_nStartPosition = iFilePosition;
- m_space.Set();
- return m_nStartPosition;
- }
-
- // seek outside the buffer. return error.
- return CACHE_RC_ERROR;
-}
-
-bool MemBufferCache::Reset(int64_t iSourcePosition, bool clearAnyway)
-{
- CSingleLock lock(m_sync);
- m_nStartPosition = iSourcePosition;
- m_buffer.Clear();
- m_HistoryBuffer.Clear();
- m_forwardBuffer.Clear();
- return true;
-}
-
-
diff --git a/xbmc/filesystem/MemBufferCache.h b/xbmc/filesystem/MemBufferCache.h
deleted file mode 100644
index 7083b2d6d5..0000000000
--- a/xbmc/filesystem/MemBufferCache.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2005-2014 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef MemBufferCache_H
-#define MemBufferCache_H
-
-#include "CacheStrategy.h"
-#include "threads/CriticalSection.h"
-#include "threads/Event.h"
-#include "utils/RingBuffer.h"
-
-/**
- @author Team XBMC
-*/
-namespace XFILE {
-
-class MemBufferCache : public CCacheStrategy
-{
-public:
- MemBufferCache();
- virtual ~MemBufferCache();
-
- virtual int Open() ;
- virtual void Close();
-
- virtual size_t GetMaxWriteSize(const size_t& iRequestSize) ;
- virtual int WriteToCache(const char *pBuffer, size_t iSize) ;
- virtual int ReadFromCache(char *pBuffer, size_t iMaxSize) ;
- virtual int64_t WaitForData(unsigned int iMinAvail, unsigned int iMillis) ;
-
- virtual int64_t Seek(int64_t iFilePosition) ;
- virtual bool Reset(int64_t iSourcePosition, bool clearAnyway) ;
-
-protected:
- int64_t m_nStartPosition;
- CRingBuffer m_buffer;
- CRingBuffer m_HistoryBuffer;
- CRingBuffer m_forwardBuffer; // for seek cases, to store data already read
- CCriticalSection m_sync;
- CEvent m_written;
-};
-
-} // namespace XFILE
-#endif