diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-04-18 20:42:58 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-04-19 00:57:23 +0200 |
| commit | 6e003ef110717dd3e4ecdb009d33671f7834e024 (patch) | |
| tree | 575c073e8a06bd20cf9fd5d99aab9db3164e75cd /src/lib/writer.h | |
| parent | be4082c68004d56ad7f14b7b9cddef640118dd62 (diff) | |
Add _last_written to Writer, containing the last written frame and eyes
to each reel. This is updated when things are popped off the queue, with
_state_mutex_held, and used in preference to the ones in ReelWriter
which were previously being updated during the time the _state_mutex
lock is unlocked in the body of Writer::thread(). This was not
thread safe (thanks, valgrind!)
Diffstat (limited to 'src/lib/writer.h')
| -rw-r--r-- | src/lib/writer.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/writer.h b/src/lib/writer.h index d304133dc..d09b06264 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -151,6 +151,30 @@ private: int _maximum_frames_in_memory; unsigned int _maximum_queue_size; + class LastWritten + { + public: + LastWritten() + : _frame(-1) + , _eyes(EYES_RIGHT) + {} + + /** @return true if qi is the next item after this one */ + bool next (QueueItem qi) const; + void update (QueueItem qi); + + int frame () const { + return _frame; + } + + private: + int _frame; + Eyes _eyes; + }; + + /** The last frame written to each reel */ + std::vector<LastWritten> _last_written; + /** number of FULL written frames */ int _full_written; /** number of FAKE written frames */ |
