• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef IM_EXTERN_LOADER_H
17 #define IM_EXTERN_LOADER_H
18 
19 #include <string>
20 #include <atomic>
21 #include <mutex>
22 
23 #include "image_effect_marco_define.h"
24 #include "effect_log.h"
25 
26 namespace OHOS {
27 namespace Media {
28 namespace Effect {
29 using InitFunc = void (*)();
30 using DeinitFunc = void (*)();
31 using InitModuleFunc = void (*)();
32 using DeinitModuleFunc = void (*)();
33 class ExternLoader {
34 public:
35     ~ExternLoader() = default;
36 
37     IMAGE_EFFECT_EXPORT static ExternLoader *Instance();
38 
39     IMAGE_EFFECT_EXPORT bool IsExtLoad() const;
40 
41     IMAGE_EFFECT_EXPORT void LoadExtSo();
42 
43     InitFunc GetInitFunc() const;
44     DeinitFunc GetDeinitFunc() const;
45     InitModuleFunc GetInitModuleFunc() const;
46     DeinitModuleFunc GetDeinitModuleFunc() const;
47 
48     void InitExt();
49 private:
50     ExternLoader() = default;
51 
52     InitFunc initFunc_ = nullptr;
53     DeinitFunc deinitFunc_ = nullptr;
54     InitModuleFunc initModuleFunc_ = nullptr;
55     DeinitModuleFunc deinitModuleFunc_ = nullptr;
56 
57     std::atomic<bool> isExtLoad_ = false;
58     std::atomic<bool> hasInitExt_ = false;
59 
60     std::mutex loadExtSo_;
61     std::mutex initExtSo_;
62 };
63 } // namespace Effect
64 } // namespace Media
65 } // namespace OHOS
66 
67 #endif // IM_EXTERN_LOADER_H