Trying to create export audio encoders with between 9 and 15 channels
[dcpomatic.git] / src / lib / audio_buffers.cc
index aea581a07311ea151d1508cd1a26b60dcd448009..3692c304e148863a3dbc02a9f2805bb901c43648 100644 (file)
@@ -190,7 +190,12 @@ AudioBuffers::copy_from (AudioBuffers const * from, int32_t frames_to_copy, int3
 
        DCPOMATIC_ASSERT (from);
        DCPOMATIC_ASSERT (read_offset >= 0 && (read_offset + frames_to_copy) <= from->_allocated_frames);
-       DCPOMATIC_ASSERT (write_offset >= 0 && (write_offset + frames_to_copy) <= _allocated_frames);
+       if (write_offset < 0 || (write_offset + frames_to_copy) > _allocated_frames) {
+               throw ProgrammingError(
+                               __FILE__, __LINE__,
+                               String::compose("frames_to_copy=%1, read_offset=%2, write_offset=%3", frames_to_copy, read_offset, write_offset)
+                               );
+       }
 
        for (int i = 0; i < _channels; ++i) {
                memcpy (_data[i] + write_offset, from->_data[i] + read_offset, frames_to_copy * sizeof(float));
@@ -224,6 +229,9 @@ AudioBuffers::move (int32_t frames, int32_t from, int32_t to)
 }
 
 /** Add data from from `from', `from_channel' to our channel `to_channel'.
+ *  @param from Buffers to copy data from.
+ *  @param from_channel Channel index to read in \p from.
+ *  @param to_channel Channel index to accumulate into.
  *  @param gain Linear gain to apply to the data before it is added.
  */
 void