blob: a755e1edac47c9f0e62d20430dd230d7bc6b38cc [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
41#define ROUTE_FLAG_RENDER 0x1
42#define ROUTE_FLAG_LOOP_BACK (0x1 << 1)
43
44#define MAX_MIXES_PER_POLICY 10
45#define MAX_CRITERIA_PER_MIX 20
46
47class AttributeMatchCriterion {
48public:
49 AttributeMatchCriterion() {}
50 AttributeMatchCriterion(audio_usage_t usage, audio_source_t source, uint32_t rule);
51
52 status_t readFromParcel(Parcel *parcel);
53 status_t writeToParcel(Parcel *parcel) const;
54
55 union {
56 audio_usage_t mUsage;
57 audio_source_t mSource;
58 } mAttr;
59 uint32_t mRule;
60};
61
62class AudioMix {
63public:
64 AudioMix() {}
65 AudioMix(Vector<AttributeMatchCriterion> criteria, uint32_t mixType, audio_config_t format,
66 uint32_t routeFlags, String8 registrationId) :
67 mCriteria(criteria), mMixType(mixType), mFormat(format),
68 mRouteFlags(routeFlags), mRegistrationId(registrationId) {}
69
70 status_t readFromParcel(Parcel *parcel);
71 status_t writeToParcel(Parcel *parcel) const;
72
73 Vector<AttributeMatchCriterion> mCriteria;
74 uint32_t mMixType;
75 audio_config_t mFormat;
76 uint32_t mRouteFlags;
77 String8 mRegistrationId;
78};
79
80}; // namespace android
81
82#endif // ANDROID_AUDIO_POLICY_H