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