Write a 7.1 channel assignment into SMPTE DCP audio MXFs.
[dcpomatic.git] / src / lib / reel_writer.cc
index c1ca2abb1cef2ee37ca6ae41e2a34fbe105c5ccb..1f9885e646b99cbc4a94f2e17ba220182cfc0091 100644 (file)
@@ -112,12 +112,18 @@ ReelWriter::ReelWriter (
                        _sound_asset->set_key (_film->key ());
                }
 
+               DCPOMATIC_ASSERT (_film->directory());
+
                /* Write the sound asset into the film directory so that we leave the creation
                   of the DCP directory until the last minute.
                */
                _sound_asset_writer = _sound_asset->start_write (
-                       _film->directory() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary),
-                       _film->interop() ? dcp::INTEROP : dcp::SMPTE
+                       _film->directory().get() / audio_asset_filename (_sound_asset, _reel_index, _reel_count, _content_summary),
+                       _film->interop() ? dcp::INTEROP : dcp::SMPTE,
+                       /* XXX: this could well be wrong, but it's better than nothing; the whole channel assignment
+                          thing needs fixing.
+                       */
+                       dcp::CHANNEL_ASSIGNMENT_71
                        );
        }
 }
@@ -128,13 +134,14 @@ ReelWriter::write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const
 {
        FILE* file = 0;
        boost::filesystem::path info_file = _film->info_file (_period);
-       if (boost::filesystem::exists (info_file)) {
+       bool const read = boost::filesystem::exists (info_file);
+       if (read) {
                file = fopen_boost (info_file, "r+b");
        } else {
                file = fopen_boost (info_file, "wb");
        }
        if (!file) {
-               throw OpenFileError (info_file);
+               throw OpenFileError (info_file, errno, read);
        }
        dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
        fwrite (&info.offset, sizeof (info.offset), 1, file);
@@ -488,7 +495,7 @@ ReelWriter::write (PlayerSubtitles subs)
                }
        }
 
-       BOOST_FOREACH (dcp::SubtitleString i, subs.text) {
+       BOOST_FOREACH (SubtitleString i, subs.text) {
                i.set_in  (i.in()  - dcp::Time (_period.from.seconds(), i.in().tcr));
                i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr));
                _subtitle_asset->add (i);