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