diff options
| author | Jean-Michel Trivi <jmtrivi@google.com> | 2012-03-05 14:51:42 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-03-05 14:51:42 -0800 |
| commit | f1b244c3fafb9c0b96b10a3aea77bb6690fa9074 (patch) | |
| tree | 636ab58f40b8a9b43ae063188abdab0858dac430 /include | |
| parent | ab556e27a1c3a93611556705f2669d987435de60 (diff) | |
| parent | 4ab051ab4613f2622dc3f3f0f57bb34d8a40a6a9 (diff) | |
| download | system_core-f1b244c3fafb9c0b96b10a3aea77bb6690fa9074.tar.gz system_core-f1b244c3fafb9c0b96b10a3aea77bb6690fa9074.tar.bz2 system_core-f1b244c3fafb9c0b96b10a3aea77bb6690fa9074.zip | |
Merge "Add function to derive a channel mask from a channel count"
Diffstat (limited to 'include')
| -rw-r--r-- | include/system/audio.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/include/system/audio.h b/include/system/audio.h index 0f19101b..09803196 100644 --- a/include/system/audio.h +++ b/include/system/audio.h @@ -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) { |
