FileDocCategorySizeDatePackage
AudioPort.javaAPI DocAndroid 5.1 API5888Thu Mar 12 22:22:30 GMT 2015android.media

AudioPort

public class AudioPort extends Object
An audio port is a node of the audio framework or hardware that can be connected to or disconnect from another audio node to create a specific audio routing configuration. Examples of audio ports are an output device (speaker) or an output mix (see AudioMixPort). All attributes that are relevant for applications to make routing selection are decribed in an AudioPort, in particular: - possible channel mask configurations. - audio format (PCM 16bit, PCM 24bit...) - gain: a port can be associated with one or more gain controllers (see AudioGain). This object is always created by the framework and read only by applications. A list of all audio port descriptors currently available for applications to control is obtained by AudioManager.listAudioPorts(). An application can obtain an AudioPortConfig for a valid configuration of this port by calling AudioPort.buildConfig() and use this configuration to create a connection between audio sinks and sources with AudioManager.connectAudioPatch()
hide

Fields Summary
public static final int
ROLE_NONE
For use by the audio framework.
public static final int
ROLE_SOURCE
The audio port is a source (produces audio)
public static final int
ROLE_SINK
The audio port is a sink (consumes audio)
public static final int
TYPE_NONE
audio port type for use by audio framework implementation
public static final int
TYPE_DEVICE
public static final int
TYPE_SUBMIX
public static final int
TYPE_SESSION
AudioHandle
mHandle
protected final int
mRole
private final int[]
mSamplingRates
private final int[]
mChannelMasks
private final int[]
mFormats
private final AudioGain[]
mGains
private AudioPortConfig
mActiveConfig
Constructors Summary
AudioPort(AudioHandle handle, int role, int[] samplingRates, int[] channelMasks, int[] formats, AudioGain[] gains)


           
                
        mHandle = handle;
        mRole = role;
        mSamplingRates = samplingRates;
        mChannelMasks = channelMasks;
        mFormats = formats;
        mGains = gains;
    
Methods Summary
public AudioPortConfigactiveConfig()
Get currently active configuration of this audio port.

        return mActiveConfig;
    
public AudioPortConfigbuildConfig(int samplingRate, int channelMask, int format, AudioGainConfig gain)
Build a specific configuration of this audio port for use by methods like AudioManager.connectAudioPatch().

param
channelMask The desired channel mask. AudioFormat.CHANNEL_OUT_DEFAULT if no change from active configuration requested.
param
format The desired audio format. AudioFormat.ENCODING_DEFAULT if no change from active configuration requested.
param
gain The desired gain. null if no gain changed requested.

        return new AudioPortConfig(this, samplingRate, channelMask, format, gain);
    
public int[]channelMasks()
Get the list of supported channel mask configurations (e.g AudioFormat.CHANNEL_OUT_STEREO) Empty array if channel mask is not relevant for this audio port

        return mChannelMasks;
    
public booleanequals(java.lang.Object o)

        if (o == null || !(o instanceof AudioPort)) {
            return false;
        }
        AudioPort ap = (AudioPort)o;
        return mHandle.equals(ap.handle());
    
public int[]formats()
Get the list of supported audio format configurations (e.g AudioFormat.ENCODING_PCM_16BIT) Empty array if format is not relevant for this audio port

        return mFormats;
    
AudioGaingain(int index)
Get the gain descriptor at a given index

        if (index < 0 || index >= mGains.length) {
            return null;
        }
        return mGains[index];
    
public AudioGain[]gains()
Get the list of gain descriptors Empty array if this port does not have gain control

        return mGains;
    
AudioHandlehandle()

        return mHandle;
    
public inthashCode()

        return mHandle.hashCode();
    
public introle()
Get the audio port role

        return mRole;
    
public int[]samplingRates()
Get the list of supported sampling rates Empty array if sampling rate is not relevant for this audio port

        return mSamplingRates;
    
public java.lang.StringtoString()

        String role = Integer.toString(mRole);
        switch (mRole) {
            case ROLE_NONE:
                role = "NONE";
                break;
            case ROLE_SOURCE:
                role = "SOURCE";
                break;
            case ROLE_SINK:
                role = "SINK";
                break;
        }
        return "{mHandle: " + mHandle
                + ", mRole: " + role
                + "}";