diff --git a/audio/audio_hw.cpp b/audio/audio_hw.cpp index 7678423..7ecfa1f 100755 --- a/audio/audio_hw.cpp +++ b/audio/audio_hw.cpp @@ -83,6 +83,11 @@ struct pcm_config pcm_config_in = { }; #endif +/* store previous audio format for nugu_playback */ +static AMP_SND_SPDIF_FORMAT gSpdifFormat = AMP_SND_SPDIF_FORMAT_INVALID; +static AMP_SND_HDMI_FORMAT gHdmiFormat = AMP_SND_HDMI_FORMAT_INVALID; + + static uint32_t out_get_sample_rate(const struct audio_stream *stream) { ENTER("stream=%p", stream); @@ -1219,6 +1224,26 @@ static int adev_set_parameters(struct audio_hw_device *dev, gDevConStatus.nugu_playback_enabled = true; bAudioRouteChange = true; + // save audio format + AMP_SND_GetSpdifFormat(&gSpdifFormat); + AMP_SND_GetHDMIFormat(&gHdmiFormat); + + // set output mode as PCM or PCM multi when nugu is on + if(gHdmiFormat != AMP_SND_HDMI_FORMAT_PCM_MULTI) { + ret = AMP_SND_SetSpdifFormat(AMP_SND_SPDIF_FORMAT_STEREO_PCM); + if( ret != SUCCESS ) { + MVLOGE("fail to set AMP_SND_SetSpdifFormat() to AMP_SND_SPDIF_FORMAT_STEREO_PCM!!!"); + } else { + MVLOGD("change to Spdif format to PCM."); + } + ret = AMP_SND_SetHDMIFormat(AMP_SND_HDMI_FORMAT_PCM_MULTI); + if( ret != SUCCESS ) { + MVLOGE("fail to set AMP_SND_SetHDMIFormat () to AMP_SND_HDMI_FORMAT_PCM_MULTI!!!"); + } else { + MVLOGD("change to HDMI format to PCM."); + } + } + //Enable AMP when NUGU is playing. isAmpOn = property_get_int32(PROPERTY_VENDOR_AMP_STATUS, 1); if(isAmpOn == 0){ //AMP is off @@ -1237,6 +1262,22 @@ static int adev_set_parameters(struct audio_hw_device *dev, //Fii add end; River 2022/07/17 gDevConStatus.nugu_playback_enabled = false; bAudioRouteChange = true; + + // Change output format as saved one. + if(gHdmiFormat != AMP_SND_HDMI_FORMAT_INVALID) { + ret = AMP_SND_SetSpdifFormat(gSpdifFormat); + if( ret != SUCCESS ) { + MVLOGE("fail to set AMP_SND_SetSpdifFormat() to (%d)!!!", gSpdifFormat); + } else { + MVLOGD("change to Spdif format to (%d).", gSpdifFormat); + } + ret = AMP_SND_SetHDMIFormat(gHdmiFormat); + if( ret != SUCCESS ) { + MVLOGE("fail to set AMP_SND_SetHDMIFormat () to (%d)!!!", gHdmiFormat); + } else { + MVLOGD("change to HDMI format to (%d).", gHdmiFormat); + } + } } }