diff options
author | Andy Hung <hunga@google.com> | 2015-05-05 23:37:30 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-05-11 12:18:04 -0700 |
commit | 182ddc7d130d078e3cdb1e1fbf02d86368a2ac47 (patch) | |
tree | d7b064ef12ca64cba14f01a5099ad6ad8e5e88e3 /modules/usbaudio | |
parent | 780f1f8149996442f43c77ec50518cc8030cd682 (diff) | |
download | hardware_libhardware-182ddc7d130d078e3cdb1e1fbf02d86368a2ac47.zip hardware_libhardware-182ddc7d130d078e3cdb1e1fbf02d86368a2ac47.tar.gz hardware_libhardware-182ddc7d130d078e3cdb1e1fbf02d86368a2ac47.tar.bz2 |
Add output channel index mask to USB hal
Change-Id: I17818ac89f7ca591422cadfaa388590ff9c08613
Diffstat (limited to 'modules/usbaudio')
-rw-r--r-- | modules/usbaudio/audio_hal.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c index 2b88797..84cc643 100644 --- a/modules/usbaudio/audio_hal.c +++ b/modules/usbaudio/audio_hal.c @@ -90,6 +90,8 @@ struct stream_out { * the device is not compatible with AudioFlinger * capabilities, e.g. exposes too many channels or * too few channels. */ + audio_channel_mask_t hal_channel_mask; /* channel mask exposed to AudioFlinger. */ + void * conversion_buffer; /* any conversions are put into here * they could come from here too if * there was a previous conversion */ @@ -301,7 +303,7 @@ static size_t out_get_buffer_size(const struct audio_stream *stream) static uint32_t out_get_channels(const struct audio_stream *stream) { const struct stream_out *out = (const struct stream_out*)stream; - return audio_channel_out_mask_from_count(out->hal_channel_count); + return out->hal_channel_mask; } static audio_format_t out_get_format(const struct audio_stream *stream) @@ -587,15 +589,24 @@ static int adev_open_output_stream(struct audio_hw_device *dev, } /* Channels */ - unsigned proposed_channel_count = profile_get_default_channel_count(out->profile); + unsigned proposed_channel_count = 0; if (k_force_channels) { proposed_channel_count = k_force_channels; - } else if (config->channel_mask != AUDIO_CHANNEL_NONE) { - proposed_channel_count = audio_channel_count_from_out_mask(config->channel_mask); + } else if (config->channel_mask == AUDIO_CHANNEL_NONE) { + 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) + 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); } - /* we can expose any channel count mask, and emulate internally. */ - config->channel_mask = audio_channel_out_mask_from_count(proposed_channel_count); - out->hal_channel_count = proposed_channel_count; + /* we can expose any channel mask, and emulate internally based on channel count. */ + out->hal_channel_mask = config->channel_mask; + /* no validity checks are needed as proxy_prepare() forces channel_count to be valid. * and we emulate any channel count discrepancies in out_write(). */ proxy_config.channels = proposed_channel_count; |