• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include <cerrno>
16 #include "hdf_base.h"
17 #include "intell_voice_log.h"
18 #include "engine_factory.h"
19 
20 #undef HDF_LOG_TAG
21 #define HDF_LOG_TAG "IntellVoiceEngineMgr"
22 
23 using namespace OHOS::HDI::IntelligentVoice::Engine::V1_0;
24 
25 namespace OHOS {
26 namespace IntelligentVoice {
27 namespace Engine {
28 class IntellVoiceEngineManager final : public IEngineManager {
29 public:
CreateAdapter(const IntellVoiceEngineAdapterDescriptor & descriptor,std::unique_ptr<IEngine> & engine)30     int32_t CreateAdapter(const IntellVoiceEngineAdapterDescriptor &descriptor, std::unique_ptr<IEngine> &engine)
31     {
32         INTELLIGENT_VOICE_LOGD("create adapter");
33         engine = EngineFactory::CreateEngine(descriptor.adapterType);
34         if (engine == nullptr) {
35             INTELLIGENT_VOICE_LOGE("failed to create engine");
36         }
37         return HDF_SUCCESS;
38     }
39 
ReleaseAdapter(const IntellVoiceEngineAdapterDescriptor & descriptor)40     int32_t ReleaseAdapter(const IntellVoiceEngineAdapterDescriptor &descriptor)
41     {
42         INTELLIGENT_VOICE_LOGD("release adapter");
43         return HDF_SUCCESS;
44     }
45 
GetInstance()46     static IntellVoiceEngineManager *GetInstance()
47     {
48         static IntellVoiceEngineManager manager;
49         return &manager;
50     }
51 
52 private:
IntellVoiceEngineManager()53     IntellVoiceEngineManager(){};
~IntellVoiceEngineManager()54     ~IntellVoiceEngineManager(){};
55 };
56 }
57 }
58 }
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
GetIntellVoiceEngineManagerHalInst(void)64 __attribute__((visibility("default"))) OHOS::IntelligentVoice::Engine::IEngineManager *GetIntellVoiceEngineManagerHalInst(void)
65 {
66     INTELLIGENT_VOICE_LOGD("enter to engine manager stub");
67     return OHOS::IntelligentVoice::Engine::IntellVoiceEngineManager::GetInstance();
68 }
69 
70 #ifdef __cplusplus
71 }
72 #endif
73