diff --git a/frameworks/native/hdiadapter_new/source/audio_capture_source.cpp b/frameworks/native/hdiadapter_new/source/audio_capture_source.cpp index 3fd7f70fe83f7efea84e3f252fc8338948dcabae..8e1986d7a8a9e088509509b5e3de2f9981317a12 100644 --- a/frameworks/native/hdiadapter_new/source/audio_capture_source.cpp +++ b/frameworks/native/hdiadapter_new/source/audio_capture_source.cpp @@ -805,9 +805,10 @@ void AudioCaptureSource::InitAudioSampleAttr(struct AudioSampleAttributes ¶m param.format = ConvertToHdiFormat(attr_.format); param.isBigEndian = attr_.isBigEndian; param.channelCount = attr_.channel; - param.channelLayout = attr_.channelLayout; - if (param.channelLayout == CH_LAYOUT_UNKNOWN) { - param.channelLayout = GetChannelLayoutByChannelCount(attr_.channel); + param.channelLayout = GetChannelLayoutByChannelCount(attr_.channel); + if (param.channelLayout != attr_.channelLayout) { + AUDIO_ERR_LOG("channelLayout:%{public} "PRIu64 "convert by channel," + "not match channelLayout:%{public}"PRIu64 "in attr_", param.channelLayout, attr_.channelLayout); } param.silenceThreshold = attr_.bufferSize; param.frameSize = param.format * param.channelCount; diff --git a/frameworks/native/hdiadapter_new/test/unittest/source/audio_capture_source_unit_test.cpp b/frameworks/native/hdiadapter_new/test/unittest/source/audio_capture_source_unit_test.cpp index a40e03150a874467f0e7a0cf2c309d7b516b0118..a65f5bbc3abd84ec3881677f317a6a43e05f5841 100644 --- a/frameworks/native/hdiadapter_new/test/unittest/source/audio_capture_source_unit_test.cpp +++ b/frameworks/native/hdiadapter_new/test/unittest/source/audio_capture_source_unit_test.cpp @@ -73,7 +73,7 @@ void AudioCaptureSourceUnitTest::InitPrimarySource() attr_.sampleRate = 48000; // 48000: sample rate attr_.channel = 2; // 2: channel attr_.format = SAMPLE_S16LE; - attr_.channelLayout = 3; // 3: channel layout + attr_.channelLayout = CH_LAYOUT_UNKNOWN; attr_.deviceType = DEVICE_TYPE_MIC; attr_.openMicSpeaker = 1; primarySource_->Init(attr_); diff --git a/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp b/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp index c6fc04f8485d1fe95901b3a0043024fb1ddbcc2e..dbd71971a5ea08b6c4499af470f694a7ef3b3f21 100644 --- a/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp +++ b/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp @@ -1976,6 +1976,7 @@ IAudioSinkAttr AudioAdapterManager::GetAudioSinkAttr(const AudioModuleInfo &audi attr.sampleRate = static_cast(std::stoul(audioModuleInfo.rate)); } if (!audioModuleInfo.channels.empty()) { + AUDIO_INFO_LOG("use custom channel:%{public}s", audioModuleInfo.channels.c_str()); attr.channel = static_cast(std::stoul(audioModuleInfo.channels)); } attr.volume = HDI_MAX_SINK_VOLUME_LEVEL;