1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #ifndef LOG_TAG
16 #define LOG_TAG "OfflineAudioEffectManager"
17 #endif
18
19 #include "offline_audio_effect_manager.h"
20
21 #include <securec.h>
22
23 #include "audio_errors.h"
24 #include "audio_service_log.h"
25 #include "offline_audio_effect_chain_impl.h"
26
27 namespace OHOS {
28 namespace AudioStandard {
GetOfflineAudioEffectChains()29 std::vector<std::string> OfflineAudioEffectManager::GetOfflineAudioEffectChains()
30 {
31 std::vector<std::string> effectChains{};
32 int32_t ret = OfflineStreamInClient::GetOfflineAudioEffectChains(effectChains);
33 CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, effectChains, "Get chains failed, errcode is %{public}d", ret);
34 return effectChains;
35 }
36
CreateOfflineAudioEffectChain(const std::string & chainName)37 std::unique_ptr<OfflineAudioEffectChain> OfflineAudioEffectManager::CreateOfflineAudioEffectChain(
38 const std::string &chainName)
39 {
40 std::unique_ptr<OfflineAudioEffectChainImpl> chain = std::make_unique<OfflineAudioEffectChainImpl>(chainName);
41 int32_t ret = chain->CreateEffectChain();
42 CHECK_AND_RETURN_RET_LOG(ret == SUCCESS, nullptr, "create OfflineEffectChain failed, errcode is %{public}d", ret);
43 return chain;
44 }
45 } // namespace AudioStandard
46 } // namespace OHOS
47