| François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 1 | /* | 
 | 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 |  | 
 | 22 | using std::string; | 
 | 23 |  | 
| François Gaffie | f19cf79 | 2018-05-30 17:22:17 +0200 | [diff] [blame] | 24 | namespace android { | 
 | 25 | namespace audio_policy { | 
| François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 26 |  | 
 | 27 | status_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 |  | 
| François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 37 | template <> | 
 | 38 | status_t Element<audio_stream_type_t>::set<audio_stream_type_t>(audio_stream_type_t volumeProfile) | 
| François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 39 | { | 
| François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 40 |     if (volumeProfile >= AUDIO_STREAM_CNT) { | 
| François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 41 |         return BAD_VALUE; | 
 | 42 |     } | 
| François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 43 |     mVolumeProfile = volumeProfile; | 
 | 44 |     ALOGD("%s: 0x%X for Stream %s", __FUNCTION__, mVolumeProfile, getName().c_str()); | 
| François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 45 |     return NO_ERROR; | 
 | 46 | } | 
 | 47 |  | 
| François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 48 | template <> | 
 | 49 | audio_stream_type_t Element<audio_stream_type_t>::get<audio_stream_type_t>() const | 
| François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 50 | { | 
| François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 51 |     ALOGV("%s: 0x%X for Stream %s", __FUNCTION__, mVolumeProfile, getName().c_str()); | 
 | 52 |     return mVolumeProfile; | 
| François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 53 | } | 
 | 54 |  | 
 | 55 | } // namespace audio_policy | 
 | 56 | } // namespace android | 
 | 57 |  |