Package org.robolectric.shadows
Class ShadowAudioTrack
- java.lang.Object
-
- org.robolectric.shadows.ShadowAudioTrack
-
@Implements(value=android.media.AudioTrack.class, looseSignatures=true) public class ShadowAudioTrack extends java.lang.ObjectImplementation of a couple methods inAudioTrack. Only a couple methods are supported, other methods are expected run through the real class. The twoAudioTrack.WriteModeare treated the same.
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_MIN_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description ShadowAudioTrack()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static intnative_get_min_buff_size(int sampleRateInHz, int channelConfig, int audioFormat)Returns a predefined or default minimum buffer size.protected intnative_write_byte(byte[] audioData, int offsetInBytes, int sizeInBytes, int format, boolean isBlocking)Always return the number of bytes to write.static voidsetMinBufferSize(int bufferSize)In the real class, the minimum buffer size is estimated from audio sample rate and other factors.protected intwrite(java.nio.ByteBuffer audioData, int sizeInBytes, int writeMode)Always return the number of bytes to write except with invalid parameters.
-
-
-
Field Detail
-
DEFAULT_MIN_BUFFER_SIZE
protected static final int DEFAULT_MIN_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setMinBufferSize
public static void setMinBufferSize(int bufferSize)
In the real class, the minimum buffer size is estimated from audio sample rate and other factors. We do not provide such estimation innative_get_min_buff_size(int, int, int), instead letting users set the minimum for the expected audio sample. Usually higher sample rate requires bigger buffer size.
-
native_get_min_buff_size
@Implementation protected static int native_get_min_buff_size(int sampleRateInHz, int channelConfig, int audioFormat)Returns a predefined or default minimum buffer size. Audio format and config are neglected.
-
native_write_byte
@Implementation(minSdk=23) protected final int native_write_byte(byte[] audioData, int offsetInBytes, int sizeInBytes, int format, boolean isBlocking)Always return the number of bytes to write. This method returns immedidately even withAudioTrack.WRITE_BLOCKING
-
write
@Implementation(minSdk=21) protected int write(@NonNull java.nio.ByteBuffer audioData, int sizeInBytes, int writeMode)Always return the number of bytes to write except with invalid parameters. Assumes AudioTrack is already initialized (object properly created). Do not block even if AudioTrack in offload mode is in STOPPING play state. This method returns immediately even withAudioTrack.WRITE_BLOCKING
-
-