@Implements(value=android.media.AudioTrack.class, looseSignatures=true) public class ShadowAudioTrack extends Object
AudioTrack
. Only a couple methods are supported,
other methods are expected run through the real class. The two AudioTrack.WriteMode
are treated the
same.Modifier and Type | Field | Description |
---|---|---|
protected static int |
DEFAULT_MIN_BUFFER_SIZE |
Constructor | Description |
---|---|
ShadowAudioTrack() |
Modifier and Type | Method | Description |
---|---|---|
protected static int |
native_get_min_buff_size(int sampleRateInHz,
int channelConfig,
int audioFormat) |
Returns a predefined or default minimum buffer size.
|
protected int |
native_write_byte(byte[] audioData,
int offsetInBytes,
int sizeInBytes,
int format,
boolean isBlocking) |
Always return the number of bytes to write.
|
static void |
setMinBufferSize(int bufferSize) |
In the real class, the minimum buffer size is estimated from audio sample rate and other
factors.
|
protected int |
write(ByteBuffer audioData,
int sizeInBytes,
int writeMode) |
Always return the number of bytes to write except with invalid parameters.
|
protected static final int DEFAULT_MIN_BUFFER_SIZE
public static void setMinBufferSize(int bufferSize)
native_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.@Implementation protected static int native_get_min_buff_size(int sampleRateInHz, int channelConfig, int audioFormat)
@Implementation(minSdk=23) protected final int native_write_byte(byte[] audioData, int offsetInBytes, int sizeInBytes, int format, boolean isBlocking)
AudioTrack.WRITE_BLOCKING
@Implementation(minSdk=21) protected int write(@NonNull ByteBuffer audioData, int sizeInBytes, int writeMode)
AudioTrack.WRITE_BLOCKING