hal: avoid undesired backend reconfiguration for multi-record usecase
Backend is getting reconfigured if new session is started with
configuration not matching to the current configuration
even though new configuration is inferior to the current
configuration and the session requesting superior configuration
is still active.
Fix this issue by checking configurations from other active sessions
before reconfiguring backend.
Change-Id: I5727c4de306a7e57ad9c4cf0d5f659f9420837af
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 0d5e6fc..e99d546 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -280,8 +280,8 @@
char profile[MAX_STREAM_PROFILE_STR_LEN];
bool is_st_session;
bool is_st_session_active;
- int sample_rate;
- int bit_width;
+ unsigned int sample_rate;
+ unsigned int bit_width;
bool realtime;
int af_period_multiplier;
struct stream_app_type_cfg app_type_cfg;
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index a9ffa14..b94bab0 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -5477,6 +5477,33 @@
__func__);
bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ channels = CODEC_BACKEND_DEFAULT_TX_CHANNELS;
+ } else {
+ struct listnode *node;
+ struct audio_usecase *uc = NULL;
+ unsigned int uc_channels = 0;
+ struct stream_in *in = NULL;
+ /* update cfg against other existing capture usecases on same backend */
+ list_for_each(node, &adev->usecase_list) {
+ uc = node_to_item(node, struct audio_usecase, list);
+ if (uc->type == PCM_CAPTURE &&
+ backend_idx == platform_get_backend_index(uc->in_snd_device)) {
+ in = (struct stream_in *) uc->stream.in;
+ uc_channels = audio_channel_count_from_in_mask(in->channel_mask);
+
+ ALOGV("%s:txbecf: uc %s, id %d, sr %d, bw %d, ch %d, device %s",
+ __func__, use_case_table[uc->id], uc->id, in->sample_rate,
+ in->bit_width, uc_channels,
+ platform_get_snd_device_name(uc->in_snd_device));
+
+ if (sample_rate < in->sample_rate)
+ sample_rate = in->sample_rate;
+ if (bit_width < in->bit_width)
+ bit_width = in->bit_width;
+ if (channels < uc_channels)
+ channels = uc_channels;
+ }
+ }
}
if (backend_idx == USB_AUDIO_TX_BACKEND) {
audio_extn_usb_is_config_supported(&bit_width, &sample_rate, &channels, false);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index c2ebb26..e9936ff 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -5351,6 +5351,33 @@
"for unprocessed/camera source", __func__);
bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ channels = CODEC_BACKEND_DEFAULT_TX_CHANNELS;
+ } else {
+ struct listnode *node;
+ struct audio_usecase *uc = NULL;
+ unsigned int uc_channels = 0;
+ struct stream_in *in = NULL;
+ /* update cfg against other existing capture usecases on same backend */
+ list_for_each(node, &adev->usecase_list) {
+ uc = node_to_item(node, struct audio_usecase, list);
+ if (uc->type == PCM_CAPTURE &&
+ backend_idx == platform_get_backend_index(uc->in_snd_device)) {
+ in = (struct stream_in *) uc->stream.in;
+ uc_channels = audio_channel_count_from_in_mask(in->channel_mask);
+
+ ALOGV("%s:txbecf: uc %s, id %d, sr %d, bw %d, ch %d, device %s",
+ __func__, use_case_table[uc->id], uc->id, in->sample_rate,
+ in->bit_width, uc_channels,
+ platform_get_snd_device_name(uc->in_snd_device));
+
+ if (sample_rate < in->sample_rate)
+ sample_rate = in->sample_rate;
+ if (bit_width < in->bit_width)
+ bit_width = in->bit_width;
+ if (channels < uc_channels)
+ channels = uc_channels;
+ }
+ }
}
if (backend_idx == USB_AUDIO_TX_BACKEND) {
audio_extn_usb_is_config_supported(&bit_width, &sample_rate, &channels, false);