1 /* 2 * Copyright (c) 2022-2022 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 AUDIO_GROUP_HANDLE_H 16 #define AUDIO_GROUP_HANDLE_H 17 18 #include <iostream> 19 #include <string> 20 21 namespace OHOS { 22 namespace AudioStandard { 23 static const int32_t MAX_ID = 10000; 24 static const int32_t GROUP_ID_NONE = -1; 25 static const int32_t NO_REMOTE_ID = -2; 26 static const std::string GROUP_NAME_NONE = "NO_GROUP"; 27 static const std::string GROUP_NAME_DEFAULT = "DEFULT_GROUP"; 28 29 enum GroupType { 30 VOLUME_TYPE = 1, 31 INTERRUPT_TYPE = 2 32 }; 33 34 class AudioGroupHandle { 35 public: GetInstance()36 static AudioGroupHandle& GetInstance() 37 { 38 static AudioGroupHandle audioGroupHandle; 39 return audioGroupHandle; 40 } 41 42 int32_t GetNextId(GroupType type); 43 44 private: AudioGroupHandle()45 AudioGroupHandle() 46 { 47 currentVolumeId_ = 0; 48 currentInterruptId_ = 0; 49 } 50 51 ~AudioGroupHandle(); 52 53 void CheckId(GroupType type); 54 55 int32_t currentVolumeId_; 56 int32_t currentInterruptId_; 57 }; 58 } // namespace AudioStandard 59 } // namespace OHOS 60 #endif // AUDIO_GROUP_HANDLE_H