diff --git a/audiohandler/BUILD.gn b/audiohandler/BUILD.gn index 1932bfc6cbb34cac527d6f283af157209c78a6ae..94edb8afa61f547ddee2e1cbf13bc2918861d876 100644 --- a/audiohandler/BUILD.gn +++ b/audiohandler/BUILD.gn @@ -43,6 +43,7 @@ ohos_shared_library("distributed_audio_handler") { "audio_framework:audio_renderer", "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "hilog:libhilog", ] defines = [ diff --git a/audiohandler/test/unittest/BUILD.gn b/audiohandler/test/unittest/BUILD.gn index e2b6b28d137094d9119c8837543a88fa15670b5f..08ee4b68965b0519cb8d58f8147813cc2d5a6e2a 100644 --- a/audiohandler/test/unittest/BUILD.gn +++ b/audiohandler/test/unittest/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("AudioHandlerTest") { external_deps = [ "audio_framework:audio_renderer", "c_utils:utils", + "hilog:libhilog", ] } diff --git a/common/dfx_utils/src/daudio_hidumper.cpp b/common/dfx_utils/src/daudio_hidumper.cpp index e5528fce0f18151c5ef69fa85fe30d0e96cadd2f..46f76bef1d38d7ed4c735e32af8c1c0c100b6fe8 100644 --- a/common/dfx_utils/src/daudio_hidumper.cpp +++ b/common/dfx_utils/src/daudio_hidumper.cpp @@ -57,9 +57,9 @@ DaudioHidumper::~DaudioHidumper() bool DaudioHidumper::Dump(const std::vector &args, std::string &result) { - DHLOGI("Distributed audio hidumper dump args.size():%d.", args.size()); result.clear(); int32_t argsSize = static_cast(args.size()); + DHLOGI("Distributed audio hidumper dump args.size():%d.", argsSize); for (int32_t i = 0; i < argsSize; i++) { DHLOGI("Distributed audio hidumper dump args[%d]: %s.", i, args.at(i).c_str()); } diff --git a/common/include/daudio_log.h b/common/include/daudio_log.h index f74e6865e40b1955a397a5e8875101e916935806..060b3ac738303eabf79b82c40c89d46d49c1cf6c 100644 --- a/common/include/daudio_log.h +++ b/common/include/daudio_log.h @@ -17,29 +17,24 @@ #define OHOS_DAUDIO_LOG_H #include "cJSON.h" +#include "hilog/log.h" + namespace OHOS { namespace DistributedHardware { -typedef enum { - DH_LOG_DEBUG, - DH_LOG_INFO, - DH_LOG_WARN, - DH_LOG_ERROR, -} DHLogLevel; - -void DHLog(DHLogLevel logLevel, const char *fmt, ...); - -#define DHLOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#undef LOG_TAG +#define LOG_TAG "DAUDIO" -#define DHLOGI(fmt, ...) DHLog(DH_LOG_INFO, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define DHLOGW(fmt, ...) DHLog(DH_LOG_WARN, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGI(fmt, ...) HILOG_INFO(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGW(fmt, ...) HILOG_WARN(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) +#define DHLOGE(fmt, ...) HILOG_ERROR(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) #define CHECK_NULL_VOID(ptr) \ do { \ if ((ptr) == nullptr) { \ diff --git a/common/src/daudio_latency_test.cpp b/common/src/daudio_latency_test.cpp index 1fd78732e18e31a0098131afddb5983e0d22149c..e5df608609c339b9e556c370a6016abe678326af 100644 --- a/common/src/daudio_latency_test.cpp +++ b/common/src/daudio_latency_test.cpp @@ -44,7 +44,6 @@ int32_t DAudioLatencyTest::AddPlayTime(const int64_t playBeepTime) DHLOGE("Catch play high frame, but not in %d ms.", TWO_BEEP_TIME_INTERVAL); return ERR_DH_AUDIO_FAILED; } - DHLOGI("Catch play high frame, playTime: %lld.", playBeepTime); playBeepTime_.push_back(playBeepTime); lastPlayTime_ = GetNowTimeUs(); return DH_SUCCESS; @@ -61,7 +60,6 @@ int32_t DAudioLatencyTest::AddRecordTime(const int64_t recordBeepTime) DHLOGE("Catch record high frame, but not in %d ms.", TWO_BEEP_TIME_INTERVAL); return ERR_DH_AUDIO_FAILED; } - DHLOGI("Catch record high frame, recordTime: %lld.", recordBeepTime); captureBeepTime_.push_back(recordBeepTime); lastRecordTime_ = GetNowTimeUs(); return DH_SUCCESS; @@ -98,16 +96,11 @@ int32_t DAudioLatencyTest::ComputeLatency() DHLOGD("Compute latency time."); int32_t playSize = static_cast(playBeepTime_.size()); if (playSize == 0 || playBeepTime_.size() != captureBeepTime_.size()) { - DHLOGE("Record num is not equal <%d, %d>", playSize, captureBeepTime_.size()); + DHLOGE("Record num is not equal"); return -1; } DHLOGI("Record %d times frame high.", playSize); int32_t sum = 0; - for (int32_t i = 0; i < playSize; i++) { - DHLOGI("Send: %lld, Received: %lld", playBeepTime_[i], captureBeepTime_[i]); - DHLOGI("Time is: %d ms.", (captureBeepTime_[i] - playBeepTime_[i]) / US_PER_MS); - sum += captureBeepTime_[i] - playBeepTime_[i]; - } DHLOGI("Audio latency in average is: %d us.", sum / playSize); playBeepTime_.clear(); captureBeepTime_.clear(); diff --git a/common/src/daudio_log.cpp b/common/src/daudio_log.cpp deleted file mode 100644 index d0ad61fe7924fc6d6312cba0e33a481c227f6c73..0000000000000000000000000000000000000000 --- a/common/src/daudio_log.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "daudio_log.h" - -#include "daudio_constants.h" -#include "securec.h" - -#ifdef HI_LOG_ENABLE -#include "hilog/log.h" -#else -#include -#endif - -namespace OHOS { -namespace DistributedHardware { -static void DHLogOut(DHLogLevel logLevel, const char *logBuf) -{ -#ifdef HI_LOG_ENABLE - LogLevel hiLogLevel = LOG_INFO; - switch (logLevel) { - case DH_LOG_DEBUG: - hiLogLevel = LOG_DEBUG; - break; - case DH_LOG_INFO: - hiLogLevel = LOG_INFO; - break; - case DH_LOG_WARN: - hiLogLevel = LOG_WARN; - break; - case DH_LOG_ERROR: - hiLogLevel = LOG_ERROR; - break; - default: - break; - } - (void)HiLogPrint(LOG_CORE, hiLogLevel, LOG_DOMAIN, DAUDIO_LOG_TITLE_TAG.c_str(), "%{public}s", logBuf); -#else - switch (logLevel) { - case DH_LOG_DEBUG: - printf("[D]%s\n", logBuf); - break; - case DH_LOG_INFO: - printf("[I]%s\n", logBuf); - break; - case DH_LOG_WARN: - printf("[W]%s\n", logBuf); - break; - case DH_LOG_ERROR: - printf("[E]%s\n", logBuf); - break; - default: - break; - } -#endif -} - -void DHLog(DHLogLevel logLevel, const char *fmt, ...) -{ - char logBuf[LOG_MAX_LEN] = {0}; - va_list arg; - va_start(arg, fmt); - - int32_t ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); - va_end(arg); - if (ret < 0) { - DHLogOut(logLevel, "DH log length error."); - return; - } - DHLogOut(logLevel, logBuf); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/common/src/daudio_util.cpp b/common/src/daudio_util.cpp index 8f3a6d0e720396e4aaf161ace19438d1941427ee..49a7111dde6503b32bcffc087fa47d5b54d43dfa 100644 --- a/common/src/daudio_util.cpp +++ b/common/src/daudio_util.cpp @@ -367,7 +367,7 @@ int32_t AbsoluteSleep(int64_t nanoTime) { int32_t ret = -1; if (nanoTime <= 0) { - DHLOGE("AbsoluteSleep invalid sleep time : %d ns", nanoTime); + DHLOGE("The nanoTime <= 0."); return ret; } struct timespec time; @@ -402,7 +402,7 @@ int64_t UpdateTimeOffset(const int64_t frameIndex, const int64_t framePeriodNs, bool CheckIsNum(const std::string &jsonString) { if (jsonString.empty() || jsonString.size() > MAX_KEY_DH_ID_LEN) { - DHLOGE("Json string size %d, is zero or too long.", jsonString.size()); + DHLOGE("Json string is zero or too long."); return false; } for (char const &c : jsonString) { @@ -417,7 +417,7 @@ bool CheckIsNum(const std::string &jsonString) bool CheckDevIdIsLegal(const std::string &devId) { if (devId.empty() || devId.size() > DAUDIO_MAX_DEVICE_ID_LEN) { - DHLOGE("DevId size %d, is zero or too long.", devId.size()); + DHLOGE("DevId size is zero or too long."); return false; } for (char const &c : devId) { diff --git a/common/test/unittest/BUILD.gn b/common/test/unittest/BUILD.gn index 168738bc148c4978e389c28346ecadee66425d17..17054354a22a1c54fd6945c2fad683cfdea449b4 100644 --- a/common/test/unittest/BUILD.gn +++ b/common/test/unittest/BUILD.gn @@ -45,7 +45,10 @@ ohos_unittest("DaudioUtilsTest") { "//third_party/googletest:gtest_main", ] - external_deps = [ "c_utils:utils" ] + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] defines = [ "HI_LOG_ENABLE", diff --git a/common/test/unittest/src/daudio_utils_test.cpp b/common/test/unittest/src/daudio_utils_test.cpp index 2521862fe2cdec15349ca840f35ebd8dfea3e6ec..1403f92eb37bd0204357e2c080b1c949c7459d69 100644 --- a/common/test/unittest/src/daudio_utils_test.cpp +++ b/common/test/unittest/src/daudio_utils_test.cpp @@ -136,11 +136,11 @@ HWTEST_F(DAudioUtilsTest, DAudioLatencyTest_003, TestSize.Level1) */ HWTEST_F(DAudioUtilsTest, DAudioUtilTest_001, TestSize.Level1) { + string args = "DHLog test"; DHLOGD("DAudio TDD test DHLOGD print."); - DHLOGI("DAudio TDD test DHLOGI print."); + DHLOGI("DAudio TDD test DHLOGI print %s.", args.c_str()); DHLOGW("DAudio TDD test DHLOGW print."); - DHLOGE("DAudio TDD test DHLOGE print."); - DHLog(DHLogLevel::DH_LOG_ERROR, ""); + DHLOGE("DAudio TDD test DHLOGE print %d.", 1); int64_t tvSec; int64_t tvNSec; GetCurrentTime(tvSec, tvNSec); diff --git a/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn index 268fbf79d19bb676b7e23e551d3c23c582c572d4..f47fceaf7bf6a6bcad22256f612cd47c389a6dd6 100755 --- a/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/audio_sink/BUILD.gn @@ -46,6 +46,7 @@ ohos_shared_library("distributed_audio_sink_sdk") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", diff --git a/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn b/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn index f86faa6d278dd469534439f9089b41328cdf39b0..439788397a80d89c7995954c68514f160e2482f2 100755 --- a/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/audio_source/BUILD.gn @@ -46,6 +46,7 @@ ohos_shared_library("distributed_audio_source_sdk") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", diff --git a/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/BUILD.gn index 88d30e02209a1f141164ab46c2d04496e396e209..3e4bc07a165de09c1ee4db80dadae902d7ec7d63 100755 --- a/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("AudioSinkTest") { external_deps = [ "c_utils:utils", + "hilog:libhilog", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/services/audioclient/micclient/src/dmic_client.cpp b/services/audioclient/micclient/src/dmic_client.cpp index 394a389b5cc9d7893d6dc8d9f08473239ca9bfe3..3159615dd3e76ea1437c91e0efab0559cd193791 100644 --- a/services/audioclient/micclient/src/dmic_client.cpp +++ b/services/audioclient/micclient/src/dmic_client.cpp @@ -153,7 +153,7 @@ int32_t DMicClient::TransSetUp() int32_t DMicClient::SetUp(const AudioParam ¶m) { - DHLOGI("Set up mic client, param: {sampleRate: %d, bitFormat: %d," + + DHLOGI("Set up mic client, param: {sampleRate: %d, bitFormat: %d," "channelMask: %d, sourceType: %d, capturerFlags: %d, frameSize: %d}.", param.comParam.sampleRate, param.comParam.bitFormat, param.comParam.channelMask, param.captureOpts.sourceType, param.captureOpts.capturerFlags, param.comParam.frameSize); @@ -252,8 +252,7 @@ void DMicClient::AudioFwkCaptureData() } int64_t endTime = GetNowTimeUs(); if (IsOutDurationRange(startTime, endTime, lastCaptureStartTime_)) { - DHLOGE("This time capture spend: %lld us, The interval of capture this time and the last time: %lld us", - endTime - startTime, startTime - lastCaptureStartTime_); + DHLOGE("The IsOutDurationRange return false"); } lastCaptureStartTime_ = startTime; } @@ -276,8 +275,7 @@ void DMicClient::AudioFwkCaptureData() } int64_t endTransTime = GetNowTimeUs(); if (IsOutDurationRange(startTransTime, endTransTime, lastTransStartTime_)) { - DHLOGE("This time send data spend: %lld us, The interval of send data this time and the last time: %lld us", - endTransTime - startTransTime, startTransTime - lastTransStartTime_); + DHLOGE("The IsOutDurationRange return false"); } lastTransStartTime_ = startTransTime; } @@ -312,8 +310,7 @@ void DMicClient::OnReadData(size_t length) std::shared_ptr audioData = std::make_shared(audioParam_.comParam.frameSize); if (audioData->Capacity() != bufDesc.bufLength) { - DHLOGE("Audio data length is not equal to buflength. datalength: %d, bufLength: %d", - audioData->Capacity(), bufDesc.bufLength); + DHLOGE("audioData->Capacity() != bufDesc.bufLength"); } if (memcpy_s(audioData->Data(), audioData->Capacity(), bufDesc.buffer, bufDesc.bufLength) != EOK) { DHLOGE("Copy audio data failed."); diff --git a/services/audioclient/spkclient/src/dspeaker_client.cpp b/services/audioclient/spkclient/src/dspeaker_client.cpp index 5a800462adb957621948ce4f981f387f968a8778..a6b95db0e438bdbe2be20e972dc6d169494af1e8 100644 --- a/services/audioclient/spkclient/src/dspeaker_client.cpp +++ b/services/audioclient/spkclient/src/dspeaker_client.cpp @@ -74,7 +74,7 @@ int32_t DSpeakerClient::InitReceiverEngine(IAVEngineProvider *providerPtr) int32_t DSpeakerClient::CreateAudioRenderer(const AudioParam ¶m) { - DHLOGD("Set up spk client: {sampleRate: %d, bitFormat: %d, channelMask: %d," + + DHLOGD("Set up spk client: {sampleRate: %d, bitFormat: %d, channelMask: %d," "frameSize: %d, contentType: %d, renderFlags: %d, streamUsage: %d}.", param.comParam.sampleRate, param.comParam.bitFormat, param.comParam.channelMask, param.comParam.frameSize, param.renderOpts.contentType, param.renderOpts.renderFlags, param.renderOpts.streamUsage); @@ -127,12 +127,11 @@ void DSpeakerClient::OnWriteData(size_t length) } else { audioData = dataQueue_.front(); dataQueue_.pop(); - DHLOGI("Pop spk data, dataQueue size: %d.", dataQueue_.size()); + DHLOGI("Pop spk data"); } } if (audioData->Capacity() != bufDesc.bufLength) { - DHLOGE("Audio data length is not equal to buflength. datalength: %d, bufLength: %d", - audioData->Capacity(), bufDesc.bufLength); + DHLOGE("Audio data length is not equal to buflength."); } if (memcpy_s(bufDesc.buffer, bufDesc.bufLength, audioData->Data(), audioData->Capacity()) != EOK) { DHLOGE("Copy audio data failed."); @@ -283,7 +282,7 @@ void DSpeakerClient::PlayThreadRunning() } audioData = dataQueue_.front(); dataQueue_.pop(); - DHLOGD("Pop spk data, dataqueue size: %d.", dataQueue_.size()); + DHLOGD("Pop spk data"); } #ifdef DUMP_DSPEAKERCLIENT_FILE if (DaudioSinkHidumper::GetInstance().QueryDumpDataFlag()) { @@ -294,7 +293,7 @@ void DSpeakerClient::PlayThreadRunning() while (writeOffSet < static_cast(audioData->Capacity())) { int32_t writeLen = audioRenderer_->Write(audioData->Data() + writeOffSet, static_cast(audioData->Capacity()) - writeOffSet); - DHLOGD("Write audio render, write len: %d, raw len: %d, offset: %d", writeLen, audioData->Capacity(), + DHLOGD("Write audio render, write len: %d, raw len: %zu, offset: %d", writeLen, audioData->Capacity(), writeOffSet); if (writeLen < 0) { break; @@ -303,8 +302,7 @@ void DSpeakerClient::PlayThreadRunning() } int64_t endTime = GetNowTimeUs(); if (IsOutDurationRange(startTime, endTime, lastPlayStartTime_)) { - DHLOGE("This time play spend: %lld us, The interval of play this time and the last time: %lld us", - endTime - startTime, startTime - lastPlayStartTime_); + DHLOGE("The IsOutDurationRange return false"); } lastPlayStartTime_ = startTime; } @@ -349,11 +347,10 @@ int32_t DSpeakerClient::OnDecodeTransDataDone(const std::shared_ptr & } dataQueue_.push(audioData); dataQueueCond_.notify_all(); - DHLOGI("Push new spk data, buf len: %d.", dataQueue_.size()); + DHLOGI("Push new spk data"); int64_t endTime = GetNowTimeUs(); if (IsOutDurationRange(startTime, endTime, lastReceiveStartTime_)) { - DHLOGE("This time receivce data spend: %lld us, Receivce data this time and the last time: %lld us", - endTime - startTime, startTime - lastReceiveStartTime_); + DHLOGE("The IsOutDurationRange return false"); } lastReceiveStartTime_ = startTime; return DH_SUCCESS; diff --git a/services/audiohdiproxy/src/daudio_manager_callback.cpp b/services/audiohdiproxy/src/daudio_manager_callback.cpp index f87c4807ee9fd326f8a7f919e7b6a22588a179b3..592eb965ed280d02590220bb48bb26c9712fb2cd 100644 --- a/services/audiohdiproxy/src/daudio_manager_callback.cpp +++ b/services/audiohdiproxy/src/daudio_manager_callback.cpp @@ -69,7 +69,7 @@ int32_t DAudioManagerCallback::GetAudioParamHDF(const AudioParameter& param, Aud paramHDF.bitFormat = AudioSampleFormat::SAMPLE_S24LE; break; default: - DHLOGE("Format [%zu] does not support conversion.", param.format); + DHLOGE("Format [%u] does not support conversion.", param.format); return HDF_FAILURE; } switch (static_cast(param.streamUsage)) { @@ -86,7 +86,7 @@ int32_t DAudioManagerCallback::GetAudioParamHDF(const AudioParameter& param, Aud paramHDF.streamUsage = StreamUsage::STREAM_USAGE_MEDIA; break; default: - DHLOGE("Stream usage [%zu] does not support conversion.", param.streamUsage); + DHLOGE("Stream usage [%u] does not support conversion.", param.streamUsage); return HDF_FAILURE; } paramHDF.frameSize = param.frameSize; @@ -94,8 +94,8 @@ int32_t DAudioManagerCallback::GetAudioParamHDF(const AudioParameter& param, Aud paramHDF.ext = param.ext; paramHDF.renderFlags = static_cast(param.renderFlags); paramHDF.capturerFlags = static_cast(param.capturerFlags); - DHLOGI("HDF Param: sample rate %d, channel %d, bit format %d, stream usage %d, frame size %zu, " + - "period %zu, renderFlags %d, capturerFlags %d, ext {%s}.", paramHDF.sampleRate, paramHDF.channelMask, + DHLOGI("HDF Param: sample rate %d, channel %d, bit format %d, stream usage %d, frame size %u," + "period %u, renderFlags %d, capturerFlags %d, ext {%s}.", paramHDF.sampleRate, paramHDF.channelMask, paramHDF.bitFormat, paramHDF.streamUsage, paramHDF.frameSize, paramHDF.period, paramHDF.renderFlags, paramHDF.capturerFlags, paramHDF.ext.c_str()); return HDF_SUCCESS; diff --git a/services/audiomanager/managersource/src/dmic_dev.cpp b/services/audiomanager/managersource/src/dmic_dev.cpp index de7a394de2efab9c6394841073b091f4071dba51..bf5ca4176dde04edd31e0c30f798c323655ae8b6 100644 --- a/services/audiomanager/managersource/src/dmic_dev.cpp +++ b/services/audiomanager/managersource/src/dmic_dev.cpp @@ -329,8 +329,7 @@ int32_t DMicDev::ReadStreamData(const std::string &devId, const int32_t dhId, st #endif int64_t endTime = GetNowTimeUs(); if (IsOutDurationRange(startTime, endTime, lastReadStartTime_)) { - DHLOGE("This time read data spend: %lld us, The interval of read data this time and the last time: %lld us", - endTime - startTime, startTime - lastReadStartTime_); + DHLOGE("The IsOutDurationRange return false"); } lastReadStartTime_ = startTime; return DH_SUCCESS; @@ -339,8 +338,6 @@ int32_t DMicDev::ReadStreamData(const std::string &devId, const int32_t dhId, st int32_t DMicDev::ReadMmapPosition(const std::string &devId, const int32_t dhId, uint64_t &frames, CurrentTimeHDF &time) { - DHLOGD("Read mmap position. frames: %lu, tvsec: %lu, tvNSec:%lu", - writeNum_, writeTvSec_, writeTvNSec_); frames = writeNum_; time.tvSec = writeTvSec_; time.tvNSec = writeTvNSec_; @@ -393,7 +390,6 @@ void DMicDev::EnqueueThread() while (ashmem_ != nullptr && isEnqueueRunning_.load()) { int64_t timeOffset = UpdateTimeOffset(frameIndex_, LOW_LATENCY_INTERVAL_NS, startTime_); - DHLOGD("Write frameIndex: %lld, timeOffset: %lld.", frameIndex_, timeOffset); std::shared_ptr audioData = nullptr; { std::lock_guard lock(dataQueueMtx_); @@ -513,11 +509,11 @@ int32_t DMicDev::OnDecodeTransDataDone(const std::shared_ptr &audioDa dataQueSize_ = param_.captureOpts.capturerFlags == MMAP_MODE ? dataQueSize_ : DATA_QUEUE_EXT_SIZE; } while (dataQueue_.size() > dataQueSize_) { - DHLOGD("Data queue overflow. buf current size: %d", dataQueue_.size()); + DHLOGD("Data queue overflow."); dataQueue_.pop(); } dataQueue_.push(audioData); - DHLOGD("Push new mic data, buf len: %d", dataQueue_.size()); + DHLOGD("Push new mic data"); return DH_SUCCESS; } } // DistributedHardware diff --git a/services/audiomanager/managersource/src/dspeaker_dev.cpp b/services/audiomanager/managersource/src/dspeaker_dev.cpp index 9207add5fad0995eaa5f3e05821822ad45d61270..a14a89760b1870850de1e7498d7ff4a836aff58b 100644 --- a/services/audiomanager/managersource/src/dspeaker_dev.cpp +++ b/services/audiomanager/managersource/src/dspeaker_dev.cpp @@ -314,8 +314,7 @@ int32_t DSpeakerDev::WriteStreamData(const std::string &devId, const int32_t dhI } int64_t endTime = GetNowTimeUs(); if (IsOutDurationRange(startTime, endTime, lastwriteStartTime_)) { - DHLOGE("This time write data spend: %lld us, The interval of write data this time and the last time: %lld us", - endTime - startTime, startTime - lastwriteStartTime_); + DHLOGE("The IsOutDurationRange return false"); } lastwriteStartTime_ = startTime; return DH_SUCCESS; @@ -324,8 +323,6 @@ int32_t DSpeakerDev::WriteStreamData(const std::string &devId, const int32_t dhI int32_t DSpeakerDev::ReadMmapPosition(const std::string &devId, const int32_t dhId, uint64_t &frames, CurrentTimeHDF &time) { - DHLOGD("Read mmap position. frames: %lu, tvsec: %lu, tvNSec:%lu", - readNum_, readTvSec_, readTvNSec_); frames = readNum_; time.tvSec = readTvSec_; time.tvNSec = readTvNSec_; @@ -375,7 +372,6 @@ void DSpeakerDev::EnqueueThread() while (ashmem_ != nullptr && isEnqueueRunning_.load()) { int64_t timeOffset = UpdateTimeOffset(frameIndex_, LOW_LATENCY_INTERVAL_NS, startTime_); - DHLOGD("Read frameIndex: %lld, timeOffset: %lld.", frameIndex_, timeOffset); auto readData = ashmem_->ReadFromAshmem(lengthPerTrans_, readIndex_); DHLOGI("Read from ashmem success! read index: %d, readLength: %d.", readIndex_, lengthPerTrans_); std::shared_ptr audioData = std::make_shared(lengthPerTrans_); diff --git a/services/audiomanager/servicesink/BUILD.gn b/services/audiomanager/servicesink/BUILD.gn index f5d8f5b2d8cb30a2fd3d011e356d8794660e7ea5..c10b887a5ae4e3179e49362aa1f6c09ac3181b0b 100755 --- a/services/audiomanager/servicesink/BUILD.gn +++ b/services/audiomanager/servicesink/BUILD.gn @@ -89,6 +89,7 @@ ohos_shared_library("distributed_audio_sink") { "eventhandler:libeventhandler", "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdi", + "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", diff --git a/services/audiomanager/servicesink/src/daudio_sink_hidumper.cpp b/services/audiomanager/servicesink/src/daudio_sink_hidumper.cpp index 5060b5043763cfe4a04afd21a00a09ca4dabb256..333b19320f21fad059da941ba9cdead4992dfaa9 100644 --- a/services/audiomanager/servicesink/src/daudio_sink_hidumper.cpp +++ b/services/audiomanager/servicesink/src/daudio_sink_hidumper.cpp @@ -53,11 +53,11 @@ DaudioSinkHidumper::~DaudioSinkHidumper() bool DaudioSinkHidumper::Dump(const std::vector &args, std::string &result) { - DHLOGI("Distributed audio hidumper dump args.size():%d.", args.size()); + DHLOGI("Distributed audio hidumper dump."); result.clear(); int32_t argsSize = static_cast(args.size()); for (int32_t i = 0; i < argsSize; i++) { - DHLOGI("Distributed audio hidumper dump args[%d]: %s.", i, args.at(i).c_str()); + DHLOGI("Distributed audio hidumper dump args: %s.", args.at(i).c_str()); } if (args.empty()) { diff --git a/services/audiomanager/servicesource/BUILD.gn b/services/audiomanager/servicesource/BUILD.gn index 64c6d106804d211507cb302ea5d62491197dc7ea..cdfbd5ea1ee8117da2f19730c28acb755df8b740 100755 --- a/services/audiomanager/servicesource/BUILD.gn +++ b/services/audiomanager/servicesource/BUILD.gn @@ -93,6 +93,7 @@ ohos_shared_library("distributed_audio_source") { "eventhandler:libeventhandler", "hdf_core:libhdi", "hicollie:libhicollie", + "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", diff --git a/services/audiomanager/test/unittest/managersink/BUILD.gn b/services/audiomanager/test/unittest/managersink/BUILD.gn index e0355657d9815c3a492da32d570056949f0a3ed2..f0518d38cd50f7a4b68dff68f60bd6cc08631352 100644 --- a/services/audiomanager/test/unittest/managersink/BUILD.gn +++ b/services/audiomanager/test/unittest/managersink/BUILD.gn @@ -82,6 +82,7 @@ ohos_unittest("DaudioSinkDevTest") { "hdf_core:libhdf_ipc_adapter", "hdf_core:libhdf_utils", "hdf_core:libhdi", + "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/audiomanager/test/unittest/sourcedevice/BUILD.gn b/services/audiomanager/test/unittest/sourcedevice/BUILD.gn index 15ab620157bef29ef4e18f0bc0e37f02319cc4a2..031fac430d37efdcfb3d51c2fa428c22ce393491 100644 --- a/services/audiomanager/test/unittest/sourcedevice/BUILD.gn +++ b/services/audiomanager/test/unittest/sourcedevice/BUILD.gn @@ -77,6 +77,7 @@ ohos_unittest("DaudioSourceDevTest") { "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", "dsoftbus:softbus_client", "eventhandler:libeventhandler", + "hilog:libhilog", "ipc:ipc_core", "samgr:samgr_proxy", ] @@ -102,6 +103,7 @@ ohos_unittest("DMicDevTest") { "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", + "hilog:libhilog", "ipc:ipc_core", "samgr:samgr_proxy", ] @@ -127,6 +129,7 @@ ohos_unittest("DSpeakerDevTest") { "distributed_hardware_fwk:distributed_av_receiver", "distributed_hardware_fwk:distributed_av_sender", "drivers_interface_distributed_audio:libdaudioext_proxy_1.0", + "hilog:libhilog", "ipc:ipc_core", "samgr:samgr_proxy", ] diff --git a/services/audiotransport/receiverengine/BUILD.gn b/services/audiotransport/receiverengine/BUILD.gn index bd3173babe3552bc805170eec46343e520fa30e6..27f9be4336a26addc2356fb93d0a0ce89b8605f6 100644 --- a/services/audiotransport/receiverengine/BUILD.gn +++ b/services/audiotransport/receiverengine/BUILD.gn @@ -61,6 +61,7 @@ ohos_shared_library("distributed_audio_decode_transport") { "c_utils:utils", "distributed_hardware_fwk:distributed_av_receiver", "dsoftbus:softbus_client", + "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "player_framework:media_client", diff --git a/services/audiotransport/senderengine/BUILD.gn b/services/audiotransport/senderengine/BUILD.gn index b5c936aad366f17ae430fe6e98071ce63ee8aea1..5c62331815aa9bc9d56c64422d431f5eb67778aa 100644 --- a/services/audiotransport/senderengine/BUILD.gn +++ b/services/audiotransport/senderengine/BUILD.gn @@ -61,6 +61,7 @@ ohos_shared_library("distributed_audio_encode_transport") { "c_utils:utils", "distributed_hardware_fwk:distributed_av_sender", "dsoftbus:softbus_client", + "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "player_framework:media_client", diff --git a/services/common/BUILD.gn b/services/common/BUILD.gn index 8c7fc46932c7468c82a708a7a6bc2cf6dd15c3b8..da1699b3ac7a4e5ca2c4b23c93ab1671243579aa 100644 --- a/services/common/BUILD.gn +++ b/services/common/BUILD.gn @@ -52,7 +52,6 @@ ohos_shared_library("distributed_audio_utils") { "${common_path}/dfx_utils/src/daudio_hisysevent.cpp", "${common_path}/dfx_utils/src/daudio_hitrace.cpp", "${common_path}/src/daudio_latency_test.cpp", - "${common_path}/src/daudio_log.cpp", "${common_path}/src/daudio_util.cpp", "audiodata/src/audio_data.cpp", ] diff --git a/services/hdfaudioclient/src/daudio_adapter_internal.cpp b/services/hdfaudioclient/src/daudio_adapter_internal.cpp index b6128c28084e09ca129fdfd97b4fd41d495f68ee..b78522e3c4e1ef5e6f86492dc6e9bafd9e1fbbc7 100644 --- a/services/hdfaudioclient/src/daudio_adapter_internal.cpp +++ b/services/hdfaudioclient/src/daudio_adapter_internal.cpp @@ -200,11 +200,11 @@ static int32_t GetPassthroughModeInternal(struct AudioAdapter *adapter, const st static int32_t InitAudioPortCapability(std::unique_ptr<::AudioPortCapability> &capInternal, AudioPortCapability &capabilityHal) { - DHLOGI("Init audio port capability internal, formatNum: %zu.", capabilityHal.formatNum); + DHLOGI("Init audio port capability internal, formatNum: %u.", capabilityHal.formatNum); constexpr uint32_t maxFormatNum = 100; constexpr uint32_t minFormatNum = 1; if (capabilityHal.formatNum < minFormatNum || capabilityHal.formatNum > maxFormatNum) { - DHLOGE("Init audio port capability, formatNum: %zu.", capabilityHal.formatNum); + DHLOGE("Init audio port capability, formatNum: %u.", capabilityHal.formatNum); return ERR_DH_AUDIO_HDI_INVALID_PARAM; } ::AudioFormat *audioFormats = (::AudioFormat *)malloc(capabilityHal.formatNum * sizeof(::AudioFormat)); diff --git a/services/hdfaudioclient/test/unittest/BUILD.gn b/services/hdfaudioclient/test/unittest/BUILD.gn index b483e6eceaa51875447a06b41be5bdda3985c3df..1a2b094899766cc643a5066e0f6a22bd4a4c7e1b 100644 --- a/services/hdfaudioclient/test/unittest/BUILD.gn +++ b/services/hdfaudioclient/test/unittest/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("AudioAdapterHdiTest") { external_deps = [ "drivers_interface_distributed_audio:libdaudio_proxy_1.0", + "hilog:libhilog", "ipc:ipc_core", ] @@ -75,7 +76,10 @@ ohos_unittest("AudioRenderInternalTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] - external_deps = [ "drivers_interface_distributed_audio:libdaudio_proxy_1.0" ] + external_deps = [ + "drivers_interface_distributed_audio:libdaudio_proxy_1.0", + "hilog:libhilog", + ] defines = [ "HI_LOG_ENABLE", @@ -106,7 +110,10 @@ ohos_unittest("AudioCaptureInternalTest") { "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] - external_deps = [ "drivers_interface_distributed_audio:libdaudio_proxy_1.0" ] + external_deps = [ + "drivers_interface_distributed_audio:libdaudio_proxy_1.0", + "hilog:libhilog", + ] defines = [ "HI_LOG_ENABLE", @@ -141,6 +148,7 @@ ohos_unittest("AudioAdapterInternalTest") { external_deps = [ "c_utils:utils", "drivers_interface_distributed_audio:libdaudio_proxy_1.0", + "hilog:libhilog", ] defines = [