1 /* 2 * Copyright (C) 2018 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 18 #pragma once 19 20 #include <media/AudioCommonTypes.h> 21 #include <system/audio.h> 22 #include <system/audio_policy.h> 23 #include <binder/Parcelable.h> 24 25 namespace android { 26 27 class AudioAttributes : public Parcelable 28 { 29 public: 30 AudioAttributes() = default; AudioAttributes(const audio_attributes_t & attributes)31 AudioAttributes(const audio_attributes_t &attributes) : mAttributes(attributes) {} // NOLINT AudioAttributes(volume_group_t groupId,audio_stream_type_t stream,const audio_attributes_t & attributes)32 AudioAttributes(volume_group_t groupId, 33 audio_stream_type_t stream, 34 const audio_attributes_t &attributes) : 35 mAttributes(attributes), mStreamType(stream), mGroupId(groupId) {} 36 getAttributes()37 audio_attributes_t getAttributes() const { return mAttributes; } 38 39 status_t readFromParcel(const Parcel *parcel) override; 40 status_t writeToParcel(Parcel *parcel) const override; 41 getStreamType()42 audio_stream_type_t getStreamType() const { return mStreamType; } getGroupId()43 volume_group_t getGroupId() const { return mGroupId; } 44 45 private: 46 audio_attributes_t mAttributes = AUDIO_ATTRIBUTES_INITIALIZER; 47 /** 48 * @brief mStreamType: for legacy volume management, we need to be able to convert an attribute 49 * to a given stream type. 50 */ 51 audio_stream_type_t mStreamType = AUDIO_STREAM_DEFAULT; 52 53 /** 54 * @brief mGroupId: for future volume management, define groups within a strategy that follows 55 * the same curves of volume (extension of stream types to manage volume) 56 */ 57 volume_group_t mGroupId = VOLUME_GROUP_NONE; 58 }; 59 60 } // namespace android 61