• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_CHANNELS_H_
18 #define ANDROID_CHANNELS_H_
19 
20 #include <system/audio.h>
21 #include <SLES/OpenSLES.h>
22 
23 #define SL_ANDROID_SPEAKER_COUNT_MAX            FCC_8
24 #define SL_ANDROID_INDEXED_SPEAKER_MASK_ALL     ((SLuint32) \
25                                                 ((1 << SL_ANDROID_SPEAKER_COUNT_MAX) - 1))
26 #define SL_ANDROID_POSITIONAL_SPEAKER_MASK_ALL  \
27         ( SL_SPEAKER_FRONT_LEFT \
28         | SL_SPEAKER_FRONT_RIGHT \
29         | SL_SPEAKER_FRONT_CENTER \
30         | SL_SPEAKER_LOW_FREQUENCY \
31         | SL_SPEAKER_BACK_LEFT \
32         | SL_SPEAKER_BACK_RIGHT \
33         | SL_SPEAKER_FRONT_LEFT_OF_CENTER \
34         | SL_SPEAKER_FRONT_RIGHT_OF_CENTER \
35         | SL_SPEAKER_BACK_CENTER \
36         | SL_SPEAKER_SIDE_LEFT \
37         | SL_SPEAKER_SIDE_RIGHT \
38         | SL_SPEAKER_TOP_CENTER \
39         | SL_SPEAKER_TOP_FRONT_LEFT \
40         | SL_SPEAKER_TOP_FRONT_CENTER \
41         | SL_SPEAKER_TOP_FRONT_RIGHT \
42         | SL_SPEAKER_TOP_BACK_LEFT \
43         | SL_SPEAKER_TOP_BACK_CENTER \
44         | SL_SPEAKER_TOP_BACK_RIGHT )
45 
46 // Channel count and channel mask definitions
47 
48 #define SL_ANDROID_SPEAKER_QUAD (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT \
49         | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT)
50 
51 #define SL_ANDROID_SPEAKER_5DOT1 (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT \
52         | SL_SPEAKER_FRONT_CENTER  | SL_SPEAKER_LOW_FREQUENCY| SL_SPEAKER_BACK_LEFT \
53         | SL_SPEAKER_BACK_RIGHT)
54 
55 #define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT \
56         | SL_SPEAKER_SIDE_RIGHT)
57 
58 extern SLuint32 sles_channel_out_mask_from_count(unsigned channelCount);
59 extern SLuint32 sles_channel_in_mask_from_count(unsigned channelCount);
60 extern SLuint32 sles_channel_count_from_mask(SLuint32 mask);
61 extern SLboolean sles_is_channel_mask_valid(SLuint32 mask);
62 
63 extern audio_channel_representation_t sles_to_audio_channel_mask_representation(SLuint32 mask);
64 extern audio_channel_mask_t sles_to_audio_output_channel_mask(SLuint32 mask);
65 extern audio_channel_mask_t sles_to_audio_input_channel_mask(SLuint32 mask);
66 
67 #define SL_ANDROID_UNKNOWN_CHANNELMASK 0
68 
69 #endif // ANDROID_CHANNELS_H_
70