Class ShadowAudioEffect
- java.lang.Object
-
- org.robolectric.shadows.ShadowAudioEffect
-
- Direct Known Subclasses:
ShadowDynamicsProcessing
@Implements(android.media.audiofx.AudioEffect.class) public class ShadowAudioEffect extends Object
ImplementsAudioEffect
by shadowing its native methods.
-
-
Constructor Summary
Constructors Constructor Description ShadowAudioEffect()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addEffect(AudioEffect.Descriptor descriptor)
Adds an effect represented by anAudioEffect.Descriptor
, only to be queried fromqueryEffects()
.static com.google.common.collect.ImmutableList<AudioEffect>
getAudioEffects()
Returns all effects created with anAudioEffect
constructor.int
getAudioSession()
Returns the audio session set in theAudioEffect
ctor.protected Optional<ByteBuffer>
getDefaultParameter(ByteBuffer parameter)
Allows sub-classes to provide default parameters.int
getPriority()
Returns the priority set in theAudioEffect
ctor.protected boolean
native_getEnabled()
Returns whether theAudioEffect
is enabled (as pernative_setEnabled(boolean)
).protected int
native_getParameter(int psize, byte[] param, int vsize, byte[] value)
Gets the value of the parameter with keyparam
, by putting its value invalue
.protected void
native_release()
Removes this audio effect from the set of active audio effects.protected int
native_setEnabled(boolean enabled)
Marks theAudioEffect
as enabled, and always returnsSUCCESS
.protected int
native_setParameter(int psize, byte[] param, int vsize, byte[] value)
Sets the parameter with the given keyparam
to the given valuevalue
.protected int
native_setup(Object audioEffectThis, String type, String uuid, int priority, int audioSession, int[] id, Object[] desc)
protected int
native_setup(Object audioEffectThis, String type, String uuid, int priority, int audioSession, int[] id, Object[] desc, String opPackageName)
protected static AudioEffect.Descriptor[]
queryEffects()
Returns the set of audio effects added throughaddEffect(android.media.audiofx.AudioEffect.Descriptor)
.static void
reset()
void
setErrorCode(int errorCode)
Sets the error code to override setter methods in this class.void
setInitialized(boolean initialized)
Updates the state of theAudioEffect
itself.
-
-
-
Method Detail
-
native_setup
@Implementation(minSdk=16, maxSdk=22) protected int native_setup(Object audioEffectThis, String type, String uuid, int priority, int audioSession, int[] id, Object[] desc)
-
native_setup
@Implementation(minSdk=23, maxSdk=29) protected int native_setup(Object audioEffectThis, String type, String uuid, int priority, int audioSession, int[] id, Object[] desc, String opPackageName)
-
native_setEnabled
@Implementation protected int native_setEnabled(boolean enabled)
Marks theAudioEffect
as enabled, and always returnsSUCCESS
.
-
native_getEnabled
@Implementation protected boolean native_getEnabled()
Returns whether theAudioEffect
is enabled (as pernative_setEnabled(boolean)
).
-
native_setParameter
@Implementation protected int native_setParameter(int psize, byte[] param, int vsize, byte[] value)
Sets the parameter with the given keyparam
to the given valuevalue
.- Returns:
- always
SUCCESS
-
native_getParameter
@Implementation protected int native_getParameter(int psize, byte[] param, int vsize, byte[] value)
Gets the value of the parameter with keyparam
, by putting its value invalue
.Note: Sub-classes of
ShadowAudioEffect
can declare default values for any parameters. Note: If the given parameter has not been set, and there is no default value for that parameter, then we "return" (setvalue
to) a single integer 0.- Returns:
- the size of the returned value, in bytes, or an error code in case of failure.
-
getDefaultParameter
protected Optional<ByteBuffer> getDefaultParameter(ByteBuffer parameter)
Allows sub-classes to provide default parameters.Override this method to provide default parameters.
-
getPriority
public int getPriority()
Returns the priority set in theAudioEffect
ctor.
-
getAudioSession
public int getAudioSession()
Returns the audio session set in theAudioEffect
ctor.
-
setInitialized
public void setInitialized(boolean initialized)
Updates the state of theAudioEffect
itself.This can be used e.g. to put the AudioEffect in an unexpected state and cause an exception the next time the Visualizer is used.
-
setErrorCode
public void setErrorCode(int errorCode)
Sets the error code to override setter methods in this class.When the error code is set to anything other than
SUCCESS
setters in the AudioEffect will early-out and return that error code.
-
addEffect
public static void addEffect(AudioEffect.Descriptor descriptor)
Adds an effect represented by anAudioEffect.Descriptor
, only to be queried fromqueryEffects()
.
-
queryEffects
@Implementation protected static AudioEffect.Descriptor[] queryEffects()
Returns the set of audio effects added throughaddEffect(android.media.audiofx.AudioEffect.Descriptor)
.Note: in the original
AudioEffect
implementation this method returns all the existing unique AudioEffects created through anAudioEffect
ctor. In this implementation only the effects added throughaddEffect(android.media.audiofx.AudioEffect.Descriptor)
are returned here.
-
getAudioEffects
public static com.google.common.collect.ImmutableList<AudioEffect> getAudioEffects()
Returns all effects created with anAudioEffect
constructor.
-
native_release
@Implementation protected void native_release()
Removes this audio effect from the set of active audio effects.
-
reset
@Resetter public static void reset()
-
-