demux: libavi: force chunk type check
[vlc.git] / modules / demux / windows_audio_commons.h
blob80aa5cb1b8053f98c008c42bd10fa929b97ebcf9
1 /*****************************************************************************
2 * windows_audio_common.h: Windows Audio common code
3 *****************************************************************************
4 * Copyright (C) 2001-2013 VideoLAN
5 * $Id$
7 * Authors: Denis Charmet <typx@videolan.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
23 #ifndef DMX_WINDOWS_AUDIO_COMMONS_H
24 #define DMX_WINDOWS_AUDIO_COMMONS_H
26 #include <vlc_aout.h>
27 #include <vlc_codecs.h>
29 static const uint32_t pi_channels_src[] = { WAVE_SPEAKER_FRONT_LEFT,
30 WAVE_SPEAKER_FRONT_RIGHT, WAVE_SPEAKER_FRONT_CENTER,
31 WAVE_SPEAKER_LOW_FREQUENCY, WAVE_SPEAKER_BACK_LEFT, WAVE_SPEAKER_BACK_RIGHT,
32 WAVE_SPEAKER_BACK_CENTER, WAVE_SPEAKER_SIDE_LEFT, WAVE_SPEAKER_SIDE_RIGHT, 0 };
34 static const uint32_t pi_channels_aout[] = { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
35 AOUT_CHAN_CENTER, AOUT_CHAN_LFE, AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
36 AOUT_CHAN_REARCENTER, AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT, 0 };
38 static inline unsigned getChannelMask( uint32_t * wvfextChannelMask, int i_channels, int * i_match )
40 unsigned i_channel_mask = 0;
41 *i_match = 0;
42 for( unsigned i = 0;
43 i < sizeof(pi_channels_src)/sizeof(*pi_channels_src) &&
44 *i_match < i_channels; i++ )
46 if( *wvfextChannelMask & pi_channels_src[i] )
48 if( !( i_channel_mask & pi_channels_aout[i] ) )
49 *i_match += 1;
51 *wvfextChannelMask &= ~pi_channels_src[i];
52 i_channel_mask |= pi_channels_aout[i];
55 return i_channel_mask;
58 #endif /*DMX_WINDOWS_AUDIO_COMMONS_H*/