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 struct CoreAudio_layout_s
24 uint32_t i_channels_layout_tag
;
25 uint32_t i_channels_bitmap
;
26 uint32_t i_channels_description_count
;
29 uint32_t i_channel_label
;
30 uint32_t i_channel_flags
;
31 float f_coordinates
[3];
35 static inline void CoreAudio_Layout_Clean(struct CoreAudio_layout_s
*c
)
37 free( c
->p_descriptions
);
40 /* According to Apple's CoreAudio_Bitmap/CoreAudio_BitmapTypes.h */
43 CoreAudio_Bitmap_LEFT
= (1<<0),
44 CoreAudio_Bitmap_RIGHT
= (1<<1),
45 CoreAudio_Bitmap_CENTER
= (1<<2),
46 CoreAudio_Bitmap_LFESCREEN
= (1<<3),
47 CoreAudio_Bitmap_BACKLEFT
= (1<<4),
48 CoreAudio_Bitmap_BACKRIGHT
= (1<<5),
49 CoreAudio_Bitmap_LEFTCENTER
= (1<<6),
50 CoreAudio_Bitmap_RIGHTCENTER
= (1<<7),
51 CoreAudio_Bitmap_BACKCENTER
= (1<<8),
52 CoreAudio_Bitmap_SIDELEFT
= (1<<9),
53 CoreAudio_Bitmap_SIDERIGHT
= (1<<10),
54 CoreAudio_Bitmap_TOPCENTER
= (1<<11),
55 CoreAudio_Bitmap_TOPFRONTLEFT
= (1<<12),
56 CoreAudio_Bitmap_TOPFRONTENTER
= (1<<13),
57 CoreAudio_Bitmap_TOPFRONTRIGHT
= (1<<14),
58 CoreAudio_Bitmap_TOPBACKLEFT
= (1<<15),
59 CoreAudio_Bitmap_TOPBACKCENTER
= (1<<16),
60 CoreAudio_Bitmap_TOPBACKRIGHT
= (1<<17),
63 static const uint32_t pi_vlc_chan_order_CoreAudio
[] =
65 AOUT_CHAN_LEFT
, AOUT_CHAN_RIGHT
, AOUT_CHAN_CENTER
,
67 AOUT_CHAN_REARLEFT
, AOUT_CHAN_REARRIGHT
,
68 AOUT_CHAN_LEFT
, AOUT_CHAN_RIGHT
, AOUT_CHAN_REARCENTER
,
69 AOUT_CHAN_MIDDLELEFT
, AOUT_CHAN_MIDDLERIGHT
,
76 uint32_t i_vlc_bitmap
;
77 } CoreAudio_Bitmap_mapping
[] = {
78 { CoreAudio_Bitmap_LEFT
, AOUT_CHAN_LEFT
},
79 { CoreAudio_Bitmap_RIGHT
, AOUT_CHAN_RIGHT
},
80 { CoreAudio_Bitmap_CENTER
, AOUT_CHAN_CENTER
},
81 { CoreAudio_Bitmap_LFESCREEN
, AOUT_CHAN_LFE
},
82 { CoreAudio_Bitmap_BACKLEFT
, AOUT_CHAN_REARLEFT
},
83 { CoreAudio_Bitmap_BACKRIGHT
, AOUT_CHAN_REARRIGHT
},
84 { CoreAudio_Bitmap_LEFTCENTER
, AOUT_CHAN_LEFT
},
85 { CoreAudio_Bitmap_RIGHTCENTER
, AOUT_CHAN_RIGHT
},
86 { CoreAudio_Bitmap_BACKCENTER
, AOUT_CHAN_REARCENTER
},
87 { CoreAudio_Bitmap_SIDELEFT
, AOUT_CHAN_MIDDLELEFT
},
88 { CoreAudio_Bitmap_SIDERIGHT
, AOUT_CHAN_MIDDLERIGHT
},
89 { CoreAudio_Bitmap_TOPCENTER
, 0 },
90 { CoreAudio_Bitmap_TOPFRONTLEFT
, 0 },
91 { CoreAudio_Bitmap_TOPFRONTENTER
,0 },
92 { CoreAudio_Bitmap_TOPFRONTRIGHT
,0 },
93 { CoreAudio_Bitmap_TOPBACKLEFT
, 0 },
94 { CoreAudio_Bitmap_TOPBACKCENTER
,0 },
95 { CoreAudio_Bitmap_TOPBACKRIGHT
, 0 },
100 CoreAudio_Layout_DESC
= 0,
101 CoreAudio_Layout_BITMAP
= (1<<16),
104 static inline int CoreAudio_Bitmap_to_vlc_bitmap( const struct CoreAudio_layout_s
*c
,
105 uint16_t *pi_mapping
,
106 uint8_t *pi_channels
,
107 const uint32_t **pp_chans_order
)
109 *pp_chans_order
= pi_vlc_chan_order_CoreAudio
;
112 for (uint8_t i
=0;i
<ARRAY_SIZE(CoreAudio_Bitmap_mapping
);i
++)
114 if ( CoreAudio_Bitmap_mapping
[i
].i_bitmap
& c
->i_channels_bitmap
)
116 if ( (CoreAudio_Bitmap_mapping
[i
].i_vlc_bitmap
& *pi_mapping
) ||
117 *pi_channels
>= AOUT_CHAN_MAX
)
119 /* double mapping or unsupported number of channels */
124 *pi_mapping
|= CoreAudio_Bitmap_mapping
[i
].i_vlc_bitmap
;