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