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 LOG_TAG 16 #define LOG_TAG "AudioGroupHandle" 17 #endif 18 19 #include "audio_policy_log.h" 20 #include "audio_group_handle.h" 21 22 23 namespace OHOS { 24 namespace AudioStandard { ~AudioGroupHandle()25AudioGroupHandle::~AudioGroupHandle() 26 { 27 AUDIO_DEBUG_LOG("~AudioGroupHandle()"); 28 } 29 GetNextId(GroupType type)30int32_t AudioGroupHandle::GetNextId(GroupType type) 31 { 32 CheckId(type); 33 if (type == GroupType::VOLUME_TYPE) { 34 return ++currentVolumeId_; 35 } else { 36 return ++currentInterruptId_; 37 } 38 } 39 CheckId(GroupType type)40void AudioGroupHandle::CheckId(GroupType type) 41 { 42 if (type == GroupType::VOLUME_TYPE && currentVolumeId_ == MAX_ID) { 43 currentVolumeId_ = 0; 44 } else if (type == GroupType::INTERRUPT_TYPE && currentInterruptId_ == MAX_ID) { 45 currentInterruptId_ = 0; 46 } 47 } 48 } // namespace AudioStandard 49 } // namespace OHOS 50