1a198a29250acb7c3e918f1566727190966bb336fEric Laurent/*
2a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Copyright (C) 2014 The Android Open Source Project
3a198a29250acb7c3e918f1566727190966bb336fEric Laurent *
4a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
5a198a29250acb7c3e918f1566727190966bb336fEric Laurent * you may not use this file except in compliance with the License.
6a198a29250acb7c3e918f1566727190966bb336fEric Laurent * You may obtain a copy of the License at
7a198a29250acb7c3e918f1566727190966bb336fEric Laurent *
8a198a29250acb7c3e918f1566727190966bb336fEric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
9a198a29250acb7c3e918f1566727190966bb336fEric Laurent *
10a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Unless required by applicable law or agreed to in writing, software
11a198a29250acb7c3e918f1566727190966bb336fEric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
12a198a29250acb7c3e918f1566727190966bb336fEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a198a29250acb7c3e918f1566727190966bb336fEric Laurent * See the License for the specific language governing permissions and
14a198a29250acb7c3e918f1566727190966bb336fEric Laurent * limitations under the License.
15a198a29250acb7c3e918f1566727190966bb336fEric Laurent */
16a198a29250acb7c3e918f1566727190966bb336fEric Laurent
17a198a29250acb7c3e918f1566727190966bb336fEric Laurentpackage android.media;
18a198a29250acb7c3e918f1566727190966bb336fEric Laurent
19a198a29250acb7c3e918f1566727190966bb336fEric Laurent/**
20a198a29250acb7c3e918f1566727190966bb336fEric Laurent * The AudioMixPort is a specialized type of AudioPort
21a198a29250acb7c3e918f1566727190966bb336fEric Laurent * describing an audio mix or stream at an input or output stream of the audio
22a198a29250acb7c3e918f1566727190966bb336fEric Laurent * framework.
234bcdba848449b33d7022de527c526943aff1f5fdEric Laurent * In addition to base audio port attributes, the mix descriptor contains:
244bcdba848449b33d7022de527c526943aff1f5fdEric Laurent * - the unique audio I/O handle assigned by AudioFlinger to this mix.
25a198a29250acb7c3e918f1566727190966bb336fEric Laurent * @see AudioPort
26a198a29250acb7c3e918f1566727190966bb336fEric Laurent * @hide
27a198a29250acb7c3e918f1566727190966bb336fEric Laurent */
28a198a29250acb7c3e918f1566727190966bb336fEric Laurent
29a198a29250acb7c3e918f1566727190966bb336fEric Laurentpublic class AudioMixPort extends AudioPort {
30a198a29250acb7c3e918f1566727190966bb336fEric Laurent
314bcdba848449b33d7022de527c526943aff1f5fdEric Laurent    private final int mIoHandle;
324bcdba848449b33d7022de527c526943aff1f5fdEric Laurent
334bcdba848449b33d7022de527c526943aff1f5fdEric Laurent    AudioMixPort(AudioHandle handle, int ioHandle, int role, String deviceName,
34f29e5f34b39a5688925ca4654be0eab11277b1ccPaul McLean            int[] samplingRates, int[] channelMasks, int[] channelIndexMasks,
35a198a29250acb7c3e918f1566727190966bb336fEric Laurent            int[] formats, AudioGain[] gains) {
36f29e5f34b39a5688925ca4654be0eab11277b1ccPaul McLean        super(handle, role, deviceName, samplingRates, channelMasks, channelIndexMasks,
37f29e5f34b39a5688925ca4654be0eab11277b1ccPaul McLean                formats, gains);
384bcdba848449b33d7022de527c526943aff1f5fdEric Laurent        mIoHandle = ioHandle;
39a198a29250acb7c3e918f1566727190966bb336fEric Laurent    }
40a198a29250acb7c3e918f1566727190966bb336fEric Laurent
41a198a29250acb7c3e918f1566727190966bb336fEric Laurent    /**
42a198a29250acb7c3e918f1566727190966bb336fEric Laurent     * Build a specific configuration of this audio mix port for use by methods
43a198a29250acb7c3e918f1566727190966bb336fEric Laurent     * like AudioManager.connectAudioPatch().
44a198a29250acb7c3e918f1566727190966bb336fEric Laurent     */
45a198a29250acb7c3e918f1566727190966bb336fEric Laurent    public AudioMixPortConfig buildConfig(int samplingRate, int channelMask, int format,
46a198a29250acb7c3e918f1566727190966bb336fEric Laurent                                       AudioGainConfig gain) {
47a198a29250acb7c3e918f1566727190966bb336fEric Laurent        return new AudioMixPortConfig(this, samplingRate, channelMask, format, gain);
48a198a29250acb7c3e918f1566727190966bb336fEric Laurent    }
49a198a29250acb7c3e918f1566727190966bb336fEric Laurent
504bcdba848449b33d7022de527c526943aff1f5fdEric Laurent    /**
514bcdba848449b33d7022de527c526943aff1f5fdEric Laurent     * Get the device type (e.g AudioManager.DEVICE_OUT_SPEAKER)
524bcdba848449b33d7022de527c526943aff1f5fdEric Laurent     */
534bcdba848449b33d7022de527c526943aff1f5fdEric Laurent    public int ioHandle() {
544bcdba848449b33d7022de527c526943aff1f5fdEric Laurent        return mIoHandle;
554bcdba848449b33d7022de527c526943aff1f5fdEric Laurent    }
564bcdba848449b33d7022de527c526943aff1f5fdEric Laurent
57a198a29250acb7c3e918f1566727190966bb336fEric Laurent    @Override
58a198a29250acb7c3e918f1566727190966bb336fEric Laurent    public boolean equals(Object o) {
59a198a29250acb7c3e918f1566727190966bb336fEric Laurent        if (o == null || !(o instanceof AudioMixPort)) {
60a198a29250acb7c3e918f1566727190966bb336fEric Laurent            return false;
61a198a29250acb7c3e918f1566727190966bb336fEric Laurent        }
624bcdba848449b33d7022de527c526943aff1f5fdEric Laurent        AudioMixPort other = (AudioMixPort)o;
634bcdba848449b33d7022de527c526943aff1f5fdEric Laurent        if (mIoHandle != other.ioHandle()) {
644bcdba848449b33d7022de527c526943aff1f5fdEric Laurent            return false;
654bcdba848449b33d7022de527c526943aff1f5fdEric Laurent        }
664bcdba848449b33d7022de527c526943aff1f5fdEric Laurent
67a198a29250acb7c3e918f1566727190966bb336fEric Laurent        return super.equals(o);
68a198a29250acb7c3e918f1566727190966bb336fEric Laurent    }
69a198a29250acb7c3e918f1566727190966bb336fEric Laurent
70a198a29250acb7c3e918f1566727190966bb336fEric Laurent}
71