diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-05-04 20:07:47 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-04 20:07:47 +0000 |
commit | 99d790b67a364446f6b7d009c8edd328578501b6 (patch) | |
tree | 96d24ae76ba6635dd06606b7c7eb461946d8bce2 | |
parent | d3f4f14218049bde7f5c5061f560c2554c6f6a0d (diff) | |
parent | 981f7744968c858838a453f796fc5796ab04bbdb (diff) | |
download | libhardware-99d790b67a364446f6b7d009c8edd328578501b6.tar.gz |
Merge "usb audio: check proxy_prepare() errors in opne_input_stream()" into oc-dev
-rw-r--r-- | modules/usbaudio/audio_hal.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c index 6a3c5daf..df4bc0f7 100644 --- a/modules/usbaudio/audio_hal.c +++ b/modules/usbaudio/audio_hal.c @@ -933,7 +933,7 @@ static int adev_open_input_stream(struct audio_hw_device *hw_dev, struct audio_config *config, struct audio_stream_in **stream_in, audio_input_flags_t flags __unused, - const char *address /*__unused*/, + const char *address, audio_source_t source __unused) { ALOGV("adev_open_input_stream() rate:%" PRIu32 ", chanMask:0x%" PRIX32 ", fmt:%" PRIu8, @@ -989,7 +989,7 @@ static int adev_open_input_stream(struct audio_hw_device *hw_dev, ret = config->sample_rate != in->adev->device_sample_rate ? -EINVAL : 0; proxy_config.rate = config->sample_rate = in->adev->device_sample_rate; } else if (profile_is_sample_rate_valid(in->profile, config->sample_rate)) { - in->adev->device_sample_rate = proxy_config.rate = config->sample_rate; + proxy_config.rate = config->sample_rate; } else { proxy_config.rate = config->sample_rate = profile_get_default_sample_rate(in->profile); ret = -EINVAL; @@ -1053,18 +1053,29 @@ static int adev_open_input_stream(struct audio_hw_device *hw_dev, // and store THAT in proxy_config.channels proxy_config.channels = profile_get_closest_channel_count(in->profile, in->hal_channel_count); - proxy_prepare(&in->proxy, in->profile, &proxy_config); + ret = proxy_prepare(&in->proxy, in->profile, &proxy_config); + if (ret == 0) { + in->standby = true; - in->standby = true; + in->conversion_buffer = NULL; + in->conversion_buffer_size = 0; - in->conversion_buffer = NULL; - in->conversion_buffer_size = 0; + *stream_in = &in->stream; - *stream_in = &in->stream; + /* Save this for adev_dump() */ + adev_add_stream_to_list(in->adev, &in->adev->input_stream_list, &in->list_node); + } else { + ALOGW("proxy_prepare error %d", ret); + unsigned channel_count = proxy_get_channel_count(&in->proxy); + config->channel_mask = channel_count <= FCC_2 + ? audio_channel_in_mask_from_count(channel_count) + : audio_channel_mask_for_index_assignment_from_count(channel_count); + config->format = audio_format_from_pcm_format(proxy_get_format(&in->proxy)); + config->sample_rate = proxy_get_sample_rate(&in->proxy); + } + } - /* Save this for adev_dump() */ - adev_add_stream_to_list(in->adev, &in->adev->input_stream_list, &in->list_node); - } else { + if (ret != 0) { // Deallocate this stream on error, because AudioFlinger won't call // adev_close_input_stream() in this case. *stream_in = NULL; |