[vlc-commits] demux: wav: supports inputs with channels > AOUT_CHAN_MAX

Thomas Guillem git at videolan.org
Mon Jul 10 17:14:22 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jul  7 11:45:38 2017 +0200| [952c089c2ce32cba4231ffd66920cc7b703e5418] | committer: Thomas Guillem

demux: wav: supports inputs with channels > AOUT_CHAN_MAX

If the channel number is higher than AOUT_CHAN_MAX, don't set the physical
mask, and just set the number of channels. A filter will take of dropping
extra channels or doing an ambisonics conversion.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=952c089c2ce32cba4231ffd66920cc7b703e5418
---

 modules/demux/wav.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/demux/wav.c b/modules/demux/wav.c
index db7a32c93c..d48ca384a4 100644
--- a/modules/demux/wav.c
+++ b/modules/demux/wav.c
@@ -29,6 +29,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_demux.h>
@@ -37,6 +39,9 @@
 
 #include "windows_audio_commons.h"
 
+#define WAV_CHAN_MAX 32
+static_assert( INPUT_CHAN_MAX >= WAV_CHAN_MAX, "channel count mismatch" );
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -271,7 +276,8 @@ static int Open( vlc_object_t * p_this )
             }
         }
     }
-    if( p_sys->i_channel_mask == 0 && p_sys->fmt.audio.i_channels > 2 )
+    if( p_sys->i_channel_mask == 0 && p_sys->fmt.audio.i_channels > 2
+     && p_sys->fmt.audio.i_channels <= AOUT_CHAN_MAX )
     {
         /* A dwChannelMask of 0 tells the audio device to render the first
          * channel to the first port on the device, the second channel to the
@@ -555,7 +561,7 @@ static int FrameInfo_PCM( unsigned int *pi_size, int *pi_samples,
 
     if( p_fmt->audio.i_rate > 352800
      || p_fmt->audio.i_bitspersample > 64
-     || p_fmt->audio.i_channels > AOUT_CHAN_MAX )
+     || p_fmt->audio.i_channels > WAV_CHAN_MAX )
         return VLC_EGENERIC;
 
     /* read samples for 50ms of */



More information about the vlc-commits mailing list