1 /*****************************************************************************
2 * coreaudio.h : CoreAudio definitions for vlc
3 *****************************************************************************
4 * Copyright (C) 2014-2018 VideoLabs, VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
22 /* According to Apple's CoreAudio_Bitmap/CoreAudio_BitmapTypes.h */
25 CoreAudio_Bitmap_LEFT
= (1<<0),
26 CoreAudio_Bitmap_RIGHT
= (1<<1),
27 CoreAudio_Bitmap_CENTER
= (1<<2),
28 CoreAudio_Bitmap_LFESCREEN
= (1<<3),
29 CoreAudio_Bitmap_BACKLEFT
= (1<<4),
30 CoreAudio_Bitmap_BACKRIGHT
= (1<<5),
31 CoreAudio_Bitmap_LEFTCENTER
= (1<<6),
32 CoreAudio_Bitmap_RIGHTCENTER
= (1<<7),
33 CoreAudio_Bitmap_BACKCENTER
= (1<<8),
34 CoreAudio_Bitmap_SIDELEFT
= (1<<9),
35 CoreAudio_Bitmap_SIDERIGHT
= (1<<10),
36 CoreAudio_Bitmap_TOPCENTER
= (1<<11),
37 CoreAudio_Bitmap_TOPFRONTLEFT
= (1<<12),
38 CoreAudio_Bitmap_TOPFRONTENTER
= (1<<13),
39 CoreAudio_Bitmap_TOPFRONTRIGHT
= (1<<14),
40 CoreAudio_Bitmap_TOPBACKLEFT
= (1<<15),
41 CoreAudio_Bitmap_TOPBACKCENTER
= (1<<16),
42 CoreAudio_Bitmap_TOPBACKRIGHT
= (1<<17),
45 static const uint32_t pi_vlc_chan_order_CoreAudio
[] =
47 AOUT_CHAN_LEFT
, AOUT_CHAN_RIGHT
, AOUT_CHAN_CENTER
,
49 AOUT_CHAN_REARLEFT
, AOUT_CHAN_REARRIGHT
,
50 AOUT_CHAN_LEFT
, AOUT_CHAN_RIGHT
, AOUT_CHAN_REARCENTER
,
51 AOUT_CHAN_MIDDLELEFT
, AOUT_CHAN_MIDDLERIGHT
,
58 uint32_t i_vlc_bitmap
;
59 } CoreAudio_Bitmap_mapping
[] = {
60 { CoreAudio_Bitmap_LEFT
, AOUT_CHAN_LEFT
},
61 { CoreAudio_Bitmap_RIGHT
, AOUT_CHAN_RIGHT
},
62 { CoreAudio_Bitmap_CENTER
, AOUT_CHAN_CENTER
},
63 { CoreAudio_Bitmap_LFESCREEN
, AOUT_CHAN_LFE
},
64 { CoreAudio_Bitmap_BACKLEFT
, AOUT_CHAN_REARLEFT
},
65 { CoreAudio_Bitmap_BACKRIGHT
, AOUT_CHAN_REARRIGHT
},
66 { CoreAudio_Bitmap_LEFTCENTER
, AOUT_CHAN_LEFT
},
67 { CoreAudio_Bitmap_RIGHTCENTER
, AOUT_CHAN_RIGHT
},
68 { CoreAudio_Bitmap_BACKCENTER
, AOUT_CHAN_REARCENTER
},
69 { CoreAudio_Bitmap_SIDELEFT
, AOUT_CHAN_MIDDLELEFT
},
70 { CoreAudio_Bitmap_SIDERIGHT
, AOUT_CHAN_MIDDLERIGHT
},
71 { CoreAudio_Bitmap_TOPCENTER
, 0 },
72 { CoreAudio_Bitmap_TOPFRONTLEFT
, 0 },
73 { CoreAudio_Bitmap_TOPFRONTENTER
,0 },
74 { CoreAudio_Bitmap_TOPFRONTRIGHT
,0 },
75 { CoreAudio_Bitmap_TOPBACKLEFT
, 0 },
76 { CoreAudio_Bitmap_TOPBACKCENTER
,0 },
77 { CoreAudio_Bitmap_TOPBACKRIGHT
, 0 },
82 CoreAudio_Layout_DESC
= 0,
83 CoreAudio_Layout_BITMAP
= (1<<16),
86 static inline int CoreAudio_Bitmap_to_vlc_bitmap( uint32_t i_corebitmap
,
89 const uint32_t **pp_chans_order
)
91 *pp_chans_order
= pi_vlc_chan_order_CoreAudio
;
94 for (uint8_t i
=0;i
<ARRAY_SIZE(CoreAudio_Bitmap_mapping
);i
++)
96 if ( CoreAudio_Bitmap_mapping
[i
].i_bitmap
& i_corebitmap
)
98 if ( (CoreAudio_Bitmap_mapping
[i
].i_vlc_bitmap
& *pi_mapping
) ||
99 *pi_channels
>= AOUT_CHAN_MAX
)
101 /* double mapping or unsupported number of channels */
106 *pi_mapping
|= CoreAudio_Bitmap_mapping
[i
].i_vlc_bitmap
;