FileDocCategorySizeDatePackage
AudioSystem.javaAPI DocAndroid 5.1 API27469Thu Mar 12 22:22:30 GMT 2015android.media

AudioSystem

public class AudioSystem extends Object
hide

Fields Summary
public static final int
STREAM_DEFAULT
public static final int
STREAM_VOICE_CALL
public static final int
STREAM_SYSTEM
public static final int
STREAM_RING
public static final int
STREAM_MUSIC
public static final int
STREAM_ALARM
public static final int
STREAM_NOTIFICATION
public static final int
STREAM_BLUETOOTH_SCO
public static final int
STREAM_SYSTEM_ENFORCED
public static final int
STREAM_DTMF
public static final int
STREAM_TTS
public static final int
NUM_STREAMS
private static final int
NUM_STREAM_TYPES
public static final int
MODE_INVALID
public static final int
MODE_CURRENT
public static final int
MODE_NORMAL
public static final int
MODE_RINGTONE
public static final int
MODE_IN_CALL
public static final int
MODE_IN_COMMUNICATION
public static final int
NUM_MODES
public static final int
ROUTE_EARPIECE
public static final int
ROUTE_SPEAKER
public static final int
ROUTE_BLUETOOTH
public static final int
ROUTE_BLUETOOTH_SCO
public static final int
ROUTE_HEADSET
public static final int
ROUTE_BLUETOOTH_A2DP
public static final int
ROUTE_ALL
public static final int
AUDIO_SESSION_ALLOCATE
public static final int
AUDIO_STATUS_OK
public static final int
AUDIO_STATUS_ERROR
public static final int
AUDIO_STATUS_SERVER_DIED
private static ErrorCallback
mErrorCallback
public static final int
SUCCESS
public static final int
ERROR
public static final int
BAD_VALUE
public static final int
INVALID_OPERATION
public static final int
PERMISSION_DENIED
public static final int
NO_INIT
public static final int
DEAD_OBJECT
public static final int
DEVICE_NONE
public static final int
DEVICE_BIT_IN
public static final int
DEVICE_BIT_DEFAULT
public static final int
DEVICE_OUT_EARPIECE
public static final int
DEVICE_OUT_SPEAKER
public static final int
DEVICE_OUT_WIRED_HEADSET
public static final int
DEVICE_OUT_WIRED_HEADPHONE
public static final int
DEVICE_OUT_BLUETOOTH_SCO
public static final int
DEVICE_OUT_BLUETOOTH_SCO_HEADSET
public static final int
DEVICE_OUT_BLUETOOTH_SCO_CARKIT
public static final int
DEVICE_OUT_BLUETOOTH_A2DP
public static final int
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES
public static final int
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER
public static final int
DEVICE_OUT_AUX_DIGITAL
public static final int
DEVICE_OUT_HDMI
public static final int
DEVICE_OUT_ANLG_DOCK_HEADSET
public static final int
DEVICE_OUT_DGTL_DOCK_HEADSET
public static final int
DEVICE_OUT_USB_ACCESSORY
public static final int
DEVICE_OUT_USB_DEVICE
public static final int
DEVICE_OUT_REMOTE_SUBMIX
public static final int
DEVICE_OUT_TELEPHONY_TX
public static final int
DEVICE_OUT_LINE
public static final int
DEVICE_OUT_HDMI_ARC
public static final int
DEVICE_OUT_SPDIF
public static final int
DEVICE_OUT_FM
public static final int
DEVICE_OUT_AUX_LINE
public static final int
DEVICE_OUT_SPEAKER_SAFE
public static final int
DEVICE_OUT_DEFAULT
public static final int
DEVICE_OUT_ALL
public static final int
DEVICE_OUT_ALL_A2DP
public static final int
DEVICE_OUT_ALL_SCO
public static final int
DEVICE_OUT_ALL_USB
public static final int
DEVICE_OUT_ALL_HDMI_SYSTEM_AUDIO
public static final int
DEVICE_ALL_HDMI_SYSTEM_AUDIO_AND_SPEAKER
public static final int
DEVICE_IN_COMMUNICATION
public static final int
DEVICE_IN_AMBIENT
public static final int
DEVICE_IN_BUILTIN_MIC
public static final int
DEVICE_IN_BLUETOOTH_SCO_HEADSET
public static final int
DEVICE_IN_WIRED_HEADSET
public static final int
DEVICE_IN_AUX_DIGITAL
public static final int
DEVICE_IN_HDMI
public static final int
DEVICE_IN_VOICE_CALL
public static final int
DEVICE_IN_TELEPHONY_RX
public static final int
DEVICE_IN_BACK_MIC
public static final int
DEVICE_IN_REMOTE_SUBMIX
public static final int
DEVICE_IN_ANLG_DOCK_HEADSET
public static final int
DEVICE_IN_DGTL_DOCK_HEADSET
public static final int
DEVICE_IN_USB_ACCESSORY
public static final int
DEVICE_IN_USB_DEVICE
public static final int
DEVICE_IN_FM_TUNER
public static final int
DEVICE_IN_TV_TUNER
public static final int
DEVICE_IN_LINE
public static final int
DEVICE_IN_SPDIF
public static final int
DEVICE_IN_BLUETOOTH_A2DP
public static final int
DEVICE_IN_LOOPBACK
public static final int
DEVICE_IN_DEFAULT
public static final int
DEVICE_IN_ALL
public static final int
DEVICE_IN_ALL_SCO
public static final int
DEVICE_IN_ALL_USB
public static final int
DEVICE_STATE_UNAVAILABLE
public static final int
DEVICE_STATE_AVAILABLE
private static final int
NUM_DEVICE_STATES
public static final String
DEVICE_OUT_EARPIECE_NAME
public static final String
DEVICE_OUT_SPEAKER_NAME
public static final String
DEVICE_OUT_WIRED_HEADSET_NAME
public static final String
DEVICE_OUT_WIRED_HEADPHONE_NAME
public static final String
DEVICE_OUT_BLUETOOTH_SCO_NAME
public static final String
DEVICE_OUT_BLUETOOTH_SCO_HEADSET_NAME
public static final String
DEVICE_OUT_BLUETOOTH_SCO_CARKIT_NAME
public static final String
DEVICE_OUT_BLUETOOTH_A2DP_NAME
public static final String
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES_NAME
public static final String
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER_NAME
public static final String
DEVICE_OUT_AUX_DIGITAL_NAME
public static final String
DEVICE_OUT_HDMI_NAME
public static final String
DEVICE_OUT_ANLG_DOCK_HEADSET_NAME
public static final String
DEVICE_OUT_DGTL_DOCK_HEADSET_NAME
public static final String
DEVICE_OUT_USB_ACCESSORY_NAME
public static final String
DEVICE_OUT_USB_DEVICE_NAME
public static final String
DEVICE_OUT_REMOTE_SUBMIX_NAME
public static final String
DEVICE_OUT_TELEPHONY_TX_NAME
public static final String
DEVICE_OUT_LINE_NAME
public static final String
DEVICE_OUT_HDMI_ARC_NAME
public static final String
DEVICE_OUT_SPDIF_NAME
public static final String
DEVICE_OUT_FM_NAME
public static final String
DEVICE_OUT_AUX_LINE_NAME
public static final String
DEVICE_OUT_SPEAKER_SAFE_NAME
public static final String
DEVICE_IN_COMMUNICATION_NAME
public static final String
DEVICE_IN_AMBIENT_NAME
public static final String
DEVICE_IN_BUILTIN_MIC_NAME
public static final String
DEVICE_IN_BLUETOOTH_SCO_HEADSET_NAME
public static final String
DEVICE_IN_WIRED_HEADSET_NAME
public static final String
DEVICE_IN_AUX_DIGITAL_NAME
public static final String
DEVICE_IN_TELEPHONY_RX_NAME
public static final String
DEVICE_IN_BACK_MIC_NAME
public static final String
DEVICE_IN_REMOTE_SUBMIX_NAME
public static final String
DEVICE_IN_ANLG_DOCK_HEADSET_NAME
public static final String
DEVICE_IN_DGTL_DOCK_HEADSET_NAME
public static final String
DEVICE_IN_USB_ACCESSORY_NAME
public static final String
DEVICE_IN_USB_DEVICE_NAME
public static final String
DEVICE_IN_FM_TUNER_NAME
public static final String
DEVICE_IN_TV_TUNER_NAME
public static final String
DEVICE_IN_LINE_NAME
public static final String
DEVICE_IN_SPDIF_NAME
public static final String
DEVICE_IN_BLUETOOTH_A2DP_NAME
public static final String
DEVICE_IN_LOOPBACK_NAME
public static final int
PHONE_STATE_OFFCALL
public static final int
PHONE_STATE_RINGING
public static final int
PHONE_STATE_INCALL
public static final int
FORCE_NONE
public static final int
FORCE_SPEAKER
public static final int
FORCE_HEADPHONES
public static final int
FORCE_BT_SCO
public static final int
FORCE_BT_A2DP
public static final int
FORCE_WIRED_ACCESSORY
public static final int
FORCE_BT_CAR_DOCK
public static final int
FORCE_BT_DESK_DOCK
public static final int
FORCE_ANALOG_DOCK
public static final int
FORCE_DIGITAL_DOCK
public static final int
FORCE_NO_BT_A2DP
public static final int
FORCE_SYSTEM_ENFORCED
public static final int
FORCE_HDMI_SYSTEM_AUDIO_ENFORCED
private static final int
NUM_FORCE_CONFIG
public static final int
FORCE_DEFAULT
public static final int
FOR_COMMUNICATION
public static final int
FOR_MEDIA
public static final int
FOR_RECORD
public static final int
FOR_DOCK
public static final int
FOR_SYSTEM
public static final int
FOR_HDMI_SYSTEM_AUDIO
private static final int
NUM_FORCE_USE
public static final int
SYNC_EVENT_NONE
public static final int
SYNC_EVENT_PRESENTATION_COMPLETE
public static final int
AUDIO_HW_SYNC_INVALID
Constructors Summary
Methods Summary
public static native intcheckAudioFlinger()

