_picture_asset_writer = _picture_asset->start_write (_first_nonexistant_frame > 0);
- if (_film->audio_channels() > 0) {
+ AudioMapping m (_film->audio_channels ());
+
+ if (m.dcp_channels() > 0) {
_sound_asset.reset (
new libdcp::SoundAsset (
_film->dir (_film->dcp_name()),
"audio.mxf",
DCPFrameRate (_film->frames_per_second()).frames_per_second,
- _film->audio_channels(),
+ m.dcp_channels (),
dcp_audio_sample_rate (_film->audio_stream()->sample_rate())
)
);
_sound_asset_writer = _sound_asset->start_write ();
}
-
+
_thread = new boost::thread (boost::bind (&Writer::thread, this));
}
void
Writer::thread ()
+try
{
while (1)
{
--_queued_full_in_memory;
}
- switch (qi.type) {
- case QueueItem::FULL:
- ++_full_written;
- break;
- case QueueItem::FAKE:
- ++_fake_written;
- break;
- case QueueItem::REPEAT:
- ++_repeat_written;
- break;
- }
-
lock.unlock ();
switch (qi.type) {
case QueueItem::FULL:
libdcp::FrameInfo const fin = _picture_asset_writer->write (qi.encoded->data(), qi.encoded->size());
qi.encoded->write_info (_film, qi.frame, fin);
_last_written = qi.encoded;
+ ++_full_written;
break;
}
case QueueItem::FAKE:
_film->log()->log (String::compose ("Writer FAKE-writes %1 to MXF", qi.frame));
_picture_asset_writer->fake_write (qi.size);
_last_written.reset ();
+ ++_fake_written;
break;
case QueueItem::REPEAT:
{
_film->log()->log (String::compose ("Writer REPEAT-writes %1 to MXF", qi.frame));
libdcp::FrameInfo const fin = _picture_asset_writer->write (_last_written->data(), _last_written->size());
_last_written->write_info (_film, qi.frame, fin);
+ ++_repeat_written;
break;
}
}
--_queued_full_in_memory;
}
}
-
+}
+catch (...)
+{
+ store_current ();
}
void
lock.unlock ();
_thread->join ();
+ if (thrown ()) {
+ rethrow ();
+ }
+
delete _thread;
_thread = 0;
fclose (mxf);
}
-/** @return true if the fake write succeeded, otherwise false */
+/** @param frame Frame index.
+ * @return true if we can fake-write this frame.
+ */
bool
Writer::can_fake_write (int frame) const
{
+ /* We have to do a proper write of the first frame so that we can set up the JPEG2000
+ parameters in the MXF writer.
+ */
return (frame != 0 && frame < _first_nonexistant_frame);
}
-
bool
operator< (QueueItem const & a, QueueItem const & b)
{