Home | History | Annotate | Download | only in audiopolicy

Lines Matching refs:rule

32  * Here's an example of creating a mixing rule for all media playback:
51 * A rule requiring the usage information of the {@link AudioAttributes} to match.
52 * This mixing rule can be added with {@link Builder#addRule(AudioAttributes, int)} or
59 * A rule requiring the capture preset information of the {@link AudioAttributes} to match.
60 * This mixing rule can be added with {@link Builder#addRule(AudioAttributes, int)} or
67 * A rule requiring the UID of the audio stream to match that specified.
68 * This mixing rule can be added with {@link Builder#addMixRule(int, Object)} where the Object
77 * A rule requiring the usage information of the {@link AudioAttributes} to differ.
83 * A rule requiring the capture preset information of the {@link AudioAttributes} to differ.
89 * A rule requiring the UID information to differ.
100 AudioMixMatchCriterion(AudioAttributes attributes, int rule) {
103 mRule = rule;
106 AudioMixMatchCriterion(Integer intProp, int rule) {
109 mRule = rule;
131 Log.e("AudioMixMatchCriterion", "Unknown match rule" + match_rule
148 private static boolean isValidSystemApiRule(int rule) {
150 switch (rule) {
159 private static boolean isValidAttributesSystemApiRule(int rule) {
161 switch (rule) {
170 private static boolean isValidRule(int rule) {
171 final int match_rule = rule & ~RULE_EXCLUSION_MASK;
182 private static boolean isPlayerRule(int rule) {
183 final int match_rule = rule & ~RULE_EXCLUSION_MASK;
220 * Add a rule for the selection of which streams are mixed together.
222 * rule hasn't been set yet.
223 * @param rule {@link AudioMixingRule#RULE_MATCH_ATTRIBUTE_USAGE} or
230 public Builder addRule(AudioAttributes attrToMatch, int rule)
232 if (!isValidAttributesSystemApiRule(rule)) {
233 throw new IllegalArgumentException("Illegal rule value " + rule);
235 return checkAddRuleObjInternal(rule, attrToMatch);
239 * Add a rule by exclusion for the selection of which streams are mixed together.
249 * <br>will create a rule which maps to any usage value, except USAGE_MEDIA.
251 * rule hasn't been set yet.
252 * @param rule {@link AudioMixingRule#RULE_MATCH_ATTRIBUTE_USAGE} or
259 public Builder excludeRule(AudioAttributes attrToMatch, int rule)
261 if (!isValidAttributesSystemApiRule(rule)) {
262 throw new IllegalArgumentException("Illegal rule value " + rule);
264 return checkAddRuleObjInternal(rule | RULE_EXCLUSION_MASK, attrToMatch);
268 * Add a rule for the selection of which streams are mixed together.
269 * The rule defines what the matching will be made on. It also determines the type of the
271 * @param rule one of {@link AudioMixingRule#RULE_MATCH_ATTRIBUTE_USAGE},
274 * @param property see the definition of each rule for the type to use (either an
281 public Builder addMixRule(int rule, Object property) throws IllegalArgumentException {
282 if (!isValidSystemApiRule(rule)) {
283 throw new IllegalArgumentException("Illegal rule value " + rule);
285 return checkAddRuleObjInternal(rule, property);
289 * Add a rule by exclusion for the selection of which streams are mixed together.
300 * <br>will create a rule which maps to usage USAGE_MEDIA, but excludes any stream
302 * @param rule one of {@link AudioMixingRule#RULE_MATCH_ATTRIBUTE_USAGE},
305 * @param property see the definition of each rule for the type to use (either an
311 public Builder excludeMixRule(int rule, Object property) throws IllegalArgumentException {
312 if (!isValidSystemApiRule(rule)) {
313 throw new IllegalArgumentException("Illegal rule value " + rule);
315 return checkAddRuleObjInternal(rule | RULE_EXCLUSION_MASK, property);
319 * Add or exclude a rule for the selection of which streams are mixed together.
321 * @param rule
326 private Builder checkAddRuleObjInternal(int rule, Object property)
329 throw new IllegalArgumentException("Illegal null argument for mixing rule");
331 if (!isValidRule(rule)) {
332 throw new IllegalArgumentException("Illegal rule value " + rule);
334 final int match_rule = rule & ~RULE_EXCLUSION_MASK;
339 return addRuleInternal((AudioAttributes) property, null, rule);
341 // implies integer match rule
345 return addRuleInternal(null, (Integer) property, rule);
350 * Add or exclude a rule on AudioAttributes or integer property for the selection of which
352 * No rule-to-parameter type check, all done in {@link #checkAddRuleObjInternal(int, Object)}.
355 * rule hasn't been set yet, null if not used.
357 * @param rule one of {@link AudioMixingRule#RULE_EXCLUDE_ATTRIBUTE_USAGE},
365 private Builder addRuleInternal(AudioAttributes attrToMatch, Integer intProp, int rule)
368 // of mix being built. When adding the first rule, the mix type is MIX_TYPE_INVALID.
370 if (isPlayerRule(rule)) {
375 } else if (((mTargetMixType == AudioMix.MIX_TYPE_PLAYERS) && !isPlayerRule(rule))
376 || ((mTargetMixType == AudioMix.MIX_TYPE_RECORDERS) && isPlayerRule(rule)))
378 throw new IllegalArgumentException("Incompatible rule for mix");
382 final int match_rule = rule & ~RULE_EXCLUSION_MASK;
387 // "usage"-based rule
389 if (criterion.mRule == rule) {
390 // rule already exists, we're done
393 // criterion already exists with a another rule,
395 throw new IllegalArgumentException("Contradictory rule exists"
401 // "capture preset"-base rule
403 if (criterion.mRule == rule) {
404 // rule already exists, we're done
407 // criterion already exists with a another rule,
409 throw new IllegalArgumentException("Contradictory rule exists"
415 // "usage"-based rule
417 if (criterion.mRule == rule) {
418 // rule already exists, we're done
421 // criterion already exists with a another rule,
423 throw new IllegalArgumentException("Contradictory rule exists"
430 // rule didn't exist, add it
434 mCriteria.add(new AudioMixMatchCriterion(attrToMatch, rule));
437 mCriteria.add(new AudioMixMatchCriterion(intProp, rule));
447 final int rule = in.readInt();
448 final int match_rule = rule & ~RULE_EXCLUSION_MASK;
468 throw new IllegalArgumentException("Illegal rule value " + rule + " in parcel");
470 return addRuleInternal(attr, intProp, rule);