public static native intcreateAudioPatch(AudioPatch[] patch, AudioPortConfig[] sources, AudioPortConfig[] sinks)

private static voiderrorCallbackFromNative(int error)

        ErrorCallback errorCallback = null;
        synchronized (AudioSystem.class) {
            if (mErrorCallback != null) {
                errorCallback = mErrorCallback;
            }
        }
        if (errorCallback != null) {
            errorCallback.onError(error);
        }
    
public static native intgetAudioHwSyncForSession(int sessionId)

public static native intgetDeviceConnectionState(int device, java.lang.String device_address)

public static native intgetDevicesForStream(int stream)

public static native intgetForceUse(int usage)

public static java.lang.StringgetInputDeviceName(int device)

        switch(device) {
        case DEVICE_IN_COMMUNICATION:
            return DEVICE_IN_COMMUNICATION_NAME;
        case DEVICE_IN_AMBIENT:
            return DEVICE_IN_AMBIENT_NAME;
        case DEVICE_IN_BUILTIN_MIC:
            return DEVICE_IN_BUILTIN_MIC_NAME;
        case DEVICE_IN_BLUETOOTH_SCO_HEADSET:
            return DEVICE_IN_BLUETOOTH_SCO_HEADSET_NAME;
        case DEVICE_IN_WIRED_HEADSET:
            return DEVICE_IN_WIRED_HEADSET_NAME;
        case DEVICE_IN_AUX_DIGITAL:
            return DEVICE_IN_AUX_DIGITAL_NAME;
        case DEVICE_IN_TELEPHONY_RX:
            return DEVICE_IN_TELEPHONY_RX_NAME;
        case DEVICE_IN_BACK_MIC:
            return DEVICE_IN_BACK_MIC_NAME;
        case DEVICE_IN_REMOTE_SUBMIX:
            return DEVICE_IN_REMOTE_SUBMIX_NAME;
        case DEVICE_IN_ANLG_DOCK_HEADSET:
            return DEVICE_IN_ANLG_DOCK_HEADSET_NAME;
        case DEVICE_IN_DGTL_DOCK_HEADSET:
            return DEVICE_IN_DGTL_DOCK_HEADSET_NAME;
        case DEVICE_IN_USB_ACCESSORY:
            return DEVICE_IN_USB_ACCESSORY_NAME;
        case DEVICE_IN_USB_DEVICE:
            return DEVICE_IN_USB_DEVICE_NAME;
        case DEVICE_IN_FM_TUNER:
            return DEVICE_IN_FM_TUNER_NAME;
        case DEVICE_IN_TV_TUNER:
            return DEVICE_IN_TV_TUNER_NAME;
        case DEVICE_IN_LINE:
            return DEVICE_IN_LINE_NAME;
        case DEVICE_IN_SPDIF:
            return DEVICE_IN_SPDIF_NAME;
        case DEVICE_IN_BLUETOOTH_A2DP:
            return DEVICE_IN_BLUETOOTH_A2DP_NAME;
        case DEVICE_IN_LOOPBACK:
            return DEVICE_IN_LOOPBACK_NAME;
        case DEVICE_IN_DEFAULT:
        default:
            return Integer.toString(device);
        }
    
