summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-06-10 15:17:00 -0700
committerAndy Hung <hunga@google.com>2015-06-10 15:18:56 -0700
commit5e58a30b6f625d3c28d1c6b15eec3edf5643e227 (patch)
tree237c1b0f61d0382765a4ba24529e4e8b8e05a78b /modules
parentc88122614c1593bc9384564b10f11bd7bb7e3b64 (diff)
downloadhardware_libhardware-5e58a30b6f625d3c28d1c6b15eec3edf5643e227.zip
hardware_libhardware-5e58a30b6f625d3c28d1c6b15eec3edf5643e227.tar.gz
hardware_libhardware-5e58a30b6f625d3c28d1c6b15eec3edf5643e227.tar.bz2
Update USB channel mask handling
1 and 2 channels will default to mono and stereo n > 2 will default to channel index masks Bug: 16245854 Change-Id: I39f9d43385a93f48e323653fbde2e38a99b6256f
Diffstat (limited to 'modules')
-rw-r--r--modules/usbaudio/audio_hal.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c
index 5431476..872fa93 100644
--- a/modules/usbaudio/audio_hal.c
+++ b/modules/usbaudio/audio_hal.c
@@ -55,6 +55,8 @@ static const unsigned k_force_channels = 0;
#define DEFAULT_INPUT_BUFFER_SIZE_MS 20
+// stereo channel count
+#define FCC_2 2
// fixed channel count of 8 limitation (for data processing in AudioFlinger)
#define FCC_8 8
@@ -528,10 +530,14 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
proposed_channel_count = profile_get_default_channel_count(out->profile);
}
if (proposed_channel_count != 0) {
- config->channel_mask = audio_channel_out_mask_from_count(proposed_channel_count);
- if (config->channel_mask == AUDIO_CHANNEL_INVALID)
+ if (proposed_channel_count <= FCC_2) {
+ // use channel position mask for mono and stereo
+ config->channel_mask = audio_channel_out_mask_from_count(proposed_channel_count);
+ } else {
+ // use channel index mask for multichannel
config->channel_mask =
audio_channel_mask_for_index_assignment_from_count(proposed_channel_count);
+ }
out->hal_channel_count = proposed_channel_count;
} else {
out->hal_channel_count = audio_channel_count_from_out_mask(config->channel_mask);