2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "CacheStrategy.h"
14 #include "threads/CriticalSection.h"
15 #include "threads/Thread.h"
21 using namespace std::chrono_literals
;
26 class CFileCache
: public IFile
, public CThread
29 explicit CFileCache(const unsigned int flags
);
30 ~CFileCache() override
;
33 void Process() override
;
34 void OnExit() override
;
35 void StopThread(bool bWait
= true) override
;
38 bool Open(const CURL
& url
) override
;
39 void Close() override
;
40 bool Exists(const CURL
& url
) override
;
41 int Stat(const CURL
& url
, struct __stat64
* buffer
) override
;
43 ssize_t
Read(void* lpBuf
, size_t uiBufSize
) override
;
45 int64_t Seek(int64_t iFilePosition
, int iWhence
) override
;
46 int64_t GetPosition() override
;
47 int64_t GetLength() override
;
49 int IoControl(EIoControl request
, void* param
) override
;
53 const std::string
GetProperty(XFILE::FileProperty type
, const std::string
&name
= "") const override
;
55 const std::vector
<std::string
> GetPropertyValues(XFILE::FileProperty type
, const std::string
& name
= "") const override
57 return std::vector
<std::string
>();
61 std::unique_ptr
<CCacheStrategy
> m_pCache
;
62 int m_seekPossible
= 0;
64 std::string m_sourcePath
;
67 int64_t m_nSeekResult
= 0;
68 int64_t m_seekPos
= 0;
69 int64_t m_readPos
= 0;
70 int64_t m_writePos
= 0;
71 unsigned m_chunkSize
= 0;
72 uint32_t m_writeRate
= 0;
73 uint32_t m_writeRateActual
= 0;
74 uint32_t m_writeRateLowSpeed
= 0;
75 int64_t m_forwardCacheSize
= 0;
76 int64_t m_maxForward
= 0;
77 bool m_bFilling
= false;
78 std::atomic
<int64_t> m_fileSize
;
80 CCriticalSection m_sync
;
81 std::chrono::milliseconds m_processWait
{100ms
};