blob: 73fb94d4dc665b5e395893730936a4548fee0cde [file] [log] [blame]
François Gaffie20f06f92015-03-24 09:01:14 +01001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "APM::AudioPolicyEngine/Stream"
18
19#include "Stream.h"
20#include <system/audio.h>
21
22using std::string;
23
François Gaffief19cf792018-05-30 17:22:17 +020024namespace android {
25namespace audio_policy {
François Gaffie20f06f92015-03-24 09:01:14 +010026
27status_t Element<audio_stream_type_t>::setIdentifier(audio_stream_type_t identifier)
28{
29 if (identifier > AUDIO_STREAM_CNT) {
30 return BAD_VALUE;
31 }
32 mIdentifier = identifier;
33 ALOGD("%s: Stream %s identifier 0x%X", __FUNCTION__, getName().c_str(), identifier);
34 return NO_ERROR;
35}
36
37/**
38* Set the strategy to follow for this stream.
39* It checks if the strategy is valid.
40*
41* @param[in] strategy to be followed.
42*
43* @return NO_ERROR if the strategy is set correctly, error code otherwise.
44*/
45template <>
46status_t Element<audio_stream_type_t>::set<routing_strategy>(routing_strategy strategy)
47{
48 if (strategy >= NUM_STRATEGIES) {
49 return BAD_VALUE;
50 }
51 mApplicableStrategy = strategy;
52 ALOGD("%s: 0x%X for Stream %s", __FUNCTION__, strategy, getName().c_str());
53 return NO_ERROR;
54}
55
56template <>
57routing_strategy Element<audio_stream_type_t>::get<routing_strategy>() const
58{
59 ALOGV("%s: 0x%X for Stream %s", __FUNCTION__, mApplicableStrategy, getName().c_str());
60 return mApplicableStrategy;
61}
62
François Gaffied1ab2bd2015-12-02 18:20:06 +010063template <>
64status_t Element<audio_stream_type_t>::set<audio_stream_type_t>(audio_stream_type_t volumeProfile)
François Gaffie20f06f92015-03-24 09:01:14 +010065{
François Gaffied1ab2bd2015-12-02 18:20:06 +010066 if (volumeProfile >= AUDIO_STREAM_CNT) {
François Gaffie20f06f92015-03-24 09:01:14 +010067 return BAD_VALUE;
68 }
François Gaffied1ab2bd2015-12-02 18:20:06 +010069 mVolumeProfile = volumeProfile;
70 ALOGD("%s: 0x%X for Stream %s", __FUNCTION__, mVolumeProfile, getName().c_str());
François Gaffie20f06f92015-03-24 09:01:14 +010071 return NO_ERROR;
72}
73
François Gaffied1ab2bd2015-12-02 18:20:06 +010074template <>
75audio_stream_type_t Element<audio_stream_type_t>::get<audio_stream_type_t>() const
François Gaffie20f06f92015-03-24 09:01:14 +010076{
François Gaffied1ab2bd2015-12-02 18:20:06 +010077 ALOGV("%s: 0x%X for Stream %s", __FUNCTION__, mVolumeProfile, getName().c_str());
78 return mVolumeProfile;
François Gaffie20f06f92015-03-24 09:01:14 +010079}
80
81} // namespace audio_policy
82} // namespace android
83