diff options
Diffstat (limited to 'src/cubeb_mixer.cpp')
-rw-r--r-- | src/cubeb_mixer.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/cubeb_mixer.cpp b/src/cubeb_mixer.cpp index f93a5e6..842581d 100644 --- a/src/cubeb_mixer.cpp +++ b/src/cubeb_mixer.cpp @@ -299,7 +299,7 @@ mix_remap(long inframes, T * out, unsigned long out_len, cubeb_channel_layout in_layout, cubeb_channel_layout out_layout) { - assert(in_layout != out_layout); + assert(in_layout != out_layout && inframes >= 0); // We might overwrite the data before we copied them to the mapped index // (e.g. upmixing from stereo to 2F1 or mapping [L, R] to [R, L]) @@ -325,15 +325,16 @@ mix_remap(long inframes, return false; } - for (long i = 0, out_index = 0; i < inframes * in_channels; i += in_channels, out_index += out_channels) { + for (unsigned long i = 0, out_index = 0; i < (unsigned long)inframes * in_channels; i += in_channels, out_index += out_channels) { for (unsigned int j = 0; j < out_channels; ++j) { cubeb_channel channel = CHANNEL_INDEX_TO_ORDER[out_layout][j]; uint32_t channel_mask = 1 << channel; int channel_index = CHANNEL_ORDER_TO_INDEX[in_layout][channel]; - assert((unsigned long)out_index + j < out_len); + assert(channel_index >= -1); + assert(out_index + j < out_len); if (in_layout_mask & channel_mask) { - assert((unsigned long)i + channel_index < in_len); assert(channel_index != -1); + assert(i + channel_index < in_len); out[out_index + j] = in[i + channel_index]; } else { assert(channel_index == -1); @@ -353,15 +354,15 @@ downmix_fallback(long inframes, T * out, unsigned long out_len, unsigned int in_channels, unsigned int out_channels) { - assert(in_channels >= out_channels); + assert(in_channels >= out_channels && inframes >= 0); if (in_channels == out_channels && in == out) { return; } - for (long i = 0, out_index = 0; i < inframes * in_channels; i += in_channels, out_index += out_channels) { + for (unsigned long i = 0, out_index = 0; i < (unsigned long)inframes * in_channels; i += in_channels, out_index += out_channels) { for (unsigned int j = 0; j < out_channels; ++j) { - assert((unsigned long)i + j < in_len && (unsigned long)out_index + j < out_len); + assert(i + j < in_len && out_index + j < out_len); out[out_index + j] = in[i + j]; } } |