From f622c1c66fbf1c66b4be7557b7c839594aef62e1 Mon Sep 17 00:00:00 2001 From: liyuhang Date: Sat, 18 Nov 2023 16:11:25 +0800 Subject: [PATCH] Add sasdk without delete old sasdk Signed-off-by: liyuhang Change-Id: I5720c762804c0d97e8af9978ad3fc47ad7b07b99 --- bundle.json | 12 +++- .../native/audiosasdk/include/audio_sasdk.h | 55 +++++++++++++++++++ services/audio_service/BUILD.gn | 36 ++++++++++++ .../audio_service/client/src/audio_sasdk.cpp | 45 +++++++++++++++ 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 interfaces/inner_api/native/audiosasdk/include/audio_sasdk.h create mode 100644 services/audio_service/client/src/audio_sasdk.cpp diff --git a/bundle.json b/bundle.json index 8c8d3a8b0e..583a43d2a7 100644 --- a/bundle.json +++ b/bundle.json @@ -81,7 +81,8 @@ "//foundation/multimedia/audio_framework/frameworks/native/ohaudio:ohaudio", "//foundation/multimedia/audio_framework/frameworks/native/opensles:opensles", "//foundation/multimedia/audio_framework/frameworks/native/audiocompatibility:audio_renderer_gateway", - "//foundation/multimedia/audio_framework/frameworks/native/audiocompatibility:audio_capturer_gateway" + "//foundation/multimedia/audio_framework/frameworks/native/audiocompatibility:audio_capturer_gateway", + "//foundation/multimedia/audio_framework/services/audio_service:audio_sasdk" ], "service_group": [ "//foundation/multimedia/audio_framework/sa_profile:audio_service_sa_profile", @@ -93,6 +94,15 @@ ] }, "inner_kits": [ + { + "header": { + "header_base": "//foundation/multimedia/audio_framework/interfaces/inner_api/native/audiosasdk/include", + "header_files": [ + "audio_sasdk.h" + ] + }, + "name": "//foundation/multimedia/audio_framework/services/audio_service:audio_sasdk" + }, { "type": "none", "name": "//foundation/multimedia/audio_framework/services/audio_service:audio_client", diff --git a/interfaces/inner_api/native/audiosasdk/include/audio_sasdk.h b/interfaces/inner_api/native/audiosasdk/include/audio_sasdk.h new file mode 100644 index 0000000000..a5267a8a09 --- /dev/null +++ b/interfaces/inner_api/native/audiosasdk/include/audio_sasdk.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef AUDIO_SASDK_H +#define AUDIO_SASDK_H + +namespace OHOS { +namespace AudioStandard { + +enum SaSdkAudioVolumeType { + /** + * Indicates audio streams of voices in calls. + */ + SASDK_STREAM_VOICE_CALL = 0, + /** + * Indicates audio streams for music. + */ + SASDK_STREAM_MUSIC = 1, +}; + +/** + * @brief The AudioSaSdk class is an abstract definition of audio sasdk abilities. + */ +class AudioSaSdk { +public: + static AudioSaSdk *GetInstance(); + + AudioSaSdk(); + + ~AudioSaSdk(); + + /** + * @brief Is stream active. + * + * @param volumeType audio volume type. + * @return Returns true if the rendering is successfully started; returns false otherwise. + * @since 11 + */ + bool IsStreamActive(SaSdkAudioVolumeType volumeType); +}; +} // namespace AudioStandard +} // namespace OHOS +#endif // AUDIO_SASDK_H diff --git a/services/audio_service/BUILD.gn b/services/audio_service/BUILD.gn index 31ba9cdb51..e2acec310f 100644 --- a/services/audio_service/BUILD.gn +++ b/services/audio_service/BUILD.gn @@ -312,6 +312,42 @@ ohos_shared_library("audio_service") { part_name = "audio_framework" } +ohos_shared_library("audio_sasdk") { + stack_protector_ret = true + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + install_enable = true + sources = [ "client/src/audio_sasdk.cpp" ] + + include_dirs = [ + "../../interfaces/inner_api/native/audiocommon/include", + "../../interfaces/inner_api/native/audiosasdk/include", + ] + + deps = [ + ":audio_common", + "../audio_policy:audio_policy_client", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] + + version_script = "../../audio_framework.versionscript" + innerapi_tags = [ + "platformsdk", + "sasdk", + ] + + subsystem_name = "multimedia" + part_name = "audio_framework" +} + group("audio_service_test_packages") { deps = [ ":audio_hdi_device_test", diff --git a/services/audio_service/client/src/audio_sasdk.cpp b/services/audio_service/client/src/audio_sasdk.cpp new file mode 100644 index 0000000000..c25a7cc267 --- /dev/null +++ b/services/audio_service/client/src/audio_sasdk.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023 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 "audio_sasdk.h" +#include "audio_policy_manager.h" +#include "audio_log.h" + +namespace OHOS { +namespace AudioStandard { +using namespace std; + +AudioSaSdk::AudioSaSdk() +{ + AUDIO_DEBUG_LOG("Construct AudioSaSdk"); +} + +AudioSaSdk::~AudioSaSdk() +{ + AUDIO_DEBUG_LOG("Destruct AudioSaSdk"); +} + +AudioSaSdk *AudioSaSdk::GetInstance() +{ + static AudioSaSdk audioSaSdk; + return &audioSaSdk; +} + +bool AudioSaSdk::IsStreamActive(SaSdkAudioVolumeType streamType) +{ + return AudioPolicyManager::GetInstance().IsStreamActive(static_cast(streamType)); +} +} // namespace AudioStandard +} // namespace OHOS -- Gitee