libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
mediaioreadcache.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <promeki/namespace.h>
14#include <promeki/error.h>
15#include <promeki/list.h>
16#include <promeki/mutex.h>
19
20PROMEKI_NAMESPACE_BEGIN
21
22class MediaIOSource;
23
68class MediaIOReadCache {
69 public:
79 explicit MediaIOReadCache(MediaIOSource *source);
80
82 ~MediaIOReadCache();
83
84 MediaIOReadCache(const MediaIOReadCache &) = delete;
85 MediaIOReadCache &operator=(const MediaIOReadCache &) = delete;
86
96 void setDepth(int n);
97
99 int depth() const;
100
108 int count() const;
109
111 bool isEmpty() const;
112
120 bool isHeadReady() const;
121
141 MediaIORequest readFrame();
142
155 size_t cancelAll();
156
170 void pushSyntheticResult(Error err);
171
187 void onCommandCompleted();
188
189 private:
190 MediaIOCommand::Ptr submitOneLocked();
191 bool checkArmedLocked();
192
193 MediaIOSource *_source = nullptr;
194 List<MediaIOCommand::Ptr> _queue;
195 int _depth = 1;
196 bool _headReadyArmed = false;
197 mutable Mutex _mutex;
198};
199
200PROMEKI_NAMESPACE_END
201
202#endif // PROMEKI_ENABLE_PROAV