Remove the bools and default parameters from SoundAsset::start_write().
authorCarl Hetherington <cth@carlh.net>
Fri, 17 Mar 2023 12:33:08 +0000 (13:33 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 20 Mar 2023 15:41:02 +0000 (16:41 +0100)
They were more confusing than they were worth.

examples/make_dcp.cc
src/sound_asset.cc
src/sound_asset.h
test/dcp_test.cc
test/decryption_test.cc
test/encryption_test.cc
test/mca_test.cc
test/sound_asset_writer_test.cc
test/sync_test.cc
test/test.cc

index 7f387db2e6dac766cbee01eccea7353c46a61dd6..60f5608ad36eed4f981d1efe8679f08e9cebfdd4 100644 (file)
@@ -74,7 +74,7 @@ main ()
           When creating the object we specify the sampling rate (48kHz) and the number of channels (2).
        */
        auto sound_asset = std::make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 2, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE);
-       auto sound_writer = sound_asset->start_write("DCP/sound.mxf");
+       auto sound_writer = sound_asset->start_write("DCP/sound.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        /* Write some sine waves */
        std::array<float, 48000> left;
index 8002f37a0fedc66ca620ef62117b67934eb487bd..56d13951ee5781d5b878459bc59347df0ce41d2c 100644 (file)
@@ -221,13 +221,19 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand
 
 
 shared_ptr<SoundAssetWriter>
-SoundAsset::start_write(boost::filesystem::path file, bool atmos_sync, bool include_mca_subdescriptors)
+SoundAsset::start_write(
+       boost::filesystem::path file,
+       AtmosSync atmos_sync,
+       MCASubDescriptors include_mca_subdescriptors
+       )
 {
-       if (atmos_sync && _channels < 14) {
+       if (atmos_sync == AtmosSync::ENABLED && _channels < 14) {
                throw MiscError ("Insufficient channels to write ATMOS sync (there must be at least 14)");
        }
 
-       return shared_ptr<SoundAssetWriter>(new SoundAssetWriter(this, file, atmos_sync, include_mca_subdescriptors));
+       return shared_ptr<SoundAssetWriter>(
+               new SoundAssetWriter(this, file, atmos_sync == AtmosSync::ENABLED, include_mca_subdescriptors == MCASubDescriptors::ENABLED)
+               );
 }
 
 
index e9a2736d4298c9ff186adab4b62989692a25feb2..e51f185498504eb82e4f631c49adec4c055613a8 100644 (file)
@@ -75,7 +75,22 @@ public:
        explicit SoundAsset (boost::filesystem::path file);
        SoundAsset (Fraction edit_rate, int sampling_rate, int channels, LanguageTag language, Standard standard);
 
-       std::shared_ptr<SoundAssetWriter> start_write(boost::filesystem::path file, bool atmos_sync = false, bool include_mca_subdescriptors = true);
+       enum class AtmosSync {
+               ENABLED,
+               DISABLED
+       };
+
+       enum class MCASubDescriptors {
+               ENABLED,
+               DISABLED
+       };
+
+       std::shared_ptr<SoundAssetWriter> start_write(
+               boost::filesystem::path file,
+               AtmosSync atmos_sync,
+               MCASubDescriptors mca_subdescriptors
+               );
+
        std::shared_ptr<SoundAssetReader> start_read () const;
 
        bool equals (
index 71564238ab829387848018a11d8345aa0c0320da..03c5e2a9ea1248484143ac8fcbab7d7e8303ddef 100644 (file)
@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE (dcp_test2)
 
        auto ms = make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE);
        ms->set_metadata (mxf_meta);
-       auto sound_writer = ms->start_write ("build/test/DCP/dcp_test2/audio.mxf");
+       auto sound_writer = ms->start_write("build/test/DCP/dcp_test2/audio.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        SF_INFO info;
        info.format = 0;
@@ -206,7 +206,7 @@ test_rewriting_sound(string name, bool modify)
 
        auto reader = A_sound->asset()->start_read();
        auto sound = make_shared<dcp::SoundAsset>(A_sound->asset()->edit_rate(), A_sound->asset()->sampling_rate(), A_sound->asset()->channels(), dcp::LanguageTag("en-US"), dcp::Standard::SMPTE);
-       auto writer = sound->start_write(path("build") / "test" / name / "pcm_8246f87f-e1df-4c42-a290-f3b3069ff021.mxf", {});
+       auto writer = sound->start_write(path("build") / "test" / name / "pcm_8246f87f-e1df-4c42-a290-f3b3069ff021.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        bool need_to_modify = modify;
        for (int i = 0; i < A_sound->asset()->intrinsic_duration(); ++i) {
@@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE (dcp_test5)
 
        auto ms = make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE);
        ms->set_metadata (mxf_meta);
-       auto sound_writer = ms->start_write ("build/test/DCP/dcp_test5/audio.mxf");
+       auto sound_writer = ms->start_write("build/test/DCP/dcp_test5/audio.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        SF_INFO info;
        info.format = 0;
index c24402bffa0f27146d43878eb482b8a01b3b7c3f..757a6986d0a2da14b5d34d1f2cb9d396fd87b580 100644 (file)
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE (decryption_test2)
        auto sound_asset = std::make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 2, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE);
        sound_asset->set_key (key);
        sound_asset->set_context_id (context_id);
-       auto sound_writer = sound_asset->start_write(dir / "sound.mxf");
+       auto sound_writer = sound_asset->start_write(dir / "sound.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
        std::array<float, 48000> left;
        std::array<float, 48000> right;
        for (int i = 0; i < 48000; ++i) {
index 2b9a6beaf0e9a6e013921705002393e9eb5924dd..29b8f1fb348b653195d52ce6ea0c1321bec532af 100644 (file)
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE (encryption_test)
        auto ms = make_shared<dcp::SoundAsset>(dcp::Fraction (24, 1), 48000, 1, dcp::LanguageTag("en-GB"), dcp::Standard::SMPTE);
        ms->set_metadata (mxf_metadata);
        ms->set_key (key);
-       auto sound_writer = ms->start_write ("build/test/DCP/encryption_test/audio.mxf");
+       auto sound_writer = ms->start_write("build/test/DCP/encryption_test/audio.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        SF_INFO info;
        info.format = 0;
index fc5dda25f71f284a09ea5d29db2aedc6da05ec5d..fc6a76d3e463d1e85a21d54504514fbe4c6e7533 100644 (file)
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE (parse_mca_descriptors_from_mxf_test)
 BOOST_AUTO_TEST_CASE (write_mca_descriptors_to_mxf_test)
 {
        auto sound_asset = make_shared<dcp::SoundAsset>(dcp::Fraction(24, 1), 48000, 6, dcp::LanguageTag("en-US"), dcp::Standard::SMPTE);
-       auto writer = sound_asset->start_write("build/test/write_mca_descriptors_to_mxf_test.mxf");
+       auto writer = sound_asset->start_write("build/test/write_mca_descriptors_to_mxf_test.mxf", {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        float* samples[6];
        for (int i = 0; i < 6; ++i) {
index a413a1745a545c76d6ebbbb2d9d7c4a24fca3b4d..d5a6648963f0526fc12900e710555756b63fdaf3 100644 (file)
@@ -48,7 +48,7 @@ void
 no_padding_test(boost::filesystem::path path, std::function<void (shared_ptr<dcp::SoundAssetWriter>, boost::random::mt19937&, boost::random::uniform_int_distribution<>&)> write)
 {
        dcp::SoundAsset asset({24, 1}, 48000, 6, dcp::LanguageTag{"en-GB"}, dcp::Standard::SMPTE);
-       auto writer = asset.start_write(path);
+       auto writer = asset.start_write(path, {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        boost::random::mt19937 rng(1);
        boost::random::uniform_int_distribution<> dist(0, 32767);
@@ -119,7 +119,7 @@ void
 padding_test(boost::filesystem::path path, std::function<void (shared_ptr<dcp::SoundAssetWriter>, boost::random::mt19937&, boost::random::uniform_int_distribution<>&)> write)
 {
        dcp::SoundAsset asset({24, 1}, 48000, 14, dcp::LanguageTag{"en-GB"}, dcp::Standard::SMPTE);
-       auto writer = asset.start_write(path);
+       auto writer = asset.start_write(path, {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        boost::random::mt19937 rng(1);
        boost::random::uniform_int_distribution<> dist(0, 32767);
index ba235bd4c2bae42fdda9cc5297a9cc0d839defcb..67920e2ffce0de41bdd26239a551190ffede6ee0 100644 (file)
@@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE (sync_test1)
                }
        }
 
-       shared_ptr<dcp::SoundAssetWriter> writer = asset.start_write ("build/test/foo.mxf", true);
+       auto writer = asset.start_write("build/test/foo.mxf", {}, dcp::SoundAsset::AtmosSync::ENABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        /* Compare the sync bits made by SoundAssetWriter to the "proper" ones in the MXF */
        BOOST_CHECK (ref == writer->create_sync_packets());
@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE (sync_test2)
        asset._id = "e004046e09234f90a4ae4355e7e83506";
        boost::system::error_code ec;
        boost::filesystem::remove ("build/test/foo.mxf", ec);
-       auto writer = asset.start_write ("build/test/foo.mxf", true);
+       auto writer = asset.start_write("build/test/foo.mxf", {}, dcp::SoundAsset::AtmosSync::ENABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        int const frames = 2000;
        float** junk = new float*[channels];
index 1b23b177686d01ea573cc023ac0a85b7326c45d7..76ed92f4b606a3854bba8981d7c574588bc4fa6e 100644 (file)
@@ -301,7 +301,7 @@ simple_sound(boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_m
        }
        ms->_language = language;
        ms->set_metadata (mxf_meta);
-       shared_ptr<dcp::SoundAssetWriter> sound_writer = ms->start_write (path / dcp::String::compose("audio%1.mxf", suffix));
+       auto sound_writer = ms->start_write(path / dcp::String::compose("audio%1.mxf", suffix), {}, dcp::SoundAsset::AtmosSync::DISABLED, dcp::SoundAsset::MCASubDescriptors::ENABLED);
 
        int const samples_per_frame = sample_rate / 24;