Home | History | Annotate | Download | only in media
      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 
     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  */
     30 public 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     /**
     57      * Get the system unique patch ID.
     58      */
     59     public int id() {
     60         return mHandle.id();
     61     }
     62 
     63     @Override
     64     public String toString() {
     65         StringBuilder s = new StringBuilder();
     66         s.append("mHandle: ");
     67         s.append(mHandle.toString());
     68 
     69         s.append(" mSources: {");
     70         for (AudioPortConfig source : mSources) {
     71             s.append(source.toString());
     72             s.append(", ");
     73         }
     74         s.append("} mSinks: {");
     75         for (AudioPortConfig sink : mSinks) {
     76             s.append(sink.toString());
     77             s.append(", ");
     78         }
     79         s.append("}");
     80 
     81         return s.toString();
     82     }
     83 }
     84