+
+ /* The following sequence of events can occur in the above code:
+ 1. a remote worker takes the last image off the queue
+ 2. the loop above terminates
+ 3. the remote worker fails to encode the image and puts it back on the queue
+ 4. the remote worker is then terminated by terminate_worker_threads
+
+ So just mop up anything left in the queue here.
+ */
+
+ for (list<shared_ptr<DCPVideoFrame> >::iterator i = _queue.begin(); i != _queue.end(); ++i) {
+ stringstream s;
+ s << "Encode left-over frame " << (*i)->frame();
+ _log->log (s.str ());
+ try {
+ shared_ptr<EncodedData> e = (*i)->encode_locally ();
+ e->write (_opt, (*i)->frame ());
+ frame_done ();
+ } catch (std::exception& e) {
+ stringstream s;
+ s << "Local encode failed " << e.what() << ".";
+ _log->log (s.str ());
+ }
+ }
+