diff options
-rw-r--r-- | xbmc/filesystem/CacheCircular.cpp | 18 | ||||
-rw-r--r-- | xbmc/filesystem/CacheCircular.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/xbmc/filesystem/CacheCircular.cpp b/xbmc/filesystem/CacheCircular.cpp index 6f656e335c..3e446963c0 100644 --- a/xbmc/filesystem/CacheCircular.cpp +++ b/xbmc/filesystem/CacheCircular.cpp @@ -35,6 +35,9 @@ CCacheCircular::CCacheCircular(size_t front, size_t back) , m_buf(NULL) , m_size(front + back) , m_size_back(back) +#ifdef _WIN32 + , m_handle(INVALID_HANDLE_VALUE) +#endif { } @@ -45,7 +48,16 @@ CCacheCircular::~CCacheCircular() int CCacheCircular::Open() { +#ifdef _WIN32 + m_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, m_size, NULL); + if(m_handle == INVALID_HANDLE_VALUE) + return CACHE_RC_ERROR; + m_buf = (uint8_t*)MapViewOfFile(m_handle, FILE_MAP_ALL_ACCESS, 0, 0, 0); +#else m_buf = new uint8_t[m_size]; +#endif + if(m_buf == 0) + return CACHE_RC_ERROR; m_beg = 0; m_end = 0; m_cur = 0; @@ -54,7 +66,13 @@ int CCacheCircular::Open() int CCacheCircular::Close() { +#ifdef _WIN32 + UnmapViewOfFile(m_buf); + CloseHandle(m_handle); + m_handle = INVALID_HANDLE_VALUE; +#else delete[] m_buf; +#endif m_buf = NULL; return CACHE_RC_OK; } diff --git a/xbmc/filesystem/CacheCircular.h b/xbmc/filesystem/CacheCircular.h index c841552828..b27db704a9 100644 --- a/xbmc/filesystem/CacheCircular.h +++ b/xbmc/filesystem/CacheCircular.h @@ -53,6 +53,9 @@ protected: size_t m_size_back; CCriticalSection m_sync; CEvent m_written; +#ifdef _WIN32 + HANDLE m_handle; +#endif }; } // namespace XFILE |