blob: 800b27bee0c3f5e921f9d3d027cd522521fbbc3b [file] [log] [blame]
Eric Laurent275e8e92014-11-30 15:14:47 -08001/*
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
27namespace 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 Trivide801052015-04-14 19:10:14 -070041#define MIX_STATE_DISABLED -1
42#define MIX_STATE_IDLE 0
43#define MIX_STATE_MIXING 1
44
Eric Laurent275e8e92014-11-30 15:14:47 -080045#define ROUTE_FLAG_RENDER 0x1
46#define ROUTE_FLAG_LOOP_BACK (0x1 << 1)
47
Jean-Michel Trivide801052015-04-14 19:10:14 -070048#define MIX_FLAG_NOTIFY_ACTIVITY 0x1
49
Eric Laurent275e8e92014-11-30 15:14:47 -080050#define MAX_MIXES_PER_POLICY 10
51#define MAX_CRITERIA_PER_MIX 20
52
53class AttributeMatchCriterion {
54public:
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
68class AudioMix {
69public:
70 AudioMix() {}
71 AudioMix(Vector<AttributeMatchCriterion> criteria, uint32_t mixType, audio_config_t format,
Jean-Michel Trivide801052015-04-14 19:10:14 -070072 uint32_t routeFlags, String8 registrationId, uint32_t flags) :
Eric Laurent275e8e92014-11-30 15:14:47 -080073 mCriteria(criteria), mMixType(mixType), mFormat(format),
Jean-Michel Trivide801052015-04-14 19:10:14 -070074 mRouteFlags(routeFlags), mRegistrationId(registrationId), mFlags(flags){}
Eric Laurent275e8e92014-11-30 15:14:47 -080075
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 Trivide801052015-04-14 19:10:14 -070084 uint32_t mFlags;
Eric Laurent275e8e92014-11-30 15:14:47 -080085};
86
87}; // namespace android
88
89#endif // ANDROID_AUDIO_POLICY_H