- while (_write_queue.size() < _maximum_frames_in_memory && !_pending.empty()) {
- /* We have some space in memory. Fetch some frames back off disk. */
-
- _pending.sort ();
- int const fetch = _pending.front ();
-
- lock.unlock ();
- _film->log()->log (String::compose ("Writer pulls %1 back from disk", fetch));
- shared_ptr<EncodedData> encoded;
- if (boost::filesystem::exists (_film->frame_out_path (fetch, false))) {
- /* It's an actual frame (not a repeat-last); load it in */
- encoded.reset (new EncodedData (_film->frame_out_path (fetch, false)));
- }
- lock.lock ();
-
- _write_queue.push_back (make_pair (encoded, fetch));
- _pending.remove (fetch);
- }