]> git.sesse.net Git - vlc/blob - modules/demux/windows_audio_commons.h
mediacodec: don't loop in GetOutput
[vlc] / modules / demux / windows_audio_commons.h
1 /*****************************************************************************
2  * windows_audio_common.h: Windows Audio common code
3  *****************************************************************************
4  * Copyright (C) 2001-2013 VideoLAN
5  * $Id$
6  *
7  * Authors: Denis Charmet <typx@videolan.org>
8  *
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.
13  *
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.
18  *
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
25
26 #include <vlc_aout.h>
27 #include <vlc_codecs.h>
28
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 };
33
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 };
37
38 static inline unsigned getChannelMask( uint32_t * wvfextChannelMask, int i_channels, int * i_match )
39 {
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++ )
45     {
46         if( *wvfextChannelMask & pi_channels_src[i] )
47         {
48             if( !( i_channel_mask & pi_channels_aout[i] ) )
49                  *i_match += 1;
50
51             *wvfextChannelMask &= ~pi_channels_src[i];
52             i_channel_mask |= pi_channels_aout[i];
53         }
54     }
55     return i_channel_mask;
56 }
57
58 #endif /*DMX_WINDOWS_AUDIO_COMMONS_H*/