Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef android_hardware_audio_V2_0_EffectMap_H_ |
| 18 | #define android_hardware_audio_V2_0_EffectMap_H_ |
| 19 | |
| 20 | #include <mutex> |
| 21 | |
| 22 | #include <hardware/audio_effect.h> |
| 23 | #include <utils/KeyedVector.h> |
| 24 | #include <utils/Singleton.h> |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | // This class needs to be in 'android' ns because Singleton macros require that. |
| 29 | class EffectMap : public Singleton<EffectMap> { |
| 30 | public: |
| 31 | static const uint64_t INVALID_ID; |
| 32 | |
| 33 | uint64_t add(effect_handle_t handle); |
| 34 | effect_handle_t get(const uint64_t& id); |
| 35 | void remove(effect_handle_t handle); |
| 36 | |
| 37 | private: |
| 38 | static uint64_t makeUniqueId(); |
| 39 | |
| 40 | std::mutex mLock; |
| 41 | KeyedVector<uint64_t, effect_handle_t> mEffects; |
| 42 | }; |
| 43 | |
| 44 | } // namespace android |
| 45 | |
| 46 | #endif // android_hardware_audio_V2_0_EffectMap_H_ |