public class AudioPolicy extends Object
Modifier and Type | Class and Description |
---|---|
static class |
AudioPolicy.AudioPolicyFocusListener |
static class |
AudioPolicy.AudioPolicyStatusListener |
static class |
AudioPolicy.Builder
Builder class for
AudioPolicy objects |
static interface |
AudioPolicy.PolicyStatus |
Modifier and Type | Field and Description |
---|---|
static int |
FOCUS_POLICY_DUCKING_DEFAULT |
static int |
FOCUS_POLICY_DUCKING_IN_APP
The behavior of a policy with regards to audio focus where it relies on the application
to do the ducking, the is the legacy and default behavior.
|
static int |
FOCUS_POLICY_DUCKING_IN_POLICY
The behavior of a policy with regards to audio focus where it handles ducking instead
of the application losing focus and being signaled it can duck (as communicated by
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK ). |
static int |
POLICY_STATUS_REGISTERED
The status of an audio policy that is valid, successfully registered and thus active.
|
static int |
POLICY_STATUS_UNREGISTERED
The status of an audio policy that is valid but cannot be used because it is not registered.
|
Modifier and Type | Method and Description |
---|---|
IAudioPolicyCallback |
cb() |
AudioRecord |
createAudioRecordSink(AudioMix mix)
Create an
AudioRecord instance that is associated with the given AudioMix . |
AudioTrack |
createAudioTrackSource(AudioMix mix)
Create an
AudioTrack instance that is associated with the given AudioMix . |
AudioPolicyConfig |
getConfig() |
int |
getFocusDuckingBehavior()
Returns the current behavior for audio focus-related ducking.
|
int |
getStatus() |
boolean |
hasFocusListener() |
int |
setFocusDuckingBehavior(int behavior)
Sets the behavior for audio focus-related ducking.
|
void |
setRegistration(String regId) |
String |
toLogFriendlyString() |
public static final int POLICY_STATUS_UNREGISTERED
public static final int POLICY_STATUS_REGISTERED
public static final int FOCUS_POLICY_DUCKING_IN_APP
public static final int FOCUS_POLICY_DUCKING_DEFAULT
public static final int FOCUS_POLICY_DUCKING_IN_POLICY
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK
).
AudioPolicy#setAudioPolicyFocusListener(AudioPolicyFocusListener)
.public AudioPolicyConfig getConfig()
public boolean hasFocusListener()
public void setRegistration(String regId)
public int getFocusDuckingBehavior()
public int setFocusDuckingBehavior(int behavior) throws IllegalArgumentException, IllegalStateException
behavior
- FOCUS_POLICY_DUCKING_IN_APP
or
FOCUS_POLICY_DUCKING_IN_POLICY
AudioManager.SUCCESS
or AudioManager.ERROR
(for instance if there
is already an audio policy that handles ducking).IllegalArgumentException
IllegalStateException
public AudioRecord createAudioRecordSink(AudioMix mix) throws IllegalArgumentException
AudioRecord
instance that is associated with the given AudioMix
.
Audio buffers recorded through the created instance will contain the mix of the audio
streams that fed the given mixer.mix
- a non-null AudioMix
instance whose routing flags was defined with
AudioMix.ROUTE_FLAG_LOOP_BACK
, previously added to this policy.AudioRecord
instance whose data format is the one defined in the
AudioMix
, or null if this policy was not successfully registered
with AudioManager.registerAudioPolicy(AudioPolicy)
.IllegalArgumentException
public AudioTrack createAudioTrackSource(AudioMix mix) throws IllegalArgumentException
AudioTrack
instance that is associated with the given AudioMix
.
Audio buffers played through the created instance will be sent to the given mix
to be recorded through the recording APIs.mix
- a non-null AudioMix
instance whose routing flags was defined with
AudioMix.ROUTE_FLAG_LOOP_BACK
, previously added to this policy.AudioTrack
instance whose data format is the one defined in the
AudioMix
, or null if this policy was not successfully registered
with AudioManager.registerAudioPolicy(AudioPolicy)
.IllegalArgumentException
public int getStatus()
public IAudioPolicyCallback cb()
public String toLogFriendlyString()