Close assets on destruction even if finalize() is not called.
[libdcp.git] / src / sound_asset_writer.h
index f1cdf41910eba72b67d4938f6e343c77c538d2d3..031af5c9937967487c02bbb866d09df0ebbc00b1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
     files in the program, then also delete it here.
 */
 
+
 /** @file  src/sound_asset_writer.h
- *  @brief SoundAssetWriter class.
+ *  @brief SoundAssetWriter class
  */
 
+
 #include "asset_writer.h"
 #include "fsk.h"
 #include "types.h"
@@ -49,8 +51,10 @@ struct sync_test1;
 
 namespace dcp {
 
+
 class SoundAsset;
 
+
 /** @class SoundAssetWriter
  *  @brief A helper class for writing to SoundAssets.
  *
@@ -63,14 +67,20 @@ class SoundAsset;
 class SoundAssetWriter : public AssetWriter
 {
 public:
+       ~SoundAssetWriter();
+
+       /** @param data Pointer an array of float pointers, one for each channel.
+        *  @param frames Number of frames i.e. number of floats that are given for each channel.
+        */
        void write (float const * const *, int);
-       bool finalize ();
+
+       bool finalize () override;
 
 private:
        friend class SoundAsset;
        friend struct ::sync_test1;
 
-       SoundAssetWriter (SoundAsset *, boost::filesystem::path, std::vector<Channel> active_channels, bool sync);
+       SoundAssetWriter (SoundAsset *, boost::filesystem::path, bool sync);
 
        void start ();
        void write_current_frame ();
@@ -83,16 +93,14 @@ private:
        struct ASDCPState;
        std::shared_ptr<ASDCPState> _state;
 
-       SoundAsset* _asset;
-       int _frame_buffer_offset;
+       SoundAsset* _asset = nullptr;
+       int _frame_buffer_offset = 0;
 
        /** true to ignore any signal passed to write() on channel 14 and instead write a sync track */
-       bool _sync;
+       bool _sync = false;
        /** index of the sync packet (0-3) which starts the next edit unit */
-       int _sync_packet;
+       int _sync_packet = 0;
        FSK _fsk;
-
-       std::vector<Channel> _active_channels;
 };
 
 }