From cfe6018118135237c11b14f4ce608211a2895666 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 26 Aug 2025 11:27:10 +0800 Subject: [PATCH] review fix Signed-off-by: Charles --- .../node/src/hpae_node_common.cpp | 44 +++++++++---------- .../server/src/audio_server_hpae_dump.cpp | 6 +-- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/services/audio_engine/node/src/hpae_node_common.cpp b/services/audio_engine/node/src/hpae_node_common.cpp index c0ed5d1e3f..853753c32e 100644 --- a/services/audio_engine/node/src/hpae_node_common.cpp +++ b/services/audio_engine/node/src/hpae_node_common.cpp @@ -278,7 +278,7 @@ AudioSampleFormat TransFormatFromStringToEnum(std::string format) void AdjustMchSinkInfo(const AudioModuleInfo &audioModuleInfo, HpaeSinkInfo &sinkInfo) { if (sinkInfo.deviceName == "DP_MCH_speaker") { - sinkInfo.channelLayout = static_cast(std::atol(audioModuleInfo.channelLayout.c_str())); + sinkInfo.channelLayout = static_cast(std::stol(audioModuleInfo.channelLayout.c_str())); return; } if (sinkInfo.deviceName != "MCH_Speaker") { @@ -314,20 +314,20 @@ int32_t TransModuleInfoToHpaeSinkInfo(const AudioModuleInfo &audioModuleInfo, Hp sinkInfo.splitMode = audioModuleInfo.extra; sinkInfo.filePath = audioModuleInfo.fileName; - sinkInfo.samplingRate = static_cast(std::atol(audioModuleInfo.rate.c_str())); + sinkInfo.samplingRate = static_cast(std::stol(audioModuleInfo.rate.c_str())); sinkInfo.format = static_cast(TransFormatFromStringToEnum(audioModuleInfo.format)); - sinkInfo.channels = static_cast(std::atol(audioModuleInfo.channels.c_str())); - int32_t bufferSize = static_cast(std::atol(audioModuleInfo.bufferSize.c_str())); + sinkInfo.channels = static_cast(std::stol(audioModuleInfo.channels.c_str())); + int32_t bufferSize = static_cast(std::stol(audioModuleInfo.bufferSize.c_str())); sinkInfo.frameLen = static_cast(bufferSize) / (sinkInfo.channels * static_cast(GetSizeFromFormat(sinkInfo.format))); sinkInfo.channelLayout = 0ULL; - sinkInfo.deviceType = static_cast(std::atol(audioModuleInfo.deviceType.c_str())); + sinkInfo.deviceType = static_cast(std::stol(audioModuleInfo.deviceType.c_str())); sinkInfo.volume = MAX_SINK_VOLUME_LEVEL; - sinkInfo.openMicSpeaker = static_cast(std::atol(audioModuleInfo.OpenMicSpeaker.c_str())); - sinkInfo.renderInIdleState = static_cast(std::atol(audioModuleInfo.renderInIdleState.c_str())); - sinkInfo.offloadEnable = static_cast(std::atol(audioModuleInfo.offloadEnable.c_str())); - sinkInfo.sinkLatency = static_cast(std::atol(audioModuleInfo.sinkLatency.c_str())); - sinkInfo.fixedLatency = static_cast(std::atol(audioModuleInfo.fixedLatency.c_str())); + sinkInfo.openMicSpeaker = static_cast(std::stol(audioModuleInfo.OpenMicSpeaker.c_str())); + sinkInfo.renderInIdleState = static_cast(std::stol(audioModuleInfo.renderInIdleState.c_str())); + sinkInfo.offloadEnable = static_cast(std::stol(audioModuleInfo.offloadEnable.c_str())); + sinkInfo.sinkLatency = static_cast(std::stol(audioModuleInfo.sinkLatency.c_str())); + sinkInfo.fixedLatency = static_cast(std::stol(audioModuleInfo.fixedLatency.c_str())); sinkInfo.deviceName = audioModuleInfo.name; AdjustMchSinkInfo(audioModuleInfo, sinkInfo); if (audioModuleInfo.needEmptyChunk) { @@ -347,30 +347,30 @@ int32_t TransModuleInfoToHpaeSourceInfo(const AudioModuleInfo &audioModuleInfo, sourceInfo.adapterName = audioModuleInfo.adapterName; sourceInfo.sourceName = audioModuleInfo.name; // built_in_mic sourceInfo.deviceName = audioModuleInfo.name; - sourceInfo.sourceType = static_cast(std::atol(audioModuleInfo.sourceType.c_str())); + sourceInfo.sourceType = static_cast(std::stol(audioModuleInfo.sourceType.c_str())); sourceInfo.filePath = audioModuleInfo.fileName; - int32_t bufferSize = static_cast(std::atol(audioModuleInfo.bufferSize.c_str())); - sourceInfo.channels = static_cast(std::atol(audioModuleInfo.channels.c_str())); + int32_t bufferSize = static_cast(std::stol(audioModuleInfo.bufferSize.c_str())); + sourceInfo.channels = static_cast(std::stol(audioModuleInfo.channels.c_str())); sourceInfo.format = TransFormatFromStringToEnum(audioModuleInfo.format); sourceInfo.frameLen = static_cast(bufferSize) / (sourceInfo.channels * static_cast(GetSizeFromFormat(sourceInfo.format))); - sourceInfo.samplingRate = static_cast(std::atol(audioModuleInfo.rate.c_str())); + sourceInfo.samplingRate = static_cast(std::stol(audioModuleInfo.rate.c_str())); sourceInfo.channelLayout = 0ULL; - sourceInfo.deviceType = static_cast(std::atol(audioModuleInfo.deviceType.c_str())); + sourceInfo.deviceType = static_cast(std::stol(audioModuleInfo.deviceType.c_str())); sourceInfo.volume = MAX_SINK_VOLUME_LEVEL; // 1.0f; - sourceInfo.ecType = static_cast(std::atol(audioModuleInfo.ecType.c_str())); + sourceInfo.ecType = static_cast(std::stol(audioModuleInfo.ecType.c_str())); sourceInfo.ecAdapterName = audioModuleInfo.ecAdapter; - sourceInfo.ecSamplingRate = static_cast(std::atol(audioModuleInfo.ecSamplingRate.c_str())); + sourceInfo.ecSamplingRate = static_cast(std::stol(audioModuleInfo.ecSamplingRate.c_str())); sourceInfo.ecFormat = TransFormatFromStringToEnum(audioModuleInfo.ecFormat); - sourceInfo.ecChannels = static_cast(std::atol(audioModuleInfo.ecChannels.c_str())); + sourceInfo.ecChannels = static_cast(std::stol(audioModuleInfo.ecChannels.c_str())); sourceInfo.ecFrameLen = DEFAULT_MULTICHANNEL_FRAME_LEN_MS * (sourceInfo.ecSamplingRate / MS_PER_SECOND); - sourceInfo.micRef = static_cast(std::atol(audioModuleInfo.openMicRef.c_str())); - sourceInfo.micRefSamplingRate = static_cast(std::atol(audioModuleInfo.micRefRate.c_str())); + sourceInfo.micRef = static_cast(std::stol(audioModuleInfo.openMicRef.c_str())); + sourceInfo.micRefSamplingRate = static_cast(std::stol(audioModuleInfo.micRefRate.c_str())); sourceInfo.micRefFormat = TransFormatFromStringToEnum(audioModuleInfo.micRefFormat); - sourceInfo.micRefChannels = static_cast(std::atol(audioModuleInfo.micRefChannels.c_str())); - sourceInfo.openMicSpeaker = static_cast(std::atol(audioModuleInfo.OpenMicSpeaker.c_str())); + sourceInfo.micRefChannels = static_cast(std::stol(audioModuleInfo.micRefChannels.c_str())); + sourceInfo.openMicSpeaker = static_cast(std::stol(audioModuleInfo.OpenMicSpeaker.c_str())); sourceInfo.micRefFrameLen = DEFAULT_MULTICHANNEL_FRAME_LEN_MS * (sourceInfo.micRefSamplingRate / MS_PER_SECOND); return SUCCESS; } diff --git a/services/audio_service/server/src/audio_server_hpae_dump.cpp b/services/audio_service/server/src/audio_server_hpae_dump.cpp index dac8dbd694..5d22601bfc 100644 --- a/services/audio_service/server/src/audio_server_hpae_dump.cpp +++ b/services/audio_service/server/src/audio_server_hpae_dump.cpp @@ -159,11 +159,7 @@ void AudioServerHpaeDump::ArgDataDump(std::string &dumpString, std::queue*dumpFuncMap[para])(dumpString); - return; - } else if (para == u"-p") { + if (para == u"-h" || para == u"-p") { dumpString.clear(); (this->*dumpFuncMap[para])(dumpString); return; -- Gitee