1 /* 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 package android.media; 18 19 import android.compat.annotation.UnsupportedAppUsage; 20 import android.os.Build; 21 22 import java.util.List; 23 24 /** 25 * The AudioMixPort is a specialized type of AudioPort 26 * describing an audio mix or stream at an input or output stream of the audio 27 * framework. 28 * In addition to base audio port attributes, the mix descriptor contains: 29 * - the unique audio I/O handle assigned by AudioFlinger to this mix. 30 * @see AudioPort 31 * @hide 32 */ 33 34 public class AudioMixPort extends AudioPort { 35 36 private final int mIoHandle; 37 38 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) AudioMixPort(AudioHandle handle, int ioHandle, int role, String deviceName, int[] samplingRates, int[] channelMasks, int[] channelIndexMasks, int[] formats, AudioGain[] gains)39 AudioMixPort(AudioHandle handle, int ioHandle, int role, String deviceName, 40 int[] samplingRates, int[] channelMasks, int[] channelIndexMasks, 41 int[] formats, AudioGain[] gains) { 42 super(handle, role, deviceName, samplingRates, channelMasks, channelIndexMasks, 43 formats, gains); 44 mIoHandle = ioHandle; 45 } 46 AudioMixPort(AudioHandle handle, int ioHandle, int role, String deviceName, List<AudioProfile> profiles, AudioGain[] gains)47 AudioMixPort(AudioHandle handle, int ioHandle, int role, String deviceName, 48 List<AudioProfile> profiles, AudioGain[] gains) { 49 super(handle, role, deviceName, profiles, gains, null); 50 mIoHandle = ioHandle; 51 } 52 53 /** 54 * Build a specific configuration of this audio mix port for use by methods 55 * like AudioManager.connectAudioPatch(). 56 */ buildConfig(int samplingRate, int channelMask, int format, AudioGainConfig gain)57 public AudioMixPortConfig buildConfig(int samplingRate, int channelMask, int format, 58 AudioGainConfig gain) { 59 return new AudioMixPortConfig(this, samplingRate, channelMask, format, gain); 60 } 61 62 /** 63 * Get the device type (e.g AudioManager.DEVICE_OUT_SPEAKER) 64 */ 65 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) ioHandle()66 public int ioHandle() { 67 return mIoHandle; 68 } 69 70 @Override equals(Object o)71 public boolean equals(Object o) { 72 if (o == null || !(o instanceof AudioMixPort)) { 73 return false; 74 } 75 AudioMixPort other = (AudioMixPort)o; 76 if (mIoHandle != other.ioHandle()) { 77 return false; 78 } 79 80 return super.equals(o); 81 } 82 83 } 84