Try to centralise .pot building.
[dcpomatic.git] / src / lib / encoder.cc
index 0c810d12c6aaf88a65e8782d9e0d389e2c4581cc..f252563792374bbac363be6af999e55f5d08f716 100644 (file)
@@ -140,7 +140,7 @@ Encoder::process_end ()
                        }
 
                        out->set_frames (frames);
-                       _writer->write (out);
+                       write_audio (out);
                }
 
                swr_free (&_swr_context);
@@ -251,6 +251,10 @@ Encoder::process_video (shared_ptr<Image> image, bool same, boost::shared_ptr<Su
                return;
        }
 
+       if (_writer->thrown ()) {
+               _writer->rethrow ();
+       }
+
        if (_writer->can_fake_write (_video_frames_out)) {
                _writer->fake_write (_video_frames_out);
                _have_a_real_frame = false;
@@ -315,23 +319,7 @@ Encoder::process_audio (shared_ptr<AudioBuffers> data)
        }
 #endif
 
-       if (_film->audio_channels() == 1) {
-               /* We need to switch things around so that the mono channel is on
-                  the centre channel of a 5.1 set (with other channels silent).
-               */
-
-               shared_ptr<AudioBuffers> b (new AudioBuffers (6, data->frames ()));
-               b->make_silent (libdcp::LEFT);
-               b->make_silent (libdcp::RIGHT);
-               memcpy (b->data()[libdcp::CENTRE], data->data()[0], data->frames() * sizeof(float));
-               b->make_silent (libdcp::LFE);
-               b->make_silent (libdcp::LS);
-               b->make_silent (libdcp::RS);
-
-               data = b;
-       }
-
-       _writer->write (data);
+       write_audio (data);
 }
 
 void
@@ -431,3 +419,25 @@ Encoder::encoder_thread (ServerDescription* server)
                _condition.notify_all ();
        }
 }
+
+void
+Encoder::write_audio (shared_ptr<const AudioBuffers> data)
+{
+       if (_film->audio_channels() == 1) {
+               /* We need to switch things around so that the mono channel is on
+                  the centre channel of a 5.1 set (with other channels silent).
+               */
+
+               shared_ptr<AudioBuffers> b (new AudioBuffers (6, data->frames ()));
+               b->make_silent (libdcp::LEFT);
+               b->make_silent (libdcp::RIGHT);
+               memcpy (b->data()[libdcp::CENTRE], data->data()[0], data->frames() * sizeof(float));
+               b->make_silent (libdcp::LFE);
+               b->make_silent (libdcp::LS);
+               b->make_silent (libdcp::RS);
+
+               data = b;
+       }
+
+       _writer->write (data);
+}