}
+MonoPictureAssetWriter::~MonoPictureAssetWriter()
+{
+ try {
+ /* Last-resort finalization to close the file, at least */
+ if (_started) {
+ _state->mxf_writer.Finalize();
+ }
+ } catch (...) {}
+}
+
+
void
MonoPictureAssetWriter::start (uint8_t const * data, int size)
{
if (ASDCP_FAILURE(r)) {
boost::throw_exception (MXFFileError("error in finalizing video MXF", _file.string(), r));
}
+ _started = false;
}
_picture_asset->_intrinsic_duration = _frames_written;
* Objects of this class can only be created with MonoPictureAsset::start_write().
*
* Frames can be written to the MonoPictureAsset by calling write() with a JPEG2000 image
- * (a verbatim .j2c file). finalize() must be called after the last frame has been written.
- * The action of finalize() can't be done in MonoPictureAssetWriter's destructor as it may
- * throw an exception.
+ * (a verbatim .j2c file). finalize() should be called after the last frame has been written,
+ * but if it is not, it will be called by the destructor (though in that case any error
+ * during finalization will be ignored).
*/
class MonoPictureAssetWriter : public PictureAssetWriter
{
public:
+ ~MonoPictureAssetWriter();
+
FrameInfo write (uint8_t const *, int) override;
void fake_write (int size) override;
bool finalize () override;
}
+SoundAssetWriter::~SoundAssetWriter()
+{
+ try {
+ /* Last-resort finalization to close the file, at least */
+ if (_started) {
+ _state->mxf_writer.Finalize();
+ }
+ } catch (...) {}
+}
+
+
void
SoundAssetWriter::start ()
{
if (ASDCP_FAILURE(r)) {
boost::throw_exception (MiscError(String::compose ("could not finalise audio MXF (%1)", static_cast<int>(r))));
}
+ _started = false;
}
_asset->_intrinsic_duration = _frames_written;
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.
*/
}
+StereoPictureAssetWriter::~StereoPictureAssetWriter()
+{
+ try {
+ /* Last-resort finalization to close the file, at least */
+ if (_started) {
+ _state->mxf_writer.Finalize();
+ }
+ } catch (...) {}
+}
+
+
void
StereoPictureAssetWriter::start (uint8_t const * data, int size)
{
if (ASDCP_FAILURE(r)) {
boost::throw_exception (MXFFileError("error in finalizing video MXF", _file.string(), r));
}
+ _started = false;
}
_picture_asset->_intrinsic_duration = _frames_written;
* Objects of this class can only be created with StereoPictureAsset::start_write().
*
* Frames can be written to the StereoPictureAsset by calling write() with a JPEG2000 image
- * (a verbatim .j2c file). finalize() must be called after the last frame has been written.
- * The action of finalize() can't be done in StereoPictureAssetWriter's destructor as it may
- * throw an exception.
+ * (a verbatim .j2c file). finalize() should be called after the last frame has been written,
+ * but if it is not, it will be called by the destructor (though in that case any error
+ * during finalization will be ignored).
*/
class StereoPictureAssetWriter : public PictureAssetWriter
{
public:
+ ~StereoPictureAssetWriter();
+
/** Write a frame for one eye. Frames must be written left, then right, then left etc.
* @param data JPEG2000 data.
* @param size Size of data.