1275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent/* 2275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * Copyright (C) 2014 The Android Open Source Project 3275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * 4275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 5275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * you may not use this file except in compliance with the License. 6275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * You may obtain a copy of the License at 7275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * 8275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 9275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * 10275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * Unless required by applicable law or agreed to in writing, software 11275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 12275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * See the License for the specific language governing permissions and 14275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent * limitations under the License. 15275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent */ 16275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 17275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 18275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#ifndef ANDROID_AUDIO_POLICY_H 19275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define ANDROID_AUDIO_POLICY_H 20275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 21275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <system/audio.h> 22275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <system/audio_policy.h> 23275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <binder/Parcel.h> 24275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <utils/String8.h> 25275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#include <utils/Vector.h> 26275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 27275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentnamespace android { 28275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 29275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent// Keep in sync with AudioMix.java, AudioMixingRule.java, AudioPolicyConfig.java 30275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_EXCLUSION_MASK 0x8000 31275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_MATCH_ATTRIBUTE_USAGE 0x1 32275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET (0x1 << 1) 33275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_EXCLUDE_ATTRIBUTE_USAGE (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_USAGE) 34275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET \ 35275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET) 36275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 37275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MIX_TYPE_INVALID -1 38275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MIX_TYPE_PLAYERS 0 39275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MIX_TYPE_RECORDERS 1 40275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 41f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi// definition of the different events that can be reported on a dynamic policy from 42f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi// AudioSystem's implementation of the AudioPolicyClient interface 43f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi// keep in sync with AudioSystem.java 44f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi#define DYNAMIC_POLICY_EVENT_MIX_STATE_UPDATE 0 45f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi 46de80105c3f2db0eabd47640c49387ea3b44d4782Jean-Michel Trivi#define MIX_STATE_DISABLED -1 47de80105c3f2db0eabd47640c49387ea3b44d4782Jean-Michel Trivi#define MIX_STATE_IDLE 0 48de80105c3f2db0eabd47640c49387ea3b44d4782Jean-Michel Trivi#define MIX_STATE_MIXING 1 49de80105c3f2db0eabd47640c49387ea3b44d4782Jean-Michel Trivi 50f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi#define MIX_ROUTE_FLAG_RENDER 0x1 51f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi#define MIX_ROUTE_FLAG_LOOP_BACK (0x1 << 1) 52de80105c3f2db0eabd47640c49387ea3b44d4782Jean-Michel Trivi 53275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MAX_MIXES_PER_POLICY 10 54275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#define MAX_CRITERIA_PER_MIX 20 55275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 56275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentclass AttributeMatchCriterion { 57275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentpublic: 58275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent AttributeMatchCriterion() {} 59275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent AttributeMatchCriterion(audio_usage_t usage, audio_source_t source, uint32_t rule); 60275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 61275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent status_t readFromParcel(Parcel *parcel); 62275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent status_t writeToParcel(Parcel *parcel) const; 63275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 64275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent union { 65275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent audio_usage_t mUsage; 66275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent audio_source_t mSource; 67275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent } mAttr; 68275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent uint32_t mRule; 69275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent}; 70275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 71275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentclass AudioMix { 72275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurentpublic: 73f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi // flag on an AudioMix indicating the activity on this mix (IDLE, MIXING) 74f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi // must be reported through the AudioPolicyClient interface 75f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi static const uint32_t kCbFlagNotifyActivity = 0x1; 76f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi 77275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent AudioMix() {} 78275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent AudioMix(Vector<AttributeMatchCriterion> criteria, uint32_t mixType, audio_config_t format, 79de80105c3f2db0eabd47640c49387ea3b44d4782Jean-Michel Trivi uint32_t routeFlags, String8 registrationId, uint32_t flags) : 80275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent mCriteria(criteria), mMixType(mixType), mFormat(format), 81f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi mRouteFlags(routeFlags), mRegistrationId(registrationId), mCbFlags(flags){} 82275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 83275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent status_t readFromParcel(Parcel *parcel); 84275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent status_t writeToParcel(Parcel *parcel) const; 85275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 86275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent Vector<AttributeMatchCriterion> mCriteria; 87275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent uint32_t mMixType; 88275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent audio_config_t mFormat; 89275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent uint32_t mRouteFlags; 90275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent String8 mRegistrationId; 91f613d42b12389335b2ecf06df18d0d095d6bfd44Jean-Michel Trivi uint32_t mCbFlags; // flags indicating which callbacks to use, see kCbFlag* 92275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent}; 93275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 94275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent}; // namespace android 95275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent 96275e8e9de2e11b4b344f5a201f1f0e51fda02d9cEric Laurent#endif // ANDROID_AUDIO_POLICY_H 97