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