From 98caf7a728382a310797dc6bdb46e37ff070eba8 Mon Sep 17 00:00:00 2001 From: Bobie Date: Sat, 1 Jun 2024 10:50:50 +0800 Subject: [PATCH] fix the stream id issue in notification. Signed-off-by: Bobie --- services/audiomanager/managersource/include/dmic_dev.h | 1 + services/audiomanager/managersource/include/dspeaker_dev.h | 1 + services/audiomanager/managersource/src/dmic_dev.cpp | 6 ++++-- services/audiomanager/managersource/src/dspeaker_dev.cpp | 6 ++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/services/audiomanager/managersource/include/dmic_dev.h b/services/audiomanager/managersource/include/dmic_dev.h index cfb8a76d..d2278ed1 100644 --- a/services/audiomanager/managersource/include/dmic_dev.h +++ b/services/audiomanager/managersource/include/dmic_dev.h @@ -105,6 +105,7 @@ private: std::mutex channelWaitMutex_; std::condition_variable channelWaitCond_; int32_t curPort_ = 0; + int32_t streamId_ = 100; std::atomic isTransReady_ = false; std::atomic isOpened_ = false; std::shared_ptr micTrans_ = nullptr; diff --git a/services/audiomanager/managersource/include/dspeaker_dev.h b/services/audiomanager/managersource/include/dspeaker_dev.h index 057c095a..f812a0c3 100644 --- a/services/audiomanager/managersource/include/dspeaker_dev.h +++ b/services/audiomanager/managersource/include/dspeaker_dev.h @@ -93,6 +93,7 @@ private: std::atomic isTransReady_ = false; std::atomic isOpened_ = false; int32_t curPort_ = 0; + int32_t streamId_ = 0; std::shared_ptr speakerTrans_ = nullptr; // Speaker render parameters diff --git a/services/audiomanager/managersource/src/dmic_dev.cpp b/services/audiomanager/managersource/src/dmic_dev.cpp index d18d84fd..236c8443 100644 --- a/services/audiomanager/managersource/src/dmic_dev.cpp +++ b/services/audiomanager/managersource/src/dmic_dev.cpp @@ -142,6 +142,7 @@ int32_t DMicDev::CreateStream(const int32_t streamId) cbObj->NotifyEvent(event); DAudioHisysevent::GetInstance().SysEventWriteBehavior(DAUDIO_OPEN, devId_, std::to_string(dhId_), "daudio mic device open success."); + streamId_ = streamId; cJSON_Delete(jParam); cJSON_free(jsonData); return DH_SUCCESS; @@ -500,9 +501,10 @@ AudioParam DMicDev::GetAudioParam() const int32_t DMicDev::NotifyHdfAudioEvent(const AudioEvent &event, const int32_t portId) { - int32_t ret = DAudioHdiHandler::GetInstance().NotifyEvent(devId_, portId, 0, event); + int32_t ret = DAudioHdiHandler::GetInstance().NotifyEvent(devId_, portId, streamId_, event); if (ret != DH_SUCCESS) { - DHLOGE("Notify event: %{public}d, result: %{public}s.", event.type, event.content.c_str()); + DHLOGE("Notify event: %{public}d, result: %{public}s, streamId: %{public}d.", + event.type, event.content.c_str(), streamId_); } return DH_SUCCESS; } diff --git a/services/audiomanager/managersource/src/dspeaker_dev.cpp b/services/audiomanager/managersource/src/dspeaker_dev.cpp index a37c9df4..3f67c41f 100644 --- a/services/audiomanager/managersource/src/dspeaker_dev.cpp +++ b/services/audiomanager/managersource/src/dspeaker_dev.cpp @@ -126,6 +126,7 @@ int32_t DSpeakerDev::CreateStream(const int32_t streamId) cbObj->NotifyEvent(event); DAudioHisysevent::GetInstance().SysEventWriteBehavior(DAUDIO_OPEN, devId_, std::to_string(dhId_), "daudio spk device open success."); + streamId_ = streamId; cJSON_Delete(jParam); cJSON_free(jsonData); return DH_SUCCESS; @@ -429,9 +430,10 @@ int32_t DSpeakerDev::SendMessage(uint32_t type, std::string content, std::string int32_t DSpeakerDev::NotifyHdfAudioEvent(const AudioEvent &event, const int32_t portId) { - int32_t ret = DAudioHdiHandler::GetInstance().NotifyEvent(devId_, portId, 0, event); + int32_t ret = DAudioHdiHandler::GetInstance().NotifyEvent(devId_, portId, streamId_, event); if (ret != DH_SUCCESS) { - DHLOGE("Notify event: %{public}d, result: %{public}s.", event.type, event.content.c_str()); + DHLOGE("Notify event: %{public}d, result: %{public}s, streamId: %{public}d.", + event.type, event.content.c_str(), streamId_); } return DH_SUCCESS; } -- Gitee