Add an assertion and a better error message.
authorCarl Hetherington <cth@carlh.net>
Fri, 29 Dec 2017 01:01:19 +0000 (01:01 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 29 Dec 2017 01:01:19 +0000 (01:01 +0000)
src/sound_asset_writer.cc

index e628b26e2823087f377a252cec3122076677b996..3cb25db59b733fa224d663a1540b7ecf34cbbae6 100644 (file)
@@ -93,6 +93,7 @@ void
 SoundAssetWriter::write (float const * const * data, int frames)
 {
        DCP_ASSERT (!_finalized);
+       DCP_ASSERT (frames > 0);
 
        static float const clip = 1.0f - (1.0f / pow (2, 23));
 
@@ -157,8 +158,11 @@ SoundAssetWriter::finalize ()
                write_current_frame ();
        }
 
-       if (_started && ASDCP_FAILURE (_state->mxf_writer.Finalize())) {
-               boost::throw_exception (MiscError ("could not finalise audio MXF"));
+       if (_started) {
+               ASDCP::Result_t const r = _state->mxf_writer.Finalize();
+               if (ASDCP_FAILURE(r)) {
+                       boost::throw_exception (MiscError (String::compose ("could not finalise audio MXF (%1)", int(r))));
+               }
        }
 
        _asset->_intrinsic_duration = _frames_written;