Commit 9462621e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: add some assertions

parent d7cb099f
......@@ -158,6 +158,7 @@ static const uint16_t vlc_chans[] = {
[SND_CHMAP_SR] = AOUT_CHAN_MIDDLERIGHT,
[SND_CHMAP_RC] = AOUT_CHAN_REARCENTER,
};
static_assert(AOUT_CHAN_MAX == 9, "Missing channel entries");
static int Map2Mask (vlc_object_t *obj, const snd_pcm_chmap_t *restrict map)
{
......
......@@ -25,6 +25,7 @@
# include "config.h"
#endif
#include <assert.h>
#include <math.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
......@@ -769,6 +770,8 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
map.map[map.channels++] = PA_CHANNEL_POSITION_LFE;
fmt->i_original_channels = fmt->i_physical_channels;
static_assert(AOUT_CHAN_MAX == 9, "Missing channels");
for (unsigned i = 0; map.channels < ss.channels; i++) {
map.map[map.channels++] = PA_CHANNEL_POSITION_AUX0 + i;
msg_Warn(aout, "mapping channel %"PRIu8" to AUX%u", map.channels, i);
......
......@@ -248,6 +248,8 @@ unsigned aout_CheckChannelReorder( const uint32_t *chans_in,
const uint32_t *chans_out,
uint32_t mask, uint8_t *restrict table )
{
static_assert(AOUT_CHAN_MAX <= (sizeof (mask) * CHAR_BIT), "Missing bits");
unsigned channels = 0;
if( chans_in == NULL )
......@@ -454,6 +456,9 @@ bool aout_CheckChannelExtraction( int *pi_selection,
const uint32_t pi_order_dst[AOUT_CHAN_MAX],
const uint32_t *pi_order_src, int i_channels )
{
static_assert(AOUT_CHAN_MAX <= (sizeof (*pi_order_dst) * CHAR_BIT),
"Missing bits");
const uint32_t pi_order_dual_mono[] = { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT };
uint32_t i_layout = 0;
int i_out = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment