[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / filesystem / CircularCache.h
blob21d3e6b10b6a843b9c314883199c30a06ffec2d3
1 /*
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.
7 */
9 #pragma once
11 #include "CacheStrategy.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/Event.h"
15 namespace XFILE {
17 class CCircularCache : public CCacheStrategy
19 public:
20 CCircularCache(size_t front, size_t back);
21 ~CCircularCache() override;
23 int Open() override;
24 void Close() override;
26 size_t GetMaxWriteSize(const size_t& iRequestSize) override;
27 int WriteToCache(const char *buf, size_t len) override;
28 int ReadFromCache(char *buf, size_t len) override;
29 int64_t WaitForData(uint32_t minimum, std::chrono::milliseconds timeout) override;
31 int64_t Seek(int64_t pos) override;
32 bool Reset(int64_t pos) override;
34 int64_t CachedDataEndPosIfSeekTo(int64_t iFilePosition) override;
35 int64_t CachedDataStartPos() override;
36 int64_t CachedDataEndPos() override;
37 bool IsCachedPosition(int64_t iFilePosition) override;
39 CCacheStrategy *CreateNew() override;
40 protected:
41 int64_t m_beg; /**< index in file (not buffer) of beginning of valid data */
42 int64_t m_end; /**< index in file (not buffer) of end of valid data */
43 int64_t m_cur; /**< current reading index in file */
44 uint8_t *m_buf; /**< buffer holding data */
45 size_t m_size; /**< size of data buffer used (m_buf) */
46 size_t m_size_back; /**< guaranteed size of back buffer (actual size can be smaller, or larger if front buffer doesn't need it) */
47 CCriticalSection m_sync;
48 CEvent m_written;
49 #ifdef TARGET_WINDOWS
50 HANDLE m_handle;
51 #endif
54 } // namespace XFILE