From 655575aed93af956b2bb76630aa79dd7061980e2 Mon Sep 17 00:00:00 2001 From: linyuanpeng Date: Sat, 18 May 2024 15:57:40 +0800 Subject: [PATCH] dfx hisysevent for effect Signed-off-by: linyuanpeng --- hisysevent.yaml | 16 ++++++++- .../native/audiocommon/include/audio_effect.h | 11 +++++++ .../native/audiocommon/include/audio_info.h | 21 ++++++++++-- .../server/src/audio_stream_collector.cpp | 33 +++++++++++++++++++ .../service/config/audio_converter_parser.cpp | 21 ------------ .../src/audio_spatial_channel_converter.cpp | 14 +++++++- .../client/src/capturer_in_client.cpp | 2 ++ .../client/src/renderer_in_client.cpp | 3 ++ .../server/src/audio_effect_server.cpp | 9 +++++ 9 files changed, 105 insertions(+), 25 deletions(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index d91eafb75c..ccdb12de8d 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -63,6 +63,10 @@ LOAD_CONFIG_ERROR: __BASE: {type: FAULT, level: CRITICAL, desc: load configuration failed on audio policy service startup} CATEGORY: {type: UINT16, desc: category of audio policy configuration in uint16} +LOAD_EFFECT_ENGINE_ERROR: + __BASE: {type: FAULT, level: CRITICAL, desc: load effect engine failed on audio service startup} + ENGINE_TYPE: {type: UINT16, desc: type of audio effect engine in uint16} + AUDIO_SERVICE_STARTUP_ERROR: __BASE: {type: FAULT, level: CRITICAL, desc: audio service start up failed} SERVICE_ID: {type: UINT8, desc: audio service id} @@ -81,13 +85,23 @@ AUDIO_STREAM_CREATE_ERROR_STATS: ERROR_CODE: {type: INT32, desc: error code} TIMES: {type: UINT32, desc: how many times when this error happen} +STREAM_PROPERTY_STATS: + __BASE: {type: STATISTIC, level: MINOR, desc: audio stream property statistic} + IS_PLAYBACK: {type: BOOL, desc: created stream is used for playback or capture} + STREAM_TYPE: {type: UINT8, desc: stream type which can be either StreamUsage in playback or SourceType in capture} + APP_NAME: {type: STRING, desc: Application name which is using this stream} + ENCODING_TYPE: {type: UINT8, desc: encoding type of this stream} + CHANNEL_LAYOUT: {type: UINT64, desc: channel layout of this stream} + DURATION: {type: UINT32, desc: duration of this stream} + STREAM_UTILIZATION_STATS: __BASE: {type: STATISTIC, level: MINOR, desc: audio stream utilization statistic} - IS_PLAYBACK: {type: BOOL, desc: this stream is used for playback or capture} + IS_PLAYBACK: {type: BOOL, desc: created stream is used for playback or capture} STREAM_TYPE: {type: UINT8, desc: stream type which can be either StreamUsage in playback or SourceType in capture} PIPE_TYPE: {type: UINT8, desc: pipe type e.g. normal/lowlatency/offload/multichannel e.t.c.} APP_NAME: {type: STRING, desc: Application name which is using this stream} SAMPLE_RATE: {type: UINT32, desc: sample rate of this stream} + EFFECT_CHAIN: {type: UINT8, desc: effect chain of this stream} DURATION: {type: UINT32, desc: duration of this stream} AUDIO_DEVICE_UTILIZATION_STATS: diff --git a/interfaces/inner_api/native/audiocommon/include/audio_effect.h b/interfaces/inner_api/native/audiocommon/include/audio_effect.h index 3e3f6460eb..1db24a75fe 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_effect.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_effect.h @@ -308,6 +308,17 @@ const std::unordered_map> HDI_EFFECT_LIB_MA {DEVICE_TYPE_BLUETOOTH_A2DP, {"libspatialization_processing_dsp", "aaaabbbb-8888-9999-6666-aabbccdd9966gg"}}, }; +const std::unordered_map EFFECT_CHAIN_TYPE_MAP { + {"UNKNOWN", 0}, + {"NONE", 1}, + {"SCENE_MUSIC", 2}, + {"SCENE_MOVIE", 3}, + {"SCENE_GAME", 4}, + {"SCENE_SPEECH", 5}, + {"SCENE_RING", 6}, + {"SCENE_OTHERS", 7} +} ; + struct AudioRendererInfoForSpatialization { RendererState rendererState; std::string deviceMacAddress; diff --git a/interfaces/inner_api/native/audiocommon/include/audio_info.h b/interfaces/inner_api/native/audiocommon/include/audio_info.h index 0a0fbd8db5..d9bf8b6dd0 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_info.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_info.h @@ -313,6 +313,9 @@ struct AudioRendererInfo { bool headTrackingEnabled = false; AudioPipeType pipeType = PIPE_TYPE_UNKNOWN; AudioSamplingRate samplingRate = SAMPLE_RATE_8000; + uint8_t encodingType = 0; + uint64_t channelLayout = 0ULL; + bool Marshalling(Parcel &parcel) const { return parcel.WriteInt32(static_cast(contentType)) @@ -322,7 +325,9 @@ struct AudioRendererInfo { && parcel.WriteBool(spatializationEnabled) && parcel.WriteBool(headTrackingEnabled) && parcel.WriteInt32(static_cast(pipeType)) - && parcel.WriteInt32(static_cast(samplingRate)); + && parcel.WriteInt32(static_cast(samplingRate)) + && parcel.WriteUint8(encodingType) + && parcel.WriteUint64(channelLayout); } void Unmarshalling(Parcel &parcel) { @@ -334,6 +339,8 @@ struct AudioRendererInfo { headTrackingEnabled = parcel.ReadBool(); pipeType = static_cast(parcel.ReadInt32()); samplingRate = static_cast(parcel.ReadInt32()); + encodingType = parcel.ReadUint8(); + channelLayout = parcel.ReadUint64(); } }; @@ -343,6 +350,10 @@ public: int32_t capturerFlags = 0; AudioPipeType pipeType = PIPE_TYPE_UNKNOWN; AudioSamplingRate samplingRate = SAMPLE_RATE_8000; + uint8_t encodingType = 0; + uint64_t channelLayout = 0ULL; + std::string sceneType = ""; + AudioCapturerInfo(SourceType sourceType_, int32_t capturerFlags_) : sourceType(sourceType_), capturerFlags(capturerFlags_) {} AudioCapturerInfo(const AudioCapturerInfo &audioCapturerInfo) @@ -356,7 +367,10 @@ public: return parcel.WriteInt32(static_cast(sourceType)) && parcel.WriteInt32(capturerFlags) && parcel.WriteInt32(static_cast(pipeType)) - && parcel.WriteInt32(static_cast(samplingRate)); + && parcel.WriteInt32(static_cast(samplingRate)) + && parcel.WriteUint8(encodingType) + && parcel.WriteUint64(channelLayout) + && parcel.WriteString(sceneType); } void Unmarshalling(Parcel &parcel) { @@ -364,6 +378,9 @@ public: capturerFlags = parcel.ReadInt32(); pipeType = static_cast(parcel.ReadInt32()); samplingRate = static_cast(parcel.ReadInt32()); + encodingType = parcel.ReadUint8(); + channelLayout = parcel.ReadUint64(); + sceneType = parcel.ReadString(); } }; diff --git a/services/audio_policy/server/src/audio_stream_collector.cpp b/services/audio_policy/server/src/audio_stream_collector.cpp index a74bd9bc00..8e175886f4 100644 --- a/services/audio_policy/server/src/audio_stream_collector.cpp +++ b/services/audio_policy/server/src/audio_stream_collector.cpp @@ -878,6 +878,12 @@ void AudioStreamCollector::WriterRenderStreamChangeSysEvent(AudioStreamChangeInf streamChangeInfo.audioRendererChangeInfo.rendererInfo.streamUsage); uint64_t transactionId = audioSystemMgr_->GetTransactionId( streamChangeInfo.audioRendererChangeInfo.outputDeviceInfo.deviceType, OUTPUT_DEVICE); + + uint8_t effectChainType = EFFECT_CHAIN_TYPE_MAP.count( + streamChangeInfo.audioRendererChangeInfo.rendererInfo.sceneType) ? + EFFECT_CHAIN_TYPE_MAP.at(streamChangeInfo.audioRendererChangeInfo.rendererInfo.sceneType) : + EFFECT_CHAIN_TYPE_MAP.at("UNKNOWN"); + std::shared_ptr bean = std::make_shared( Media::MediaMonitor::AUDIO, Media::MediaMonitor::STREAM_CHANGE, Media::MediaMonitor::BEHAVIOR_EVENT); @@ -894,6 +900,9 @@ void AudioStreamCollector::WriterRenderStreamChangeSysEvent(AudioStreamChangeInf bean->Add("STREAM_TYPE", streamChangeInfo.audioRendererChangeInfo.rendererInfo.streamUsage); bean->Add("SAMPLE_RATE", streamChangeInfo.audioRendererChangeInfo.rendererInfo.samplingRate); bean->Add("NETWORKID", streamChangeInfo.audioRendererChangeInfo.outputDeviceInfo.networkId); + bean->Add("ENCODING_TYPE", streamChangeInfo.audioRendererChangeInfo.rendererInfo.encodingType); + bean->Add("CHANNEL_LAYOUT", streamChangeInfo.audioRendererChangeInfo.rendererInfo.channelLayout); + bean->Add("EFFECT_CHAIN", effectChainType); Media::MediaMonitor::MediaMonitorManager::GetInstance().WriteLogMsg(bean); } @@ -905,6 +914,11 @@ void AudioStreamCollector::WriterCaptureStreamChangeSysEvent(AudioStreamChangeIn uint64_t transactionId = audioSystemMgr_->GetTransactionId( streamChangeInfo.audioCapturerChangeInfo.inputDeviceInfo.deviceType, INPUT_DEVICE); + uint8_t effectChainType = EFFECT_CHAIN_TYPE_MAP.count( + streamChangeInfo.audioCapturerChangeInfo.capturerInfo.sceneType) ? + EFFECT_CHAIN_TYPE_MAP.at(streamChangeInfo.audioCapturerChangeInfo.capturerInfo.sceneType) : + EFFECT_CHAIN_TYPE_MAP.at("UNKNOWN"); + std::shared_ptr bean = std::make_shared( Media::MediaMonitor::AUDIO, Media::MediaMonitor::STREAM_CHANGE, Media::MediaMonitor::BEHAVIOR_EVENT); @@ -922,6 +936,9 @@ void AudioStreamCollector::WriterCaptureStreamChangeSysEvent(AudioStreamChangeIn bean->Add("SAMPLE_RATE", streamChangeInfo.audioCapturerChangeInfo.capturerInfo.samplingRate); bean->Add("MUTED", streamChangeInfo.audioCapturerChangeInfo.muted); bean->Add("NETWORKID", streamChangeInfo.audioCapturerChangeInfo.inputDeviceInfo.networkId); + bean->Add("ENCODING_TYPE", streamChangeInfo.audioCapturerChangeInfo.capturerInfo.encodingType); + bean->Add("CHANNEL_LAYOUT", streamChangeInfo.audioCapturerChangeInfo.capturerInfo.channelLayout); + bean->Add("EFFECT_CHAIN", effectChainType); Media::MediaMonitor::MediaMonitorManager::GetInstance().WriteLogMsg(bean); } @@ -934,6 +951,11 @@ void AudioStreamCollector::WriteRenderStreamReleaseSysEvent( uint64_t transactionId = audioSystemMgr_->GetTransactionId( audioRendererChangeInfo->outputDeviceInfo.deviceType, OUTPUT_DEVICE); + uint8_t effectChainType = EFFECT_CHAIN_TYPE_MAP.count( + audioRendererChangeInfo->rendererInfo.sceneType) ? + EFFECT_CHAIN_TYPE_MAP.at(audioRendererChangeInfo->rendererInfo.sceneType) : + EFFECT_CHAIN_TYPE_MAP.at("UNKNOWN"); + std::shared_ptr bean = std::make_shared( Media::MediaMonitor::AUDIO, Media::MediaMonitor::STREAM_CHANGE, Media::MediaMonitor::BEHAVIOR_EVENT); @@ -950,6 +972,9 @@ void AudioStreamCollector::WriteRenderStreamReleaseSysEvent( bean->Add("STREAM_TYPE", audioRendererChangeInfo->rendererInfo.streamUsage); bean->Add("SAMPLE_RATE", audioRendererChangeInfo->rendererInfo.samplingRate); bean->Add("NETWORKID", audioRendererChangeInfo->outputDeviceInfo.networkId); + bean->Add("ENCODING_TYPE", audioRendererChangeInfo->rendererInfo.encodingType); + bean->Add("CHANNEL_LAYOUT", audioRendererChangeInfo->rendererInfo.channelLayout); + bean->Add("EFFECT_CHAIN", effectChainType); Media::MediaMonitor::MediaMonitorManager::GetInstance().WriteLogMsg(bean); } @@ -960,6 +985,11 @@ void AudioStreamCollector::WriteCaptureStreamReleaseSysEvent( uint64_t transactionId = audioSystemMgr_->GetTransactionId( audioCapturerChangeInfo->inputDeviceInfo.deviceType, INPUT_DEVICE); + uint8_t effectChainType = EFFECT_CHAIN_TYPE_MAP.count( + audioCapturerChangeInfo->capturerInfo.sceneType) ? + EFFECT_CHAIN_TYPE_MAP.at(audioCapturerChangeInfo->capturerInfo.sceneType) : + EFFECT_CHAIN_TYPE_MAP.at("UNKNOWN"); + std::shared_ptr bean = std::make_shared( Media::MediaMonitor::AUDIO, Media::MediaMonitor::STREAM_CHANGE, Media::MediaMonitor::BEHAVIOR_EVENT); @@ -977,6 +1007,9 @@ void AudioStreamCollector::WriteCaptureStreamReleaseSysEvent( bean->Add("SAMPLE_RATE", audioCapturerChangeInfo->capturerInfo.samplingRate); bean->Add("MUTED", audioCapturerChangeInfo->muted); bean->Add("NETWORKID", audioCapturerChangeInfo->inputDeviceInfo.networkId); + bean->Add("ENCODING_TYPE", audioCapturerChangeInfo->capturerInfo.encodingType); + bean->Add("CHANNEL_LAYOUT", audioCapturerChangeInfo->capturerInfo.channelLayout); + bean->Add("EFFECT_CHAIN", effectChainType); Media::MediaMonitor::MediaMonitorManager::GetInstance().WriteLogMsg(bean); } } // namespace AudioStandard diff --git a/services/audio_policy/server/src/service/config/audio_converter_parser.cpp b/services/audio_policy/server/src/service/config/audio_converter_parser.cpp index 372768081a..3bb197459c 100644 --- a/services/audio_policy/server/src/service/config/audio_converter_parser.cpp +++ b/services/audio_policy/server/src/service/config/audio_converter_parser.cpp @@ -108,29 +108,8 @@ static void WriteConverterConfigError() static void ParseEffectConfigFile(xmlDoc* &doc) { -#ifdef USE_CONFIG_POLICY - CfgFiles *cfgFiles = GetCfgFiles(AUDIO_CONVERTER_CONFIG_FILE); - if (cfgFiles == nullptr) { - AUDIO_ERR_LOG("Not found audio_converter_config.xml!"); - WriteConverterConfigError(); - return; - } - for (int32_t i = MAX_CFG_POLICY_DIRS_CNT - 1; i >= 0; i--) { - if (cfgFiles->paths[i] && *(cfgFiles->paths[i]) != '\0') { - AUDIO_INFO_LOG("converter config file path:%{public}s", cfgFiles->paths[i]); - doc = xmlReadFile(cfgFiles->paths[i], nullptr, XML_PARSE_NOERROR | XML_PARSE_NOWARNING); - break; - } - } - FreeCfgFiles(cfgFiles); -#else AUDIO_INFO_LOG("use default audio effect config file path: %{public}s", AUDIO_CONVERTER_CONFIG_FILE); doc = xmlReadFile(AUDIO_CONVERTER_CONFIG_FILE, nullptr, XML_PARSE_NOERROR | XML_PARSE_NOWARNING); -#endif - if (doc == nullptr) { - WriteConverterConfigError(); - return; - } } AudioConverterParser::AudioConverterParser() diff --git a/services/audio_service/client/src/audio_spatial_channel_converter.cpp b/services/audio_service/client/src/audio_spatial_channel_converter.cpp index cf2359ee85..c97ae6baaf 100644 --- a/services/audio_service/client/src/audio_spatial_channel_converter.cpp +++ b/services/audio_service/client/src/audio_spatial_channel_converter.cpp @@ -20,6 +20,7 @@ #include #include #include +#include "media_monitor_manager.h" namespace OHOS { namespace AudioStandard { @@ -228,7 +229,18 @@ bool LibLoader::AddAlgoHandle(Library library) libEntry_ = std::make_unique(); libEntry_->libraryName = library.name; bool loadLibrarySuccess = LoadLibrary(library.path); - CHECK_AND_RETURN_RET_LOG(loadLibrarySuccess, false, " loadLibrary fail, please check logs!"); + if (!loadLibrarySuccess) { + // hisysevent for load engine error + std::shared_ptr bean = std::make_shared( + Media::MediaMonitor::AUDIO, Media::MediaMonitor::LOAD_EFFECT_ENGINE_ERROR, + Media::MediaMonitor::FAULT_EVENT); + bean->Add("ENGINE_TYPE", Media::MediaMonitor::AUDIO_CONVERTER_ENGINE); + Media::MediaMonitor::MediaMonitorManager::GetInstance().WriteLogMsg(bean); + + AUDIO_ERR_LOG("loadLibrary fail, please check logs!"); + return false; + } + int32_t ret = libEntry_->audioEffectLibHandle->createEffect(descriptor, &handle_); CHECK_AND_RETURN_RET_LOG(ret == 0, false, "%{public}s create fail", library.name.c_str()); return true; diff --git a/services/audio_service/client/src/capturer_in_client.cpp b/services/audio_service/client/src/capturer_in_client.cpp index f057e5e765..f6934dfae3 100644 --- a/services/audio_service/client/src/capturer_in_client.cpp +++ b/services/audio_service/client/src/capturer_in_client.cpp @@ -439,6 +439,8 @@ void CapturerInClientInner::SetCapturerInfo(const AudioCapturerInfo &capturerInf capturerInfo_ = capturerInfo; capturerInfo_.pipeType = PIPE_TYPE_NORMAL_IN; capturerInfo_.samplingRate = static_cast(streamParams_.samplingRate); + capturerInfo_.encodingType = streamParams_.encoding; + capturerInfo_.channelLayout = streamParams_.channelLayout; AUDIO_INFO_LOG("SetCapturerInfo with SourceType %{public}d flag %{public}d", capturerInfo_.sourceType, capturerInfo_.capturerFlags); return; diff --git a/services/audio_service/client/src/renderer_in_client.cpp b/services/audio_service/client/src/renderer_in_client.cpp index b7cb317f22..f4cbbdfd07 100644 --- a/services/audio_service/client/src/renderer_in_client.cpp +++ b/services/audio_service/client/src/renderer_in_client.cpp @@ -188,6 +188,9 @@ void RendererInClientInner::SetRendererInfo(const AudioRendererInfo &rendererInf AudioPolicyManager::GetInstance().GetSpatializationState(rendererInfo_.streamUsage); rendererInfo_.spatializationEnabled = spatializationState.spatializationEnabled; rendererInfo_.headTrackingEnabled = spatializationState.headTrackingEnabled; + rendererInfo_.encodingType = curStreamParams_.encoding; + rendererInfo_.channelLayout = curStreamParams_.channelLayout; + if (GetOffloadEnable()) { rendererInfo_.pipeType = PIPE_TYPE_OFFLOAD; } else if (GetHighResolutionEnabled()) { diff --git a/services/audio_service/server/src/audio_effect_server.cpp b/services/audio_service/server/src/audio_effect_server.cpp index 65be1fac7d..182523a73c 100644 --- a/services/audio_service/server/src/audio_effect_server.cpp +++ b/services/audio_service/server/src/audio_effect_server.cpp @@ -23,6 +23,7 @@ #include "unistd.h" #include "audio_log.h" #include "audio_effect_server.h" +#include "media_monitor_manager.h" namespace OHOS { namespace AudioStandard { @@ -92,6 +93,14 @@ static void LoadLibraries(const std::vector &libs, std::vector loadLibrary fail, please check logs!"); + + // hisysevent for load engine error + std::shared_ptr bean = std::make_shared( + Media::MediaMonitor::AUDIO, Media::MediaMonitor::LOAD_EFFECT_ENGINE_ERROR, + Media::MediaMonitor::FAULT_EVENT); + bean->Add("ENGINE_TYPE", Media::MediaMonitor::AUDIO_EFFECT_PROCESS_ENGINE); + Media::MediaMonitor::MediaMonitorManager::GetInstance().WriteLogMsg(bean); + continue; } -- Gitee