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 23 /** 24 * An AudioPatch describes a connection between audio sources and audio sinks. 25 * An audio source can be an output mix (playback AudioBus) or an input device (microphone). 26 * An audio sink can be an output device (speaker) or an input mix (capture AudioBus). 27 * An AudioPatch is created by AudioManager.createAudioPatch() and released by 28 * AudioManager.releaseAudioPatch() 29 * It contains the list of source and sink AudioPortConfig showing audio port configurations 30 * being connected. 31 * @hide 32 */ 33 public class AudioPatch { 34 35 @UnsupportedAppUsage 36 private final AudioHandle mHandle; 37 private final AudioPortConfig[] mSources; 38 private final AudioPortConfig[] mSinks; 39 40 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) AudioPatch(AudioHandle patchHandle, AudioPortConfig[] sources, AudioPortConfig[] sinks)41 AudioPatch(AudioHandle patchHandle, AudioPortConfig[] sources, AudioPortConfig[] sinks) { 42 mHandle = patchHandle; 43 mSources = sources; 44 mSinks = sinks; 45 } 46 47 /** 48 * Retrieve the list of sources of this audio patch. 49 */ 50 @UnsupportedAppUsage sources()51 public AudioPortConfig[] sources() { 52 return mSources; 53 } 54 55 /** 56 * Retreive the list of sinks of this audio patch. 57 */ 58 @UnsupportedAppUsage sinks()59 public AudioPortConfig[] sinks() { 60 return mSinks; 61 } 62 63 /** 64 * Get the system unique patch ID. 65 */ id()66 public int id() { 67 return mHandle.id(); 68 } 69 70 @Override toString()71 public String toString() { 72 StringBuilder s = new StringBuilder(); 73 s.append("mHandle: "); 74 s.append(mHandle.toString()); 75 76 s.append(" mSources: {"); 77 for (AudioPortConfig source : mSources) { 78 s.append(source.toString()); 79 s.append(", "); 80 } 81 s.append("} mSinks: {"); 82 for (AudioPortConfig sink : mSinks) { 83 s.append(sink.toString()); 84 s.append(", "); 85 } 86 s.append("}"); 87 88 return s.toString(); 89 } 90 } 91