120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie/* 220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * Copyright (C) 2015 The Android Open Source Project 320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * 420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * Licensed under the Apache License, Version 2.0 (the "License"); 520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * you may not use this file except in compliance with the License. 620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * You may obtain a copy of the License at 720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * 820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * http://www.apache.org/licenses/LICENSE-2.0 920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * 1020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * Unless required by applicable law or agreed to in writing, software 1120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * distributed under the License is distributed on an "AS IS" BASIS, 1220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * See the License for the specific language governing permissions and 1420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * limitations under the License. 1520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie */ 1620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 1720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#define LOG_TAG "APM::AudioPolicyEngine/Stream" 1820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 1920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include "Stream.h" 2020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <system/audio.h> 2120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 2220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffieusing std::string; 2320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 2420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffienamespace android 2520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{ 2620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffienamespace audio_policy 2720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{ 2820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 2920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffiestatus_t Element<audio_stream_type_t>::setIdentifier(audio_stream_type_t identifier) 3020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{ 3120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie if (identifier > AUDIO_STREAM_CNT) { 3220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie return BAD_VALUE; 3320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie } 3420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie mIdentifier = identifier; 3520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie ALOGD("%s: Stream %s identifier 0x%X", __FUNCTION__, getName().c_str(), identifier); 3620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie return NO_ERROR; 3720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie} 3820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 3920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie/** 4020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie* Set the strategy to follow for this stream. 4120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie* It checks if the strategy is valid. 4220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie* 4320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie* @param[in] strategy to be followed. 4420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie* 4520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie* @return NO_ERROR if the strategy is set correctly, error code otherwise. 4620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie*/ 4720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffietemplate <> 4820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffiestatus_t Element<audio_stream_type_t>::set<routing_strategy>(routing_strategy strategy) 4920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{ 5020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie if (strategy >= NUM_STRATEGIES) { 5120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie return BAD_VALUE; 5220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie } 5320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie mApplicableStrategy = strategy; 5420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie ALOGD("%s: 0x%X for Stream %s", __FUNCTION__, strategy, getName().c_str()); 5520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie return NO_ERROR; 5620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie} 5720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 5820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffietemplate <> 5920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffierouting_strategy Element<audio_stream_type_t>::get<routing_strategy>() const 6020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{ 6120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie ALOGV("%s: 0x%X for Stream %s", __FUNCTION__, mApplicableStrategy, getName().c_str()); 6220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie return mApplicableStrategy; 6320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie} 6420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 65d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffietemplate <> 66d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffiestatus_t Element<audio_stream_type_t>::set<audio_stream_type_t>(audio_stream_type_t volumeProfile) 6720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{ 68d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie if (volumeProfile >= AUDIO_STREAM_CNT) { 6920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie return BAD_VALUE; 7020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie } 71d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie mVolumeProfile = volumeProfile; 72d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie ALOGD("%s: 0x%X for Stream %s", __FUNCTION__, mVolumeProfile, getName().c_str()); 7320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie return NO_ERROR; 7420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie} 7520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 76d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffietemplate <> 77d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffieaudio_stream_type_t Element<audio_stream_type_t>::get<audio_stream_type_t>() const 7820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{ 79d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie ALOGV("%s: 0x%X for Stream %s", __FUNCTION__, mVolumeProfile, getName().c_str()); 80d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie return mVolumeProfile; 8120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie} 8220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 8320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie} // namespace audio_policy 8420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie} // namespace android 8520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie 86