Add function to derive a channel mask from a channel count
Change-Id: I22523ded9cd8e5283a285a9db21d819bbbc1b6c3
This commit is contained in:
parent
0afee8b668
commit
4ab051ab46
1 changed files with 35 additions and 1 deletions
|
@ -250,7 +250,9 @@ typedef enum {
|
|||
AUDIO_CHANNEL_IN_Z_AXIS |
|
||||
AUDIO_CHANNEL_IN_VOICE_UPLINK |
|
||||
AUDIO_CHANNEL_IN_VOICE_DNLINK),
|
||||
} audio_channels_t;
|
||||
};
|
||||
|
||||
typedef uint32_t audio_channel_mask_t;
|
||||
|
||||
typedef enum {
|
||||
AUDIO_MODE_INVALID = -2,
|
||||
|
@ -382,6 +384,38 @@ static inline bool audio_is_output_channel(uint32_t channel)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Derive a channel mask from a channel count.
|
||||
* This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel
|
||||
* cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad,
|
||||
* and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC
|
||||
* for continuity with stereo.
|
||||
* Returns the matching channel mask, or 0 if the number of channels exceeds that of the
|
||||
* configurations for which a default channel mask is defined.
|
||||
*/
|
||||
static inline audio_channel_mask_t audio_channel_mask_from_count(uint32_t channel_count)
|
||||
{
|
||||
switch(channel_count) {
|
||||
case 1:
|
||||
return AUDIO_CHANNEL_OUT_MONO;
|
||||
case 2:
|
||||
return AUDIO_CHANNEL_OUT_STEREO;
|
||||
case 3:
|
||||
return (AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER);
|
||||
case 4: // 4.0
|
||||
return AUDIO_CHANNEL_OUT_QUAD;
|
||||
case 5: // 5.0
|
||||
return (AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER);
|
||||
case 6: // 5.1
|
||||
return AUDIO_CHANNEL_OUT_5POINT1;
|
||||
case 7: // 6.1
|
||||
return (AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER);
|
||||
case 8:
|
||||
return AUDIO_CHANNEL_OUT_7POINT1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool audio_is_valid_format(audio_format_t format)
|
||||
{
|
||||
switch (format & AUDIO_FORMAT_MAIN_MASK) {
|
||||
|
|
Loading…
Reference in a new issue