public static native booleangetMasterMute()

public static native floatgetMasterVolume()

public static final intgetNumStreamTypes()

          return NUM_STREAM_TYPES; 
public static java.lang.StringgetOutputDeviceName(int device)


        
    
        switch(device) {
        case DEVICE_OUT_EARPIECE:
            return DEVICE_OUT_EARPIECE_NAME;
        case DEVICE_OUT_SPEAKER:
            return DEVICE_OUT_SPEAKER_NAME;
        case DEVICE_OUT_WIRED_HEADSET:
            return DEVICE_OUT_WIRED_HEADSET_NAME;
        case DEVICE_OUT_WIRED_HEADPHONE:
            return DEVICE_OUT_WIRED_HEADPHONE_NAME;
        case DEVICE_OUT_BLUETOOTH_SCO:
            return DEVICE_OUT_BLUETOOTH_SCO_NAME;
        case DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
            return DEVICE_OUT_BLUETOOTH_SCO_HEADSET_NAME;
        case DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
            return DEVICE_OUT_BLUETOOTH_SCO_CARKIT_NAME;
        case DEVICE_OUT_BLUETOOTH_A2DP:
            return DEVICE_OUT_BLUETOOTH_A2DP_NAME;
        case DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:
            return DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES_NAME;
        case DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:
            return DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER_NAME;
        case DEVICE_OUT_HDMI:
            return DEVICE_OUT_HDMI_NAME;
        case DEVICE_OUT_ANLG_DOCK_HEADSET:
            return DEVICE_OUT_ANLG_DOCK_HEADSET_NAME;
        case DEVICE_OUT_DGTL_DOCK_HEADSET:
            return DEVICE_OUT_DGTL_DOCK_HEADSET_NAME;
        case DEVICE_OUT_USB_ACCESSORY:
            return DEVICE_OUT_USB_ACCESSORY_NAME;
        case DEVICE_OUT_USB_DEVICE:
            return DEVICE_OUT_USB_DEVICE_NAME;
        case DEVICE_OUT_REMOTE_SUBMIX:
            return DEVICE_OUT_REMOTE_SUBMIX_NAME;
        case DEVICE_OUT_TELEPHONY_TX:
            return DEVICE_OUT_TELEPHONY_TX_NAME;
        case DEVICE_OUT_LINE:
            return DEVICE_OUT_LINE_NAME;
        case DEVICE_OUT_HDMI_ARC:
            return DEVICE_OUT_HDMI_ARC_NAME;
        case DEVICE_OUT_SPDIF:
            return DEVICE_OUT_SPDIF_NAME;
        case DEVICE_OUT_FM:
            return DEVICE_OUT_FM_NAME;
        case DEVICE_OUT_AUX_LINE:
            return DEVICE_OUT_AUX_LINE_NAME;
        case DEVICE_OUT_SPEAKER_SAFE:
            return DEVICE_OUT_SPEAKER_SAFE_NAME;
        case DEVICE_OUT_DEFAULT:
        default:
            return Integer.toString(device);
        }
    
public static native intgetOutputLatency(int stream)

public static native java.lang.StringgetParameters(java.lang.String keys)

public static native intgetPrimaryOutputFrameCount()

public static native intgetPrimaryOutputSamplingRate()

public static native intgetStreamVolumeIndex(int stream, int device)

public static native intinitStreamVolume(int stream, int indexMin, int indexMax)

public static native booleanisMicrophoneMuted()

public static native booleanisSourceActive(int source)

public static native booleanisStreamActive(int stream, int inPastMs)

public static native booleanisStreamActiveRemotely(int stream, int inPastMs)

public static native intlistAudioPatches(java.util.ArrayList patches, int[] generation)

public static native intlistAudioPorts(java.util.ArrayList ports, int[] generation)

public static native intmuteMicrophone(boolean on)

public static native intnewAudioSessionId()

public static native intregisterPolicyMixes(java.util.ArrayList mixes, boolean register)

public static native intreleaseAudioPatch(AudioPatch patch)

public static native intsetAudioPortConfig(AudioPortConfig config)

public static native intsetDeviceConnectionState(int device, int state, java.lang.String device_address)

public static voidsetErrorCallback(android.media.AudioSystem$ErrorCallback cb)


    /*
     * Handles the audio error callback.
     */
      
    
        /*
         * Callback for audio server errors.
         * param error   error code:
         * - AUDIO_STATUS_OK
         * - AUDIO_STATUS_SERVER_DIED
         * - AUDIO_STATUS_ERROR
         */
          
    

    /*
     * Registers a callback to be invoked when an error occurs.
     * @param cb the callback to run
     */
        
    
        synchronized (AudioSystem.class) {
            mErrorCallback = cb;
            if (cb != null) {
                cb.onError(checkAudioFlinger());
            }
        }
    
public static native intsetForceUse(int usage, int config)

public static native intsetLowRamDevice(boolean isLowRamDevice)

public static native intsetMasterMute(boolean mute)

public static native intsetMasterVolume(float value)

public static native intsetParameters(java.lang.String keyValuePairs)

public static native intsetPhoneState(int state)

public static native intsetStreamVolumeIndex(int stream, int index, int device)