diff options
author | Eric Laurent <elaurent@google.com> | 2014-11-30 15:14:47 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-12-09 15:47:19 -0800 |
commit | 275e8e9de2e11b4b344f5a201f1f0e51fda02d9c (patch) | |
tree | c22e1c0b8541aa04fd6c8d803e4fa6704a84e6e2 /include/media | |
parent | 82a69ea8b090d57bff5e02774688b546a711bbb8 (diff) | |
download | frameworks_av-275e8e9de2e11b4b344f5a201f1f0e51fda02d9c.zip frameworks_av-275e8e9de2e11b4b344f5a201f1f0e51fda02d9c.tar.gz frameworks_av-275e8e9de2e11b4b344f5a201f1f0e51fda02d9c.tar.bz2 |
audio policy: add support for custom mixes
Add support for custom mixes in AudioPolicyManager.
Two methods are added to register or unregister a list of custom mixes
with their attributes and format.
getOutputForAttr() and getInputForAttr() first look for a match in
registered mixes before defaulting to normal output/input selection
Remote submix device connection disconnection now takes address into
account to identify the correspnoding custom mix.
Bug: 16009464.
Change-Id: I3f1c2a485a0fb71b1f984ed0adc9b68aa971e408
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/AudioPolicy.h | 82 | ||||
-rw-r--r-- | include/media/AudioPolicyHelper.h | 2 |
2 files changed, 83 insertions, 1 deletions
diff --git a/include/media/AudioPolicy.h b/include/media/AudioPolicy.h new file mode 100644 index 0000000..a755e1e --- /dev/null +++ b/include/media/AudioPolicy.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_AUDIO_POLICY_H +#define ANDROID_AUDIO_POLICY_H + +#include <system/audio.h> +#include <system/audio_policy.h> +#include <binder/Parcel.h> +#include <utils/String8.h> +#include <utils/Vector.h> + +namespace android { + +// Keep in sync with AudioMix.java, AudioMixingRule.java, AudioPolicyConfig.java +#define RULE_EXCLUSION_MASK 0x8000 +#define RULE_MATCH_ATTRIBUTE_USAGE 0x1 +#define RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET (0x1 << 1) +#define RULE_EXCLUDE_ATTRIBUTE_USAGE (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_USAGE) +#define RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET \ + (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET) + +#define MIX_TYPE_INVALID -1 +#define MIX_TYPE_PLAYERS 0 +#define MIX_TYPE_RECORDERS 1 + +#define ROUTE_FLAG_RENDER 0x1 +#define ROUTE_FLAG_LOOP_BACK (0x1 << 1) + +#define MAX_MIXES_PER_POLICY 10 +#define MAX_CRITERIA_PER_MIX 20 + +class AttributeMatchCriterion { +public: + AttributeMatchCriterion() {} + AttributeMatchCriterion(audio_usage_t usage, audio_source_t source, uint32_t rule); + + status_t readFromParcel(Parcel *parcel); + status_t writeToParcel(Parcel *parcel) const; + + union { + audio_usage_t mUsage; + audio_source_t mSource; + } mAttr; + uint32_t mRule; +}; + +class AudioMix { +public: + AudioMix() {} + AudioMix(Vector<AttributeMatchCriterion> criteria, uint32_t mixType, audio_config_t format, + uint32_t routeFlags, String8 registrationId) : + mCriteria(criteria), mMixType(mixType), mFormat(format), + mRouteFlags(routeFlags), mRegistrationId(registrationId) {} + + status_t readFromParcel(Parcel *parcel); + status_t writeToParcel(Parcel *parcel) const; + + Vector<AttributeMatchCriterion> mCriteria; + uint32_t mMixType; + audio_config_t mFormat; + uint32_t mRouteFlags; + String8 mRegistrationId; +}; + +}; // namespace android + +#endif // ANDROID_AUDIO_POLICY_H diff --git a/include/media/AudioPolicyHelper.h b/include/media/AudioPolicyHelper.h index 3ed0b74..79231be 100644 --- a/include/media/AudioPolicyHelper.h +++ b/include/media/AudioPolicyHelper.h @@ -63,7 +63,7 @@ static audio_stream_type_t audio_attributes_to_stream_type(const audio_attribute static void stream_type_to_audio_attributes(audio_stream_type_t streamType, audio_attributes_t *attr) { - attr->flags = 0x0; + memset(attr, 0, sizeof(audio_attributes_t)); switch (streamType) { case AUDIO_STREAM_DEFAULT: |