• 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 RESOURCE_MANAGER_ADAPTER_H
17 #define RESOURCE_MANAGER_ADAPTER_H
18 
19 #include <mutex>
20 #include "resource_manager.h"
21 
22 namespace OHOS {
23 namespace AudioStandard {
24 
25 class ResourceManagerAdapter {
26 public:
27     static ResourceManagerAdapter *GetInstance();
28 
29     ResourceManagerAdapter();
30     ~ResourceManagerAdapter();
31 
32     void ReleaseSystemResourceManager();
33     std::string GetSystemStringByName(std::string name);
34     Global::Resource::RState GetMediaDataByName(std::string name, size_t &len, std::unique_ptr<uint8_t[]> &outValue,
35         uint32_t density = 0);
36 private:
37     void InitResourceManager();
38     void RefreshResConfig();
39     /**
40      * Ensure that operations on resourceManager_ are not executed concurrently
41      */
42     std::mutex resourceManagerMutex_;
43     Global::Resource::ResourceManager *resourceManager_ = nullptr;
44     Global::Resource::ResConfig *resConfig_ = nullptr;
45 };
46 } // namespace AudioStandard
47 } // namespace OHOS
48 #endif // RESOURCE_MANAGER_ADAPTER_H
49