| Eric Laurent | 275e8e9 | 2014-11-30 15:14:47 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2014 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 | #ifndef ANDROID_AUDIO_POLICY_H | 
|  | 19 | #define ANDROID_AUDIO_POLICY_H | 
|  | 20 |  | 
|  | 21 | #include <system/audio.h> | 
|  | 22 | #include <system/audio_policy.h> | 
|  | 23 | #include <binder/Parcel.h> | 
|  | 24 | #include <utils/String8.h> | 
|  | 25 | #include <utils/Vector.h> | 
|  | 26 |  | 
|  | 27 | namespace android { | 
|  | 28 |  | 
|  | 29 | // Keep in sync with AudioMix.java, AudioMixingRule.java, AudioPolicyConfig.java | 
|  | 30 | #define RULE_EXCLUSION_MASK 0x8000 | 
|  | 31 | #define RULE_MATCH_ATTRIBUTE_USAGE 0x1 | 
|  | 32 | #define RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET (0x1 << 1) | 
|  | 33 | #define RULE_EXCLUDE_ATTRIBUTE_USAGE (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_USAGE) | 
|  | 34 | #define RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET \ | 
|  | 35 | (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET) | 
|  | 36 |  | 
|  | 37 | #define MIX_TYPE_INVALID -1 | 
|  | 38 | #define MIX_TYPE_PLAYERS 0 | 
|  | 39 | #define MIX_TYPE_RECORDERS 1 | 
|  | 40 |  | 
| Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 41 | #define MIX_STATE_DISABLED -1 | 
|  | 42 | #define MIX_STATE_IDLE 0 | 
|  | 43 | #define MIX_STATE_MIXING 1 | 
|  | 44 |  | 
| Eric Laurent | 275e8e9 | 2014-11-30 15:14:47 -0800 | [diff] [blame] | 45 | #define ROUTE_FLAG_RENDER 0x1 | 
|  | 46 | #define ROUTE_FLAG_LOOP_BACK (0x1 << 1) | 
|  | 47 |  | 
| Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 48 | #define MIX_FLAG_NOTIFY_ACTIVITY 0x1 | 
|  | 49 |  | 
| Eric Laurent | 275e8e9 | 2014-11-30 15:14:47 -0800 | [diff] [blame] | 50 | #define MAX_MIXES_PER_POLICY 10 | 
|  | 51 | #define MAX_CRITERIA_PER_MIX 20 | 
|  | 52 |  | 
|  | 53 | class AttributeMatchCriterion { | 
|  | 54 | public: | 
|  | 55 | AttributeMatchCriterion() {} | 
|  | 56 | AttributeMatchCriterion(audio_usage_t usage, audio_source_t source, uint32_t rule); | 
|  | 57 |  | 
|  | 58 | status_t readFromParcel(Parcel *parcel); | 
|  | 59 | status_t writeToParcel(Parcel *parcel) const; | 
|  | 60 |  | 
|  | 61 | union { | 
|  | 62 | audio_usage_t   mUsage; | 
|  | 63 | audio_source_t  mSource; | 
|  | 64 | } mAttr; | 
|  | 65 | uint32_t        mRule; | 
|  | 66 | }; | 
|  | 67 |  | 
|  | 68 | class AudioMix { | 
|  | 69 | public: | 
|  | 70 | AudioMix() {} | 
|  | 71 | AudioMix(Vector<AttributeMatchCriterion> criteria, uint32_t mixType, audio_config_t format, | 
| Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 72 | uint32_t routeFlags, String8 registrationId, uint32_t flags) : | 
| Eric Laurent | 275e8e9 | 2014-11-30 15:14:47 -0800 | [diff] [blame] | 73 | mCriteria(criteria), mMixType(mixType), mFormat(format), | 
| Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 74 | mRouteFlags(routeFlags), mRegistrationId(registrationId), mFlags(flags){} | 
| Eric Laurent | 275e8e9 | 2014-11-30 15:14:47 -0800 | [diff] [blame] | 75 |  | 
|  | 76 | status_t readFromParcel(Parcel *parcel); | 
|  | 77 | status_t writeToParcel(Parcel *parcel) const; | 
|  | 78 |  | 
|  | 79 | Vector<AttributeMatchCriterion> mCriteria; | 
|  | 80 | uint32_t        mMixType; | 
|  | 81 | audio_config_t  mFormat; | 
|  | 82 | uint32_t        mRouteFlags; | 
|  | 83 | String8         mRegistrationId; | 
| Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 84 | uint32_t        mFlags; | 
| Eric Laurent | 275e8e9 | 2014-11-30 15:14:47 -0800 | [diff] [blame] | 85 | }; | 
|  | 86 |  | 
|  | 87 | }; // namespace android | 
|  | 88 |  | 
|  | 89 | #endif  // ANDROID_AUDIO_POLICY_H |