audio: can not get AC4 active presentation [2/2]
PD#SWPL-188558
Problem:
dual ms12 branch does not have this function.
Solution:
add getting AC4 active presentation and checking AC4 pgi is present
function
Verify:
yocto-t5w
Change-Id: I2e0a1f73ab8f96fca293518f5d399c00db32d384
Signed-off-by: yayun.shi <yayun.shi@amlogic.com>
diff --git a/audio_hal/aml_audio_output.c b/audio_hal/aml_audio_output.c
index b61b53a..705a28b 100644
--- a/audio_hal/aml_audio_output.c
+++ b/audio_hal/aml_audio_output.c
@@ -469,19 +469,17 @@
adev->stream_write_data = Stop_watch(adev->last_write_ts, 800);// no audio data more than 800ms
}
bool audio_effect_enable = adev->stream_write_data;
- if (adev->last_audio_effect_enable != audio_effect_enable) {
+ if (eDolbyMS12Lib == adev->dolby_lib_type && adev->last_audio_effect_enable != audio_effect_enable) {
AM_LOGI("audio_effect_enable change from %d to %d", adev->last_audio_effect_enable, audio_effect_enable);
- if (eDolbyMS12Lib == adev->dolby_lib_type) {
- if (audio_effect_enable) {
- /*Only when active port change to spk and data enough will set it*/
- if (adev->active_outport == OUTPORT_SPEAKER) {
- set_ms12_full_dap_disable(&adev->ms12, false);
- adev->last_audio_effect_enable = audio_effect_enable;
- }
- } else {
- set_ms12_full_dap_disable(&adev->ms12, true);
+ if (audio_effect_enable) {
+ /*Only when active port change to spk and data enough will set it*/
+ if (adev->active_outport == OUTPORT_SPEAKER) {
+ set_ms12_full_dap_disable(&adev->ms12, false);
adev->last_audio_effect_enable = audio_effect_enable;
}
+ } else {
+ set_ms12_full_dap_disable(&adev->ms12, true);
+ adev->last_audio_effect_enable = audio_effect_enable;
}
}
diff --git a/audio_hal/audio_hw.c b/audio_hal/audio_hw.c
index c62fc65..c4fbae4 100644
--- a/audio_hal/audio_hw.c
+++ b/audio_hal/audio_hw.c
@@ -5425,11 +5425,23 @@
return strdup(temp_buf);
} else if (strstr (keys, "ac4_active_pres_id")) {
int active_id_offset = -1;
- if ((eDolbyMS12Lib == adev->dolby_lib_type) && (adev->ms12.input_config_format == AUDIO_FORMAT_AC4)) {
+ struct aml_stream_out *aml_out = NULL;
+ bool is_ac4_stream_present = false;
+
+ for (int i = 0 ; i < STREAM_NUM_MAX; i++) {
+ aml_out = adev->active_outputs[i];
+ if (aml_out && AUDIO_FORMAT_AC4 == aml_out->hal_internal_format) {
+ AM_LOGI("aml_out:%p format:%x", aml_out, aml_out->hal_internal_format);
+ is_ac4_stream_present = true;
+ break;
+ }
+ }
+
+ if ((eDolbyMS12Lib == adev->dolby_lib_type) && is_ac4_stream_present) {
//should use the dolby_ms12_get_ac4_active_presentation() before or after get_dolby_ms12_cleanup()
pthread_mutex_lock(&adev->ms12.lock);
- if (adev->ms12.dolby_ms12_enable && (0 == dolby_ms12_get_ac4_active_presentation(&active_id_offset))) {
- ALOGI ("dolby_ms12_get_ac4_active_presentation index offset is %d\n", active_id_offset);
+ if (adev->ms12.dolby_ms12_enable && (0 == get_aml_ac4_active_presentation((struct audio_stream_out *)aml_out, &active_id_offset))) {
+ ALOGI ("get_aml_ac4_active_presentation index is %d", active_id_offset);
}
pthread_mutex_unlock(&adev->ms12.lock);
}
diff --git a/audio_hal/audio_hw_ms12_v2.c b/audio_hal/audio_hw_ms12_v2.c
index 2b57f11..2c11df6 100644
--- a/audio_hal/audio_hw_ms12_v2.c
+++ b/audio_hal/audio_hw_ms12_v2.c
@@ -722,7 +722,7 @@
struct aml_audio_device *adev = aml_out->dev;
struct dolby_ms12_desc *ms12 = &(adev->ms12);
int ret = -1;
- if (ms12 && aml_out->ms12_dec_handle) {
+ if (aml_out && aml_out->ms12_dec_handle) {
ret = aml_ms12_decoder_setparameter(ms12, aml_out->ms12_dec_handle, MS12_CODEC_PARAMETER_AT, &associated_type, sizeof(associated_type));
}
AM_LOGI("stream:%p ms12_dec_handle:%p set associated_type to %d. ret %d",
@@ -736,7 +736,7 @@
struct aml_audio_device *adev = aml_out->dev;
struct dolby_ms12_desc *ms12 = &(adev->ms12);
int ret = -1;
- if (ms12 && aml_out->ms12_dec_handle) {
+ if (aml_out && aml_out->ms12_dec_handle) {
ret = aml_ms12_decoder_setparameter(ms12, aml_out->ms12_dec_handle, MS12_CODEC_PARAMETER_AC4_DE, &ac4_de, sizeof(ac4_de));
}
AM_LOGI("stream:%p ms12_dec_handle:%p set ac4_de to %d. ret %d",
@@ -752,13 +752,45 @@
struct aml_audio_device *adev = aml_out->dev;
struct dolby_ms12_desc *ms12 = &(adev->ms12);
int ret = -1;
- if (ms12 && aml_out->ms12_dec_handle) {
+ if (aml_out && aml_out->ms12_dec_handle) {
ret = aml_ms12_decoder_setparameter(ms12, aml_out->ms12_dec_handle, MS12_CODEC_PARAMETER_AC4_PRES_GROUP_IDX, &index, sizeof(index));
}
AM_LOGI("stream:%p ms12_dec_handle:%p set group index to %d. ret %d",
stream, aml_out->ms12_dec_handle, index, ret);
}
+
+int get_aml_ac4_active_presentation(struct audio_stream_out *stream, int *presentation_group_index)
+{
+ struct aml_stream_out *aml_out = (struct aml_stream_out *)stream;
+ struct aml_audio_device *adev = aml_out->dev;
+ struct dolby_ms12_desc *ms12 = &(adev->ms12);
+ int ret = -1;
+ if (aml_out && aml_out->ms12_dec_handle && presentation_group_index) {
+ ret = aml_ms12_decoder_getparameter(ms12, aml_out->ms12_dec_handle, MS12_CODEC_PARAMETER_AC4DE_ACTIVE_PRESENTATION, presentation_group_index, sizeof(int));
+ AM_LOGI("presentation_group_index = %d", *presentation_group_index);
+ } else {
+ AM_LOGE("aml_out(%p), ms12_dec_handle(%p), presentation_group_index(%p)", aml_out, aml_out->ms12_dec_handle, presentation_group_index);
+ }
+ return ret;
+}
+
+int check_aml_ac4dec_the_pgi_is_present(struct audio_stream_out *stream, int presentation_group_index)
+{
+ struct aml_stream_out *aml_out = (struct aml_stream_out *)stream;
+ struct aml_audio_device *adev = aml_out->dev;
+ struct dolby_ms12_desc *ms12 = &(adev->ms12);
+ int ret = 0;
+ if (aml_out && aml_out->ms12_dec_handle) {
+ ret = aml_ms12_decoder_getparameter(ms12, aml_out->ms12_dec_handle, MS12_CODEC_PARAMETER_AC4DE_THE_PGI_IS_PRESENT, &presentation_group_index, sizeof(int));
+ AM_LOGI("presentation_group_index(%d) %s present", presentation_group_index, (ret? "is":"is not"));
+ } else {
+ AM_LOGE("aml_out(%p), ms12_dec_handle(%p)", aml_out, aml_out->ms12_dec_handle);
+ }
+ return ret;
+
+}
+
void set_ms12_decoder_parameters(struct audio_stream_out *stream, char * parm)
{
struct aml_stream_out *aml_out = (struct aml_stream_out *)stream;
diff --git a/audio_hal/audio_hw_ms12_v2.h b/audio_hal/audio_hw_ms12_v2.h
index 852338b..0b336f3 100644
--- a/audio_hal/audio_hw_ms12_v2.h
+++ b/audio_hal/audio_hw_ms12_v2.h
@@ -346,6 +346,9 @@
void set_ms12_ac4_preferred_associated_type(struct audio_stream_out *stream, int associated_type);
void set_ms12_ac4_dialogue_enhancement(struct audio_stream_out *stream, int ac4_de);
void set_ms12_ac4_presentation_group_index(struct audio_stream_out *stream, int index);
+int get_aml_ac4_active_presentation(struct audio_stream_out *stream, int *presentation_group_index);
+int check_aml_ac4dec_the_pgi_is_present(struct audio_stream_out *stream, int presentation_group_index);
+
/*
*@brief set ms12 main audio mute or non mute
* input parameters
diff --git a/decoder/libms12_v24/include/aml_audio_ms12.h b/decoder/libms12_v24/include/aml_audio_ms12.h
index d4e4044..ae0492d 100644
--- a/decoder/libms12_v24/include/aml_audio_ms12.h
+++ b/decoder/libms12_v24/include/aml_audio_ms12.h
@@ -57,29 +57,33 @@
};
typedef enum {
- MS12_CODEC_PARAMETER_CMD,
- MS12_CODEC_PARAMETER_PAUSE,
- MS12_CODEC_PARAMETER_FLUSH,
- MS12_CODEC_PARAMETER_XA,
- MS12_CODEC_PARAMETER_XU,
- MS12_CODEC_PARAMETER_MAIN1_MIXGAIN,
- MS12_CODEC_PARAMETER_MAIN2_MIXGAIN,
- MS12_CODEC_PARAMETER_AD_FADE_PAN,
- MS12_CODEC_PARAMETER_AC4_LANG,
- MS12_CODEC_PARAMETER_AC4_LANG2,
- MS12_CODEC_PARAMETER_AT,
- MS12_CODEC_PARAMETER_PAT,
- MS12_CODEC_PARAMETER_AC4_DE,
- MS12_CODEC_PARAMETER_AC4_PRES_GROUP_IDX,
- MS12_CODEC_PARAMETER_AC4_SHORT_PROG_ID,
- MS12_CODEC_PARAMETER_MAIN_BUFFER_AVAIL,
- MS12_CODEC_PARAMETER_ASSOCIATE_BUFFER_AVAIL,
- MS12_CODEC_PARAMETER_MAIN_CONSUMED,
- MS12_CODEC_PARAMETER_MAIN_PCMOUT_FRAME,
- MS12_CODEC_PARAMETER_ATMOS_PRESENT,
+ MS12_CODEC_PARAMETER_CMD = 0,
+ MS12_CODEC_PARAMETER_PAUSE = 1,
+ MS12_CODEC_PARAMETER_FLUSH = 2,
+ MS12_CODEC_PARAMETER_XA = 3,
+ MS12_CODEC_PARAMETER_XU = 4,
+ MS12_CODEC_PARAMETER_MAIN1_MIXGAIN = 5,
+ MS12_CODEC_PARAMETER_MAIN2_MIXGAIN = 6,
+ MS12_CODEC_PARAMETER_AD_FADE_PAN = 7,
+ MS12_CODEC_PARAMETER_AC4_LANG = 8,
+ MS12_CODEC_PARAMETER_AC4_LANG2 = 9,
+ MS12_CODEC_PARAMETER_AT = 10,
+ MS12_CODEC_PARAMETER_PAT = 11,
+ MS12_CODEC_PARAMETER_AC4_DE = 12,
+ MS12_CODEC_PARAMETER_AC4_PRES_GROUP_IDX = 13,
+ MS12_CODEC_PARAMETER_AC4_SHORT_PROG_ID = 14,
+ MS12_CODEC_PARAMETER_MAIN_BUFFER_AVAIL = 15,
+ MS12_CODEC_PARAMETER_ASSOCIATE_BUFFER_AVAIL = 16,
+ MS12_CODEC_PARAMETER_MAIN_CONSUMED = 17,
+ MS12_CODEC_PARAMETER_MAIN_PCMOUT_FRAME = 18,
+ MS12_CODEC_PARAMETER_ATMOS_PRESENT = 19,
+ MS12_CODEC_PARAMETER_REQUEST_FOCUS = 20,
+ MS12_CODEC_PARAMETER_AC4DE_ACTIVE_PRESENTATION = 21,
+ MS12_CODEC_PARAMETER_AC4DE_THE_PGI_IS_PRESENT = 22,
MS12_CODEC_PARAMETER_MAX,
}ms12_codec_parameter_type_t;
+
typedef enum {
MS12_CODEC_CALLBACK_SYNC,
MS12_CODEC_CALLBACK_TEMPO,
diff --git a/decoder/libms12_v24/include/dolby_ms12.h b/decoder/libms12_v24/include/dolby_ms12.h
index de882bb..49dcb15 100644
--- a/decoder/libms12_v24/include/dolby_ms12.h
+++ b/decoder/libms12_v24/include/dolby_ms12.h
@@ -337,11 +337,6 @@
, int *config /**< [in] mat encoder config value */
);
-//brief This function get the active presentation group indext
-int dolby_ms12_get_ac4_active_presentation(int *presentation_group_index);
-//whether the given presentation group index is present in a bitstream
-int dolby_ms12_ac4dec_check_the_pgi_is_present(int presentation_group_index);
-
int dolby_ms12_set_alsa_delay_frame(int delay_frame);
int dolby_ms12_set_alsa_limit_frame(int limit_frame);
diff --git a/decoder/libms12_v24/src/dolby_ms12.cpp b/decoder/libms12_v24/src/dolby_ms12.cpp
index faaa4e1..88b7e66 100644
--- a/decoder/libms12_v24/src/dolby_ms12.cpp
+++ b/decoder/libms12_v24/src/dolby_ms12.cpp
@@ -610,27 +610,6 @@
return -1;
}
-extern "C" int dolby_ms12_get_ac4_active_presentation(int *presentation_group_index)
-{
- ALOGV("%s()\n", __FUNCTION__);
- android::DolbyMS12* dolby_ms12_instance = getInstance();
- if (dolby_ms12_instance) {
- return dolby_ms12_instance->DolbyMS12GetAC4ActivePresentation(presentation_group_index);
- }
- return -1;
-}
-
-extern "C" int dolby_ms12_ac4dec_check_the_pgi_is_present(int presentation_group_index)
-{
- ALOGV("%s()\n", __FUNCTION__);
- android::DolbyMS12* dolby_ms12_instance = getInstance();
- if (dolby_ms12_instance) {
- return dolby_ms12_instance->DolbyMS12AC4DecCheckThePgiIsPresent(presentation_group_index);
- }
- return -1;
-}
-
-
extern "C" int dolby_ms12_set_alsa_limit_frame(int limit_frame)
{
ALOGV("%s()\n", __FUNCTION__);