[vlc-commits] aout: add some assertions
Rémi Denis-Courmont
git at videolan.org
Sun Nov 8 15:51:18 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 8 16:51:09 2015 +0200| [9462621efb0eef5c96c01374e646483d0bec0360] | committer: Rémi Denis-Courmont
aout: add some assertions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9462621efb0eef5c96c01374e646483d0bec0360
---
modules/audio_output/alsa.c | 1 +
modules/audio_output/pulse.c | 3 +++
src/audio_output/common.c | 5 +++++
3 files changed, 9 insertions(+)
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 4e9fd53..fcb949d 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -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)
{
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 29170b2..6bc8f37 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -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);
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 3de1f6a..188067c 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -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;
More information about the vlc-commits
mailing list