From 8a881076c89ebdc6557a74e714cd8f04cccdaec1 Mon Sep 17 00:00:00 2001 From: Bobie Date: Fri, 12 Jul 2024 11:59:53 +0800 Subject: [PATCH] add sptr Signed-off-by: Bobie --- .../native_cpp/audio_sink/src/daudio_sink_handler.cpp | 4 ++-- .../native_cpp/audio_source/src/daudio_source_handler.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp b/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp index d03625ab..b02ea033 100644 --- a/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp +++ b/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp @@ -37,10 +37,10 @@ DAudioSinkHandler::DAudioSinkHandler() { DHLOGD("DAudio sink handler constructed."); if (!sinkSvrRecipient_) { - sinkSvrRecipient_ = new DAudioSinkSvrRecipient(); + sinkSvrRecipient_ = sptr(new DAudioSinkSvrRecipient()); } if (!dAudioSinkIpcCallback_) { - dAudioSinkIpcCallback_ = new DAudioSinkIpcCallback(); + dAudioSinkIpcCallback_ = sptr(new DAudioSinkIpcCallback()); } } diff --git a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp index d43861d1..933b4854 100644 --- a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp @@ -36,11 +36,11 @@ DAudioSourceHandler::DAudioSourceHandler() { DHLOGD("Audio source handler constructed."); if (!sourceSvrRecipient_) { - sourceSvrRecipient_ = new DAudioSourceSvrRecipient(); + sourceSvrRecipient_ = sptr(new DAudioSourceSvrRecipient()); } if (!dAudioIpcCallback_) { - dAudioIpcCallback_ = new DAudioIpcCallback(); + dAudioIpcCallback_ = sptr(new DAudioIpcCallback()); } } @@ -55,7 +55,8 @@ int32_t DAudioSourceHandler::InitSource(const std::string ¶ms) if (dAudioSourceProxy_ == nullptr) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); CHECK_NULL_RETURN(samgr, ERR_DH_AUDIO_NULLPTR); - sptr loadCallback = new DAudioSourceLoadCallback(params); + sptr loadCallback = sptr( + new DAudioSourceLoadCallback(params)); int32_t ret = samgr->LoadSystemAbility(DISTRIBUTED_HARDWARE_AUDIO_SOURCE_SA_ID, loadCallback); if (ret != ERR_OK) { DHLOGE("Failed to Load systemAbility, ret code: %{public}d", ret); -- Gitee