From 85ccd60b4671eb95417bf61086be2210d23be3a1 Mon Sep 17 00:00:00 2001 From: hwwuhaobo Date: Mon, 24 Apr 2023 16:58:58 +0800 Subject: [PATCH 1/5] fix audio ext mmap mode Signed-off-by: hwwuhaobo --- .../include/audio_adapter_interface_impl.h | 8 ++++++ .../include/audio_capture_interface_impl.h | 2 ++ .../audio_capture_interface_impl_base.h | 2 ++ .../include/audio_render_interface_impl.h | 2 ++ .../audio_render_interface_impl_base.h | 2 ++ .../v1_0/src/audio_adapter_interface_impl.cpp | 25 +++++++++++++++++++ .../v1_0/src/audio_capture_interface_impl.cpp | 6 +++++ .../v1_0/src/audio_render_interface_impl.cpp | 6 +++++ 8 files changed, 53 insertions(+) diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h index 569bbbf5..6dbe7d5c 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h @@ -155,6 +155,14 @@ private: const std::string NOT_MUTE_STATUS = "0"; const std::string IS_MUTE_STATUS = "1"; + + AudioCaptureInterfaceImplBase *(*GetLowlatencyCaptureImpl_)() = nullptr; + AudioRenderInterfaceImplBase *(*GetLowlatencyRenderImpl_)() = nullptr; +#ifdef __aarch64__ + char resolvedPath_[100] = "/system/lib64/libdaudio_lowlatency_hdf_service.z.so"; +#else + char resolvedPath_[100] = "/system/lib/libdaudio_lowlatency_hdf_service.z.so"; +#endif }; } // V1_0 } // Audio diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h index 12df1f62..e11c2a8a 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h @@ -73,6 +73,8 @@ public: int32_t AudioDevDump(int32_t range, int32_t fd) override; int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override; const AudioDeviceDescriptor &GetCaptureDesc() override; + void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, + const AudioSampleAttributes &attrs, const sptr &callback) override; private: static constexpr int64_t AUDIO_OFFSET_FRAME_NUM = 10; diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h index d705eae3..4e3c4912 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h @@ -43,6 +43,8 @@ public: virtual ~AudioCaptureInterfaceImplBase() = default; virtual const AudioDeviceDescriptor &GetCaptureDesc() = 0; + virtual void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, + const AudioSampleAttributes &attrs, const sptr &callback) = 0; }; } // V1_0 } // Audio diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h index c1536720..8b92112f 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h @@ -91,6 +91,8 @@ public: uint32_t GetVolumeInner() override; uint32_t GetMaxVolumeInner() override; uint32_t GetMinVolumeInner() override; + void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, + const AudioSampleAttributes &attrs, const sptr &callback) override; private: float GetFadeRate(uint32_t currentIndex, const uint32_t durationIndex); diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h index dea8aa2b..7618f9fa 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h @@ -48,6 +48,8 @@ public: virtual uint32_t GetVolumeInner() = 0; virtual uint32_t GetMaxVolumeInner() = 0; virtual uint32_t GetMinVolumeInner() = 0; + virtual void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, + const AudioSampleAttributes &attrs, const sptr &callback) = 0; }; } // V1_0 } // Audio diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp index b993d2f8..56e902f7 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp @@ -15,6 +15,7 @@ #include "audio_adapter_interface_impl.h" +#include #include #include @@ -86,6 +87,18 @@ int32_t AudioAdapterInterfaceImpl::CreateRender(const AudioDeviceDescriptor &des } renderFlags_ = Audioext::V1_0::NORMAL_MODE; audioRender_ = new AudioRenderInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extSpkCallback_); + void *handle = dlopen(resolvedPath_, RTLD_LAZY); + if (attrs.type == AUDIO_MMAP_NOIRQ && handle != nullptr) { + DHLOGI("Try to mmap mode."); + GetLowlatencyRenderImpl_ = (AudioRenderInterfaceImplBase *(*)())(dlsym(handle, "GetLowlatencyRenderImpl")); + if (GetLowlatencyRenderImpl_ == nullptr) { + DHLOGE("Dlsym GetLowlatencyRenderImpl error."); + return HDF_FAILURE; + } + audioRender_ = GetLowlatencyRenderImpl_(); + audioRender_->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extSpkCallback_); + renderFlags_ = Audioext::V1_0::MMAP_MODE; + } if (audioRender_ == nullptr) { DHLOGE("Create render failed."); return HDF_FAILURE; @@ -138,6 +151,18 @@ int32_t AudioAdapterInterfaceImpl::CreateCapture(const AudioDeviceDescriptor &de } capturerFlags_ = Audioext::V1_0::NORMAL_MODE; audioCapture_ = new AudioCaptureInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extMicCallback_); + void *handle = dlopen(resolvedPath_, RTLD_LAZY); + if (attrs.type == AUDIO_MMAP_NOIRQ && handle != nullptr) { + DHLOGI("Try to mmap mode."); + GetLowlatencyCaptureImpl_ = (AudioCaptureInterfaceImplBase *(*)())(dlsym(handle, "GetLowlatencyCaptureImpl")); + if (GetLowlatencyCaptureImpl_ == nullptr) { + DHLOGE("Dlsym GetLowlatencyCaptureImpl error."); + return HDF_FAILURE; + } + audioCapture_ = GetLowlatencyCaptureImpl_(); + audioCapture_->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extMicCallback_); + capturerFlags_ = Audioext::V1_0::MMAP_MODE; + } if (audioCapture_ == nullptr) { DHLOGE("Create capture failed."); return HDF_FAILURE; 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 bbfcabba..5419c8ee 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 @@ -321,6 +321,12 @@ int32_t AudioCaptureInterfaceImpl::GetFrameBufferSize(uint64_t &bufferSize) return HDF_SUCCESS; } +void AudioCaptureInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, + const AudioSampleAttributes &attrs, const sptr &callback) +{ + DHLOGI("Set attrs, not support yet."); +} + const AudioDeviceDescriptor &AudioCaptureInterfaceImpl::GetCaptureDesc() { return devDesc_; 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 f8478f10..1f4d0178 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 @@ -435,6 +435,12 @@ uint32_t AudioRenderInterfaceImpl::GetMinVolumeInner() std::lock_guard volLck(volMtx_); return volMin_; } + +void AudioRenderInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, + const AudioSampleAttributes &attrs, const sptr &callback) +{ + DHLOGI("Set attrs, not support yet."); +} } // V1_0 } // Audio } // Distributedaudio -- Gitee From 7d6b555926323139a0fee67a67b5618298fc64a9 Mon Sep 17 00:00:00 2001 From: hwwuhaobo Date: Mon, 24 Apr 2023 17:38:58 +0800 Subject: [PATCH 2/5] fix audio ext mmap mode Signed-off-by: hwwuhaobo --- services/audioclient/interface/imic_client.h | 1 + services/audioclient/interface/ispk_client.h | 1 + .../micclient/include/dmic_client.h | 1 + .../audioclient/micclient/src/dmic_client.cpp | 5 ++++ .../spkclient/include/dspeaker_client.h | 1 + .../spkclient/src/dspeaker_client.cpp | 5 ++++ .../managersink/include/daudio_sink_dev.h | 8 +++++ .../managersink/src/daudio_sink_dev.cpp | 30 ++++++++++++++----- 8 files changed, 44 insertions(+), 8 deletions(-) diff --git a/services/audioclient/interface/imic_client.h b/services/audioclient/interface/imic_client.h index 91feb930..7546355e 100644 --- a/services/audioclient/interface/imic_client.h +++ b/services/audioclient/interface/imic_client.h @@ -31,6 +31,7 @@ public: virtual int32_t Release() = 0; virtual int32_t StartCapture() = 0; virtual int32_t StopCapture() = 0; + virtual void SetAttrs(const std::string &devId, const std::shared_ptr &callback) = 0; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/audioclient/interface/ispk_client.h b/services/audioclient/interface/ispk_client.h index a6c03854..f28c313e 100644 --- a/services/audioclient/interface/ispk_client.h +++ b/services/audioclient/interface/ispk_client.h @@ -34,6 +34,7 @@ public: virtual int32_t SetMute(const AudioEvent &event) = 0; virtual int32_t SetAudioParameters(const AudioEvent &event) = 0; virtual void PlayStatusChange(const std::string &args) = 0; + virtual void SetAttrs(const std::string &devId, const std::shared_ptr &callback) = 0; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/audioclient/micclient/include/dmic_client.h b/services/audioclient/micclient/include/dmic_client.h index 0e131309..b9f68de4 100644 --- a/services/audioclient/micclient/include/dmic_client.h +++ b/services/audioclient/micclient/include/dmic_client.h @@ -54,6 +54,7 @@ public: int32_t Release() override; int32_t StartCapture() override; int32_t StopCapture() override; + void SetAttrs(const std::string &devId, const std::shared_ptr &callback) override; private: void CaptureThreadRunning(); diff --git a/services/audioclient/micclient/src/dmic_client.cpp b/services/audioclient/micclient/src/dmic_client.cpp index a854c35e..107530e2 100644 --- a/services/audioclient/micclient/src/dmic_client.cpp +++ b/services/audioclient/micclient/src/dmic_client.cpp @@ -234,5 +234,10 @@ int32_t DMicClient::StopCapture() } return DH_SUCCESS; } + +void DMicClient::SetAttrs(const std::string &devId, const std::shared_ptr &callback) +{ + DHLOGE("Set attrs, not support yet."); +} } // DistributedHardware } // OHOS diff --git a/services/audioclient/spkclient/include/dspeaker_client.h b/services/audioclient/spkclient/include/dspeaker_client.h index bce42c94..5738f18e 100644 --- a/services/audioclient/spkclient/include/dspeaker_client.h +++ b/services/audioclient/spkclient/include/dspeaker_client.h @@ -66,6 +66,7 @@ public: int32_t SetMute(const AudioEvent &event) override; int32_t SetAudioParameters(const AudioEvent &event) override; void PlayStatusChange(const std::string &args) override; + void SetAttrs(const std::string &devId, const std::shared_ptr &callback) override; private: std::string GetVolumeLevel(); diff --git a/services/audioclient/spkclient/src/dspeaker_client.cpp b/services/audioclient/spkclient/src/dspeaker_client.cpp index b9e5315e..c0685be1 100644 --- a/services/audioclient/spkclient/src/dspeaker_client.cpp +++ b/services/audioclient/spkclient/src/dspeaker_client.cpp @@ -462,5 +462,10 @@ void DSpeakerClient::PlayStatusChange(const std::string &args) DHLOGE("Play status error."); } } + +void DSpeakerClient::SetAttrs(const std::string &devId, const std::shared_ptr &callback) +{ + DHLOGE("Set attrs, not support yet."); +} } // DistributedHardware } // OHOS diff --git a/services/audiomanager/managersink/include/daudio_sink_dev.h b/services/audiomanager/managersink/include/daudio_sink_dev.h index 282f2b37..10ad859c 100644 --- a/services/audiomanager/managersink/include/daudio_sink_dev.h +++ b/services/audiomanager/managersink/include/daudio_sink_dev.h @@ -96,6 +96,14 @@ private: using DAudioSinkDevFunc = int32_t (DAudioSinkDev::*)(const AudioEvent &audioEvent); std::map memberFuncMap_; + + ISpkClient *(*GetDirectSpkClient_)() = nullptr; + IMicClient *(*GetDirectMicClient_)() = nullptr; +#ifdef __aarch64__ + char resolvedPath_[100] = "/system/lib64/libdistributed_direct_client.z.so"; +#else + char resolvedPath_[100] = "/system/lib/libdistributed_direct_client.z.so"; +#endif }; } // DistributedHardware } // OHOS diff --git a/services/audiomanager/managersink/src/daudio_sink_dev.cpp b/services/audiomanager/managersink/src/daudio_sink_dev.cpp index e2787d2b..c93f5e2e 100644 --- a/services/audiomanager/managersink/src/daudio_sink_dev.cpp +++ b/services/audiomanager/managersink/src/daudio_sink_dev.cpp @@ -390,15 +390,20 @@ int32_t DAudioSinkDev::TaskOpenDSpeaker(const std::string &args) return ret; } - if (speakerClient_ == nullptr) { - if (audioParam.renderOpts.renderFlags == NORMAL_MODE) { - speakerClient_ = std::make_shared(devId_, shared_from_this()); - } - } - if (speakerClient_ == nullptr) { speakerClient_ = std::make_shared(devId_, shared_from_this()); } + void *handle = dlopen(resolvedPath_, RTLD_LAZY); + if (audioParam.renderOpts.renderFlags == MMAP_MODE && handle != nullptr) { + DHLOGI("Try to mmap mode."); + GetDirectSpkClient_ = (ISpkClient *(*)())(dlsym(handle, "GetDirectSpkClient")); + if (GetDirectSpkClient_ == nullptr) { + DHLOGE("Dlsym GetDirectSpkClient error."); + return HDF_FAILURE; + } + speakerClient_ = GetDirectSpkClient_(); + speakerClient_->SetAttrs(devId_, shared_from_this()); + } ret = speakerClient_->SetUp(audioParam); if (ret != DH_SUCCESS) { DHLOGE("Setup speaker failed, ret: %d.", ret); @@ -460,9 +465,18 @@ int32_t DAudioSinkDev::TaskOpenDMic(const std::string &args) do { if (micClient_ == nullptr) { - if (audioParam.captureOpts.capturerFlags == NORMAL_MODE) { - micClient_ = std::make_shared(devId_, shared_from_this()); + micClient_ = std::make_shared(devId_, shared_from_this()); + } + void *handle = dlopen(resolvedPath_, RTLD_LAZY); + if (audioParam.captureOpts.capturerFlags == MMAP_MODE && handle != nullptr) { + DHLOGI("Try to mmap mode."); + GetDirectMicClient_ = (IMicClient *(*)())(dlsym(handle, "GetDirectMicClient")); + if (GetDirectMicClient_ == nullptr) { + DHLOGE("Dlsym GetDirectMicClient error."); + return HDF_FAILURE; } + micClient_ = GetDirectMicClient_(); + micClient_->SetAttrs(devId_, shared_from_this()); } ret = micClient_->SetUp(audioParam); if (ret != DH_SUCCESS) { -- Gitee From 365f517cdc8f965d8e1fa40ea3356eb1ee7800d3 Mon Sep 17 00:00:00 2001 From: hwwuhaobo Date: Mon, 24 Apr 2023 18:12:25 +0800 Subject: [PATCH 3/5] fix audio ext mmap mode Signed-off-by: hwwuhaobo --- .../audio/v1_0/include/audio_render_interface_impl_base.h | 3 +++ .../audio/v1_0/src/audio_capture_interface_impl.cpp | 2 +- .../audio/v1_0/src/audio_render_interface_impl.cpp | 2 +- services/audiomanager/managersink/src/daudio_sink_dev.cpp | 5 +++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h index 7618f9fa..5929d137 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h @@ -29,6 +29,9 @@ namespace HDI { namespace DistributedAudio { namespace Audio { namespace V1_0 { +using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; +using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; +using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; typedef enum { RENDER_STATUS_OPEN = 0, RENDER_STATUS_CLOSE, 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 5419c8ee..39b830a3 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 @@ -322,7 +322,7 @@ int32_t AudioCaptureInterfaceImpl::GetFrameBufferSize(uint64_t &bufferSize) } void AudioCaptureInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) + const AudioSampleAttributes &attrs, const sptr &callback) { DHLOGI("Set attrs, not support yet."); } 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 1f4d0178..0c40c099 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 @@ -437,7 +437,7 @@ uint32_t AudioRenderInterfaceImpl::GetMinVolumeInner() } void AudioRenderInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) + const AudioSampleAttributes &attrs, const sptr &callback) { DHLOGI("Set attrs, not support yet."); } diff --git a/services/audiomanager/managersink/src/daudio_sink_dev.cpp b/services/audiomanager/managersink/src/daudio_sink_dev.cpp index c93f5e2e..f17a49de 100644 --- a/services/audiomanager/managersink/src/daudio_sink_dev.cpp +++ b/services/audiomanager/managersink/src/daudio_sink_dev.cpp @@ -15,6 +15,7 @@ #include "daudio_sink_dev.h" +#include #include #include "daudio_constants.h" @@ -399,7 +400,7 @@ int32_t DAudioSinkDev::TaskOpenDSpeaker(const std::string &args) GetDirectSpkClient_ = (ISpkClient *(*)())(dlsym(handle, "GetDirectSpkClient")); if (GetDirectSpkClient_ == nullptr) { DHLOGE("Dlsym GetDirectSpkClient error."); - return HDF_FAILURE; + return ERR_DH_AUDIO_FAILED; } speakerClient_ = GetDirectSpkClient_(); speakerClient_->SetAttrs(devId_, shared_from_this()); @@ -473,7 +474,7 @@ int32_t DAudioSinkDev::TaskOpenDMic(const std::string &args) GetDirectMicClient_ = (IMicClient *(*)())(dlsym(handle, "GetDirectMicClient")); if (GetDirectMicClient_ == nullptr) { DHLOGE("Dlsym GetDirectMicClient error."); - return HDF_FAILURE; + return ERR_DH_AUDIO_FAILED; } micClient_ = GetDirectMicClient_(); micClient_->SetAttrs(devId_, shared_from_this()); -- Gitee From 901a2217f8a219614fc1fc61bc8598386dc04342 Mon Sep 17 00:00:00 2001 From: hwwuhaobo Date: Mon, 24 Apr 2023 19:31:15 +0800 Subject: [PATCH 4/5] fix audio ext mmap mode Signed-off-by: hwwuhaobo --- services/audiomanager/managersink/src/daudio_sink_dev.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/audiomanager/managersink/src/daudio_sink_dev.cpp b/services/audiomanager/managersink/src/daudio_sink_dev.cpp index f17a49de..14aefed6 100644 --- a/services/audiomanager/managersink/src/daudio_sink_dev.cpp +++ b/services/audiomanager/managersink/src/daudio_sink_dev.cpp @@ -402,7 +402,7 @@ int32_t DAudioSinkDev::TaskOpenDSpeaker(const std::string &args) DHLOGE("Dlsym GetDirectSpkClient error."); return ERR_DH_AUDIO_FAILED; } - speakerClient_ = GetDirectSpkClient_(); + speakerClient_ = std::shared_ptr(GetDirectSpkClient_()); speakerClient_->SetAttrs(devId_, shared_from_this()); } ret = speakerClient_->SetUp(audioParam); @@ -476,7 +476,7 @@ int32_t DAudioSinkDev::TaskOpenDMic(const std::string &args) DHLOGE("Dlsym GetDirectMicClient error."); return ERR_DH_AUDIO_FAILED; } - micClient_ = GetDirectMicClient_(); + micClient_ = std::shared_ptr(GetDirectMicClient_()); micClient_->SetAttrs(devId_, shared_from_this()); } ret = micClient_->SetUp(audioParam); -- Gitee From 36e39ef47d9956352b422bbbb3e74510f1be4ce4 Mon Sep 17 00:00:00 2001 From: hwwuhaobo Date: Mon, 24 Apr 2023 21:28:42 +0800 Subject: [PATCH 5/5] fix audio ext mmap mode Signed-off-by: hwwuhaobo --- .../v1_0/include/audio_adapter_interface_impl.h | 8 ++++---- .../v1_0/src/audio_adapter_interface_impl.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h index 6dbe7d5c..43948eb4 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h @@ -156,12 +156,12 @@ private: const std::string NOT_MUTE_STATUS = "0"; const std::string IS_MUTE_STATUS = "1"; - AudioCaptureInterfaceImplBase *(*GetLowlatencyCaptureImpl_)() = nullptr; - AudioRenderInterfaceImplBase *(*GetLowlatencyRenderImpl_)() = nullptr; + AudioCaptureInterfaceImplBase *(*GetExternCaptureImpl_)() = nullptr; + AudioRenderInterfaceImplBase *(*GetExternRenderImpl_)() = nullptr; #ifdef __aarch64__ - char resolvedPath_[100] = "/system/lib64/libdaudio_lowlatency_hdf_service.z.so"; + char resolvedPath_[100] = "/system/lib64/libdaudio_extern_hdf_service.z.so"; #else - char resolvedPath_[100] = "/system/lib/libdaudio_lowlatency_hdf_service.z.so"; + char resolvedPath_[100] = "/system/lib/libdaudio_extern_hdf_service.z.so"; #endif }; } // V1_0 diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp index 56e902f7..3bac9205 100644 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp +++ b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp @@ -90,12 +90,12 @@ int32_t AudioAdapterInterfaceImpl::CreateRender(const AudioDeviceDescriptor &des void *handle = dlopen(resolvedPath_, RTLD_LAZY); if (attrs.type == AUDIO_MMAP_NOIRQ && handle != nullptr) { DHLOGI("Try to mmap mode."); - GetLowlatencyRenderImpl_ = (AudioRenderInterfaceImplBase *(*)())(dlsym(handle, "GetLowlatencyRenderImpl")); - if (GetLowlatencyRenderImpl_ == nullptr) { - DHLOGE("Dlsym GetLowlatencyRenderImpl error."); + GetExternRenderImpl_ = (AudioRenderInterfaceImplBase *(*)())(dlsym(handle, "GetExternRenderImpl")); + if (GetExternRenderImpl_ == nullptr) { + DHLOGE("Dlsym GetExternRenderImpl error."); return HDF_FAILURE; } - audioRender_ = GetLowlatencyRenderImpl_(); + audioRender_ = GetExternRenderImpl_(); audioRender_->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extSpkCallback_); renderFlags_ = Audioext::V1_0::MMAP_MODE; } @@ -154,12 +154,12 @@ int32_t AudioAdapterInterfaceImpl::CreateCapture(const AudioDeviceDescriptor &de void *handle = dlopen(resolvedPath_, RTLD_LAZY); if (attrs.type == AUDIO_MMAP_NOIRQ && handle != nullptr) { DHLOGI("Try to mmap mode."); - GetLowlatencyCaptureImpl_ = (AudioCaptureInterfaceImplBase *(*)())(dlsym(handle, "GetLowlatencyCaptureImpl")); - if (GetLowlatencyCaptureImpl_ == nullptr) { - DHLOGE("Dlsym GetLowlatencyCaptureImpl error."); + GetExternCaptureImpl_ = (AudioCaptureInterfaceImplBase *(*)())(dlsym(handle, "GetExternCaptureImpl")); + if (GetExternCaptureImpl_ == nullptr) { + DHLOGE("Dlsym GetExternCaptureImpl error."); return HDF_FAILURE; } - audioCapture_ = GetLowlatencyCaptureImpl_(); + audioCapture_ = GetExternCaptureImpl_(); audioCapture_->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extMicCallback_); capturerFlags_ = Audioext::V1_0::MMAP_MODE; } -- Gitee