audio: hal: Add support to configure render mode
-Changes to configure render mode
Change-Id: I38ef63bf89eaf7a8664ff33cd00455b9643a4cdc
CRs-Fixed: 2009985
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index aa26626..07cba28 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -93,6 +93,10 @@
AUDIO_FORMAT_AAC_SUB_HE_V2)
#endif
+#ifndef AUDIO_OUTPUT_FLAG_TIMESTAMP
+#define AUDIO_OUTPUT_FLAG_TIMESTAMP 0x10000
+#endif
+
#ifndef COMPRESS_METADATA_NEEDED
#define audio_extn_parse_compress_metadata(out, parms) (0)
#else
@@ -829,4 +833,5 @@
struct audio_usecase *usecase,
struct audio_avt_device_drift_param *drift_param);
int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out);
+int audio_extn_utils_compress_set_render_mode(struct stream_out *out);
#endif /* AUDIO_EXTN_H */
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 349d2b0..7860522 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -1694,3 +1694,46 @@
return COMPRESS_OFFLOAD_PLAYBACK_LATENCY;
}
#endif
+
+#ifdef SNDRV_COMPRESS_RENDER_MODE
+int audio_extn_utils_compress_set_render_mode(struct stream_out *out)
+{
+ struct snd_compr_metadata metadata;
+ int ret = -EINVAL;
+
+ if (!(is_offload_usecase(out->usecase))) {
+ ALOGE("%s:: not supported for non offload session", __func__);
+ goto exit;
+ }
+
+ if (!out->compr) {
+ ALOGD("%s:: Invalid compress handle",
+ __func__);
+ goto exit;
+ }
+
+ ALOGD("%s:: render mode %d", __func__, out->render_mode);
+
+ metadata.key = SNDRV_COMPRESS_RENDER_MODE;
+ if (out->render_mode == RENDER_MODE_AUDIO_MASTER) {
+ metadata.value[0] = SNDRV_COMPRESS_RENDER_MODE_AUDIO_MASTER;
+ } else if (out->render_mode == RENDER_MODE_AUDIO_STC_MASTER) {
+ metadata.value[0] = SNDRV_COMPRESS_RENDER_MODE_STC_MASTER;
+ } else {
+ ret = 0;
+ goto exit;
+ }
+ ret = compress_set_metadata(out->compr, &metadata);
+ if(ret) {
+ ALOGE("%s::error %s", __func__, compress_get_error(out->compr));
+ }
+exit:
+ return ret;
+}
+#else
+int audio_extn_utils_compress_set_render_mode(struct stream_out *out __unused)
+{
+ ALOGD("%s:: configuring render mode not supported", __func__);
+ return 0;
+}
+#endif
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index bfbfa39..238db4e 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2332,6 +2332,8 @@
compress_set_max_poll_wait(out->compr, 1000);
}
+ audio_extn_utils_compress_set_render_mode(out);
+
audio_extn_dts_create_state_notifier_node(out->usecase);
audio_extn_dts_notify_playback_state(out->usecase, 0, out->sample_rate,
popcount(out->channel_mask),
@@ -4137,6 +4139,14 @@
if (flags & AUDIO_OUTPUT_FLAG_NON_BLOCKING)
out->non_blocking = 1;
+ if ((flags & AUDIO_OUTPUT_FLAG_TIMESTAMP) &&
+ (flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC)) {
+ out->render_mode = RENDER_MODE_AUDIO_STC_MASTER;
+ } else if(flags & AUDIO_OUTPUT_FLAG_TIMESTAMP) {
+ out->render_mode = RENDER_MODE_AUDIO_MASTER;
+ } else {
+ out->render_mode = RENDER_MODE_AUDIO_NO_TIMESTAMP;
+ }
out->send_new_metadata = 1;
out->send_next_track_params = false;
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 8f2ac98..ffe4d46 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -196,6 +196,12 @@
int data[];
};
+typedef enum render_mode {
+ RENDER_MODE_AUDIO_NO_TIMESTAMP = 0,
+ RENDER_MODE_AUDIO_MASTER,
+ RENDER_MODE_AUDIO_STC_MASTER,
+} render_mode_t;
+
struct stream_app_type_cfg {
int sample_rate;
uint32_t bit_width;
@@ -252,11 +258,14 @@
bool realtime;
int af_period_multiplier;
struct audio_device *dev;
+
void* qaf_stream_handle;
pthread_cond_t qaf_offload_cond;
pthread_t qaf_offload_thread;
struct listnode qaf_offload_cmd_list;
uint32_t platform_latency;
+ render_mode_t render_mode;
+
audio_offload_info_t info;
};