summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-05-09 22:59:07 +0100
committerCarl Hetherington <cth@carlh.net>2015-05-09 22:59:07 +0100
commit8d20417855c563afa08bda167ccf8ab8609208fa (patch)
tree24489cd8d7061a282964c52a8d63c6265c190f4d /src/lib
parent60b505349fcc21cfc8bbed0de75b21755d520038 (diff)
Apply a modified version of 7c76bbb0c989cb5e5e552f28668a985243438cab
from master; when we push an encoded frame's data to disk because we can't write it yet, the idea i to set encoded in the QueueItem to 0 to say that the data has already been pushed to disk. This was not working because we were resetting encoded in a copy of the QueueItem, and hence not affecting the QueueItem held in _queue. This meant that the same frame could be pushed to disk several times. Use the iterator instead of a copy so that the QueueItem in the list is modified.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/writer.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 31c265e2f..1a11a482b 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -366,21 +366,24 @@ try
}
DCPOMATIC_ASSERT (i != _queue.rend());
- QueueItem qi = *i;
-
++_pushed_to_disk;
-
lock.unlock ();
+ /* i is valid here, even though we don't hold a lock on the mutex,
+ since list iterators are unaffected by insertion and only this
+ thread could erase the last item in the list.
+ */
+
LOG_GENERAL (
"Writer full (awaiting %1 [last eye was %2]); pushes %3 to disk",
_last_written_frame + 1,
- _last_written_eyes, qi.frame
+ _last_written_eyes, i->frame
);
- qi.encoded->write (_film, qi.frame, qi.eyes);
+ i->encoded->write (_film, i->frame, i->eyes);
+
lock.lock ();
- qi.encoded.reset ();
+ i->encoded.reset ();
--_queued_full_in_memory;
}