hal: Add support for two concurrent record sessions.
Add support to fallback to compress record path for second
record session during concurrent recording.
Change-Id: I0b570bb8a15fa6b07210e643b63ce65d8d95616a
diff --git a/hal/Android.mk b/hal/Android.mk
index 6814e76..d9d45e7 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -321,6 +321,10 @@
LOCAL_SRC_FILES += audio_extn/qaf.c
endif
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CONCURRENT_CAPTURE)),true)
+ LOCAL_CFLAGS += -DCONCURRENT_CAPTURE_ENABLED
+endif
+
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_INPUT)),true)
LOCAL_CFLAGS += -DCOMPRESS_INPUT_ENABLED
LOCAL_SRC_FILES += audio_extn/compress_in.c
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 46a4b98..08a8fad 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -7858,6 +7858,22 @@
pthread_mutex_lock(&adev->lock);
ret_val = audio_extn_check_and_set_multichannel_usecase(adev,
in, config, &channel_mask_updated);
+#ifdef CONCURRENT_CAPTURE_ENABLED
+ /* Acquire lock to avoid two concurrent use cases initialized to
+ same pcm record use case*/
+
+ if(in->usecase == USECASE_AUDIO_RECORD) {
+ if (!(adev->pcm_record_uc_state)) {
+ ALOGV("%s: using USECASE_AUDIO_RECORD",__func__);
+ adev->pcm_record_uc_state = 1;
+ } else {
+ /* Assign compress record use case for second record */
+ in->usecase = USECASE_AUDIO_RECORD_COMPRESS2;
+ in->flags |= AUDIO_INPUT_FLAG_COMPRESS;
+ ALOGV("%s: overriding usecase with USECASE_AUDIO_RECORD_COMPRESS2 and appending compress flag", __func__);
+ }
+ }
+#endif
pthread_mutex_unlock(&adev->lock);
if (!ret_val) {
@@ -7983,6 +7999,10 @@
in_standby(&stream->common);
pthread_mutex_lock(&adev->lock);
+ if (in->usecase == USECASE_AUDIO_RECORD) {
+ adev->pcm_record_uc_state = 0;
+ }
+
if (audio_extn_ssr_get_stream() == in) {
audio_extn_ssr_deinit();
}
@@ -8442,6 +8462,7 @@
list_init(&adev->usecase_list);
adev->cur_wfd_channels = 2;
adev->offload_usecases_state = 0;
+ adev->pcm_record_uc_state = 0;
adev->is_channel_status_set = false;
adev->perf_lock_opts[0] = 0x101;
adev->perf_lock_opts[1] = 0x20E;
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 7b74d16..4f93aa9 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -526,6 +526,7 @@
void *platform;
void *extspk;
unsigned int offload_usecases_state;
+ unsigned int pcm_record_uc_state;
void *visualizer_lib;
int (*visualizer_start_output)(audio_io_handle_t, int);
int (*visualizer_stop_output)(audio_io_handle_t, int);