From 6e003ef110717dd3e4ecdb009d33671f7834e024 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 18 Apr 2020 20:42:58 +0200 Subject: 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!) --- src/lib/writer.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/lib/writer.h') 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 _last_written; + /** number of FULL written frames */ int _full_written; /** number of FAKE written frames */ -- cgit v1.2.3