From 1f5f079b1dc24c7cdaf8318d0031134424c2c646 Mon Sep 17 00:00:00 2001 From: w30042960 Date: Thu, 31 Aug 2023 16:14:14 +0800 Subject: [PATCH] add define Signed-off-by: w30042960 --- .../audio/v1_0/src/audio_capture_interface_impl.cpp | 3 +++ .../hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp | 3 +++ services/audioclient/micclient/src/dmic_client.cpp | 3 +++ services/audioclient/spkclient/src/dspeaker_client.cpp | 3 +++ services/audiomanager/managersource/src/dmic_dev.cpp | 3 +++ services/audiomanager/managersource/src/dspeaker_dev.cpp | 3 +++ 6 files changed, 18 insertions(+) diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp index 083282ca..87f5da7c 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp @@ -27,6 +27,7 @@ #undef DH_LOG_TAG #define DH_LOG_TAG "AudioCaptureInterfaceImpl" +// define DUMP_CAPTURE_FILE for dump file using namespace OHOS::DistributedHardware; namespace OHOS { @@ -84,9 +85,11 @@ int32_t AudioCaptureInterfaceImpl::CaptureFrame(std::vector &frame, uint DHLOGE("Read stream data failed."); return HDF_FAILURE; } +#ifdef DUMP_CAPTURE_FILE if (dumpFlag_) { SaveFile(FILE_NAME, reinterpret_cast(audioData.data.data()), audioData.data.size()); } +#endif frame.resize(devAttrs_.frameSize); ret = memcpy_s(frame.data(), frame.size(), audioData.data.data(), audioData.data.size()); if (ret != EOK) { diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp index 7b1b9f9f..5da06110 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp @@ -26,6 +26,7 @@ #undef DH_LOG_TAG #define DH_LOG_TAG "AudioRenderInterfaceImpl" +// define DUMP_RENDER_FILE for dump file using namespace OHOS::DistributedHardware; namespace OHOS { @@ -101,9 +102,11 @@ int32_t AudioRenderInterfaceImpl::RenderFrame(const std::vector &frame, AudioParameter param = { devAttrs_.format, devAttrs_.channelCount, devAttrs_.sampleRate, 0, devAttrs_.frameSize}; AudioData data = { param, frame }; +#ifdef DUMP_RENDER_FILE if (dumpFlag_) { SaveFile(FILE_NAME, reinterpret_cast(data.data.data()), frame.size()); } +#endif FadeInProcess(DURATION_FRAMES, data.data.data(), frame.size()); if (audioExtCallback_ == nullptr) { DHLOGE("Callback is nullptr."); diff --git a/services/audioclient/micclient/src/dmic_client.cpp b/services/audioclient/micclient/src/dmic_client.cpp index 13f7c692..7ce19317 100644 --- a/services/audioclient/micclient/src/dmic_client.cpp +++ b/services/audioclient/micclient/src/dmic_client.cpp @@ -24,6 +24,7 @@ #undef DH_LOG_TAG #define DH_LOG_TAG "DMicClient" +// define DUMP_DMICCLIENT_FILE for dump file namespace OHOS { namespace DistributedHardware { @@ -508,9 +509,11 @@ void DMicClient::AudioFwkCaptureData() DHLOGE("Bytes read failed."); return; } +#ifdef DUMP_DMICCLIENT_FILE if (DaudioSinkHidumper::GetInstance().GetFlagStatus()) { SaveFile(FILE_NAME, const_cast(audioData->Data()), audioData->Size()); } +#endif int64_t startTransTime = GetNowTimeUs(); int32_t ret = micTrans_->FeedAudioData(audioData); if (ret != DH_SUCCESS) { diff --git a/services/audioclient/spkclient/src/dspeaker_client.cpp b/services/audioclient/spkclient/src/dspeaker_client.cpp index fb200608..08aaf14e 100644 --- a/services/audioclient/spkclient/src/dspeaker_client.cpp +++ b/services/audioclient/spkclient/src/dspeaker_client.cpp @@ -23,6 +23,7 @@ #undef DH_LOG_TAG #define DH_LOG_TAG "DSpeakerClient" +// define DUMP_DSPEAKERCLIENT_FILE for dump file namespace OHOS { namespace DistributedHardware { @@ -291,9 +292,11 @@ void DSpeakerClient::PlayThreadRunning() dataQueue_.pop(); DHLOGD("Pop spk data, dataqueue size: %d.", dataQueue_.size()); } +#ifdef DUMP_DSPEAKERCLIENT_FILE if (DaudioSinkHidumper::GetInstance().GetFlagStatus()) { SaveFile(FILE_NAME, const_cast(audioData->Data()), audioData->Size()); } +#endif int32_t writeOffSet = 0; while (writeOffSet < static_cast(audioData->Capacity())) { int32_t writeLen = audioRenderer_->Write(audioData->Data() + writeOffSet, diff --git a/services/audiomanager/managersource/src/dmic_dev.cpp b/services/audiomanager/managersource/src/dmic_dev.cpp index 2cf8d093..7c9ee791 100644 --- a/services/audiomanager/managersource/src/dmic_dev.cpp +++ b/services/audiomanager/managersource/src/dmic_dev.cpp @@ -32,6 +32,7 @@ #undef DH_LOG_TAG #define DH_LOG_TAG "DMicDev" +// define DUMP_DMICDEV_FILE for dump file namespace OHOS { namespace DistributedHardware { @@ -343,6 +344,7 @@ int32_t DMicDev::ReadStreamData(const std::string &devId, const int32_t dhId, st data = dataQueue_.front(); dataQueue_.pop(); } +#ifdef DUMP_DMICDEV_FILE if (DaudioHidumper::GetInstance().GetFlagStatus()) { if (!dumpFlag_) { AudioEvent event(NOTIFY_HDF_MIC_DUMP, ""); @@ -351,6 +353,7 @@ int32_t DMicDev::ReadStreamData(const std::string &devId, const int32_t dhId, st } SaveFile(FILE_NAME, const_cast(data->Data()), data->Size()); } +#endif int64_t endTime = GetNowTimeUs(); if (IsOutDurationRange(startTime, endTime, lastReadStartTime_)) { DHLOGE("This time read data spend: %lld, The interval of read data this time and the last time: %lld", diff --git a/services/audiomanager/managersource/src/dspeaker_dev.cpp b/services/audiomanager/managersource/src/dspeaker_dev.cpp index 4b7091b9..65f0ad26 100644 --- a/services/audiomanager/managersource/src/dspeaker_dev.cpp +++ b/services/audiomanager/managersource/src/dspeaker_dev.cpp @@ -34,6 +34,7 @@ #undef DH_LOG_TAG #define DH_LOG_TAG "DSpeakerDev" +// define DUMP_DSPEAKERDEV_FILE for dump file namespace OHOS { namespace DistributedHardware { @@ -346,6 +347,7 @@ int32_t DSpeakerDev::WriteStreamData(const std::string &devId, const int32_t dhI DHLOGE("Write stream data, speaker trans is null."); return ERR_DH_AUDIO_SA_SPEAKER_TRANS_NULL; } +#ifdef DUMP_DSPEAKERDEV_FILE if (DaudioHidumper::GetInstance().GetFlagStatus()) { if (!dumpFlag_) { AudioEvent event(NOTIFY_HDF_SPK_DUMP, ""); @@ -354,6 +356,7 @@ int32_t DSpeakerDev::WriteStreamData(const std::string &devId, const int32_t dhI } SaveFile(FILE_NAME, const_cast(data->Data()), data->Size()); } +#endif int32_t ret = speakerTrans_->FeedAudioData(data); if (ret != DH_SUCCESS) { DHLOGE("Write stream data failed, ret: %d.", ret); -- Gitee