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 #ifndef SOUNDPOOL_MANAGER_H 16 #define SOUNDPOOL_MANAGER_H 17 18 #include <unistd.h> 19 #include <unordered_map> 20 #include "media_log.h" 21 #include "soundpool.h" 22 23 namespace OHOS { 24 namespace Media { 25 class SoundPool; 26 27 class SoundPoolManager { 28 public: 29 SoundPoolManager(const SoundPoolManager&) = delete; 30 SoundPoolManager& operator = (const SoundPoolManager&) = delete; 31 ~SoundPoolManager(); 32 33 int32_t GetSoundPool(const pid_t pid, std::shared_ptr<SoundPool>& soundPool); 34 int32_t Release(const pid_t pid); 35 GetInstance()36 static SoundPoolManager& GetInstance() 37 { 38 static SoundPoolManager instance; 39 return instance; 40 }; 41 42 private: SoundPoolManager()43 SoundPoolManager() {} 44 std::mutex mutex_; 45 std::unordered_map<pid_t, std::shared_ptr<SoundPool>> soundPools_; 46 }; 47 } // namespace Media 48 } // namespace OHOS 49 #endif // SOUNDPOOL_MANAGER_H 50