1// Copyright 2016 The Android Open Source Project 2// 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 "brillo_audio_client_helpers.h" 17 18namespace brillo { 19 20audio_policy_force_use_t BrilloAudioClientHelpers::GetForceUse( 21 BAudioUsage usage) { 22 if (usage == kUsageMedia) 23 return AUDIO_POLICY_FORCE_FOR_MEDIA; 24 else 25 return AUDIO_POLICY_FORCE_FOR_SYSTEM; 26} 27 28audio_stream_type_t BrilloAudioClientHelpers::GetStreamType(BAudioUsage usage) { 29 switch (usage) { 30 case kUsageAlarm: 31 return AUDIO_STREAM_ALARM; 32 case kUsageMedia: 33 return AUDIO_STREAM_MUSIC; 34 case kUsageNotifications: 35 return AUDIO_STREAM_NOTIFICATION; 36 case kUsageSystem: 37 return AUDIO_STREAM_SYSTEM; 38 default: 39 return AUDIO_STREAM_DEFAULT; 40 } 41} 42 43BAudioUsage BrilloAudioClientHelpers::GetBAudioUsage( 44 audio_stream_type_t stream) { 45 switch (stream) { 46 case AUDIO_STREAM_ALARM: 47 return kUsageAlarm; 48 case AUDIO_STREAM_MUSIC: 49 return kUsageMedia; 50 case AUDIO_STREAM_NOTIFICATION: 51 return kUsageNotifications; 52 case AUDIO_STREAM_SYSTEM: 53 return kUsageSystem; 54 default: 55 return kUsageInvalid; 56 } 57} 58 59} // namespace brillo 60