Merge "Fix AudioTrack and AudioRecord documentation" into nyc-dev
am: b143e3de34
* commit 'b143e3de34ab98463a641fd6d67165fce878f1ff':
Fix AudioTrack and AudioRecord documentation
Change-Id: I861c0047b33730465c3ceeae1c4072f17b29d804
This commit is contained in:
@@ -19877,6 +19877,7 @@ package android.media {
|
||||
method public void stop() throws java.lang.IllegalStateException;
|
||||
field public static final int ERROR = -1; // 0xffffffff
|
||||
field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
|
||||
field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
|
||||
field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
|
||||
field public static final int READ_BLOCKING = 0; // 0x0
|
||||
field public static final int READ_NON_BLOCKING = 1; // 0x1
|
||||
@@ -19999,6 +20000,7 @@ package android.media {
|
||||
method public int write(java.nio.ByteBuffer, int, int, long);
|
||||
field public static final int ERROR = -1; // 0xffffffff
|
||||
field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
|
||||
field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
|
||||
field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
|
||||
field public static final int MODE_STATIC = 0; // 0x0
|
||||
field public static final int MODE_STREAM = 1; // 0x1
|
||||
|
||||
@@ -21393,6 +21393,7 @@ package android.media {
|
||||
method public void stop() throws java.lang.IllegalStateException;
|
||||
field public static final int ERROR = -1; // 0xffffffff
|
||||
field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
|
||||
field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
|
||||
field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
|
||||
field public static final int READ_BLOCKING = 0; // 0x0
|
||||
field public static final int READ_NON_BLOCKING = 1; // 0x1
|
||||
@@ -21517,6 +21518,7 @@ package android.media {
|
||||
method public int write(java.nio.ByteBuffer, int, int, long);
|
||||
field public static final int ERROR = -1; // 0xffffffff
|
||||
field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
|
||||
field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
|
||||
field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
|
||||
field public static final int MODE_STATIC = 0; // 0x0
|
||||
field public static final int MODE_STREAM = 1; // 0x1
|
||||
|
||||
@@ -19947,6 +19947,7 @@ package android.media {
|
||||
method public void stop() throws java.lang.IllegalStateException;
|
||||
field public static final int ERROR = -1; // 0xffffffff
|
||||
field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
|
||||
field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
|
||||
field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
|
||||
field public static final int READ_BLOCKING = 0; // 0x0
|
||||
field public static final int READ_NON_BLOCKING = 1; // 0x1
|
||||
@@ -20069,6 +20070,7 @@ package android.media {
|
||||
method public int write(java.nio.ByteBuffer, int, int, long);
|
||||
field public static final int ERROR = -1; // 0xffffffff
|
||||
field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
|
||||
field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
|
||||
field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
|
||||
field public static final int MODE_STATIC = 0; // 0x0
|
||||
field public static final int MODE_STREAM = 1; // 0x1
|
||||
|
||||
@@ -479,17 +479,13 @@ void envReleaseArrayElements(JNIEnv *env, jfloatArray array, jfloat *elems, jint
|
||||
|
||||
static inline
|
||||
jint interpretReadSizeError(ssize_t readSize) {
|
||||
ALOGE_IF(readSize != WOULD_BLOCK, "Error %zd during AudioRecord native read", readSize);
|
||||
switch (readSize) {
|
||||
case WOULD_BLOCK:
|
||||
if (readSize == WOULD_BLOCK) {
|
||||
return (jint)0;
|
||||
case BAD_VALUE:
|
||||
return (jint)AUDIO_JAVA_BAD_VALUE;
|
||||
default:
|
||||
// may be possible for other errors such as
|
||||
// NO_INIT to happen if restoreRecord_l fails.
|
||||
case INVALID_OPERATION:
|
||||
return (jint)AUDIO_JAVA_INVALID_OPERATION;
|
||||
} else if (readSize == NO_INIT) {
|
||||
return AUDIO_JAVA_DEAD_OBJECT;
|
||||
} else {
|
||||
ALOGE("Error %zd during AudioRecord native read", readSize);
|
||||
return nativeToJavaStatus(readSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -606,6 +606,18 @@ void envReleaseArrayElements(JNIEnv *env, jfloatArray array, jfloat *elems, jint
|
||||
env->ReleaseFloatArrayElements(array, elems, mode);
|
||||
}
|
||||
|
||||
static inline
|
||||
jint interpretWriteSizeError(ssize_t writeSize) {
|
||||
if (writeSize == WOULD_BLOCK) {
|
||||
return (jint)0;
|
||||
} else if (writeSize == NO_INIT) {
|
||||
return AUDIO_JAVA_DEAD_OBJECT;
|
||||
} else {
|
||||
ALOGE("Error %zd during AudioTrack native read", writeSize);
|
||||
return nativeToJavaStatus(writeSize);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
static jint writeToTrack(const sp<AudioTrack>& track, jint audioFormat, const T *data,
|
||||
@@ -628,11 +640,10 @@ static jint writeToTrack(const sp<AudioTrack>& track, jint audioFormat, const T
|
||||
memcpy(track->sharedBuffer()->pointer(), data + offsetInSamples, sizeInBytes);
|
||||
written = sizeInBytes;
|
||||
}
|
||||
if (written > 0) {
|
||||
if (written >= 0) {
|
||||
return written / sizeof(T);
|
||||
}
|
||||
// for compatibility, error codes pass through unchanged
|
||||
return written;
|
||||
return interpretWriteSizeError(written);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -94,6 +94,11 @@ public class AudioRecord implements AudioRouting
|
||||
* Denotes a failure due to the improper use of a method.
|
||||
*/
|
||||
public static final int ERROR_INVALID_OPERATION = AudioSystem.INVALID_OPERATION;
|
||||
/**
|
||||
* An error code indicating that the object reporting it is no longer valid and needs to
|
||||
* be recreated.
|
||||
*/
|
||||
public static final int ERROR_DEAD_OBJECT = AudioSystem.DEAD_OBJECT;
|
||||
|
||||
// Error codes:
|
||||
// to keep in sync with frameworks/base/core/jni/android_media_AudioRecord.cpp
|
||||
@@ -1046,10 +1051,16 @@ public class AudioRecord implements AudioRouting
|
||||
* @param audioData the array to which the recorded audio data is written.
|
||||
* @param offsetInBytes index in audioData from which the data is written expressed in bytes.
|
||||
* @param sizeInBytes the number of requested bytes.
|
||||
* @return the number of bytes that were read or {@link #ERROR_INVALID_OPERATION}
|
||||
* if the object wasn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes.
|
||||
* The number of bytes will not exceed sizeInBytes.
|
||||
* @return zero or the positive number of bytes that were read, or one of the following
|
||||
* error codes. The number of bytes will not exceed sizeInBytes.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the object isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the object is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next read()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int read(@NonNull byte[] audioData, int offsetInBytes, int sizeInBytes) {
|
||||
return read(audioData, offsetInBytes, sizeInBytes, READ_BLOCKING);
|
||||
@@ -1070,11 +1081,17 @@ public class AudioRecord implements AudioRouting
|
||||
* is read.
|
||||
* <br>With {@link #READ_NON_BLOCKING}, the read will return immediately after
|
||||
* reading as much audio data as possible without blocking.
|
||||
* @return the number of bytes that were read or {@link #ERROR_INVALID_OPERATION}
|
||||
* if the object wasn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes.
|
||||
* The number of bytes will be a multiple of the frame size in bytes
|
||||
* @return zero or the positive number of bytes that were read, or one of the following
|
||||
* error codes. The number of bytes will be a multiple of the frame size in bytes
|
||||
* not to exceed sizeInBytes.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the object isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the object is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next read()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int read(@NonNull byte[] audioData, int offsetInBytes, int sizeInBytes,
|
||||
@ReadMode int readMode) {
|
||||
@@ -1106,10 +1123,17 @@ public class AudioRecord implements AudioRouting
|
||||
* Must not be negative, or cause the data access to go out of bounds of the array.
|
||||
* @param sizeInShorts the number of requested shorts.
|
||||
* Must not be negative, or cause the data access to go out of bounds of the array.
|
||||
* @return the number of shorts that were read or {@link #ERROR_INVALID_OPERATION}
|
||||
* if the object wasn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes.
|
||||
* The number of shorts will be a multiple of the channel count not to exceed sizeInShorts.
|
||||
* @return zero or the positive number of shorts that were read, or one of the following
|
||||
* error codes. The number of shorts will be a multiple of the channel count not to exceed
|
||||
* sizeInShorts.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the object isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the object is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next read()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int read(@NonNull short[] audioData, int offsetInShorts, int sizeInShorts) {
|
||||
return read(audioData, offsetInShorts, sizeInShorts, READ_BLOCKING);
|
||||
@@ -1129,10 +1153,17 @@ public class AudioRecord implements AudioRouting
|
||||
* is read.
|
||||
* <br>With {@link #READ_NON_BLOCKING}, the read will return immediately after
|
||||
* reading as much audio data as possible without blocking.
|
||||
* @return the number of shorts that were read or {@link #ERROR_INVALID_OPERATION}
|
||||
* if the object wasn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes.
|
||||
* The number of shorts will be a multiple of the channel count not to exceed sizeInShorts.
|
||||
* @return zero or the positive number of shorts that were read, or one of the following
|
||||
* error codes. The number of shorts will be a multiple of the channel count not to exceed
|
||||
* sizeInShorts.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the object isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the object is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next read()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int read(@NonNull short[] audioData, int offsetInShorts, int sizeInShorts,
|
||||
@ReadMode int readMode) {
|
||||
@@ -1169,10 +1200,17 @@ public class AudioRecord implements AudioRouting
|
||||
* is read.
|
||||
* <br>With {@link #READ_NON_BLOCKING}, the read will return immediately after
|
||||
* reading as much audio data as possible without blocking.
|
||||
* @return the number of floats that were read or {@link #ERROR_INVALID_OPERATION}
|
||||
* if the object wasn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes.
|
||||
* The number of floats will be a multiple of the channel count not to exceed sizeInFloats.
|
||||
* @return zero or the positive number of floats that were read, or one of the following
|
||||
* error codes. The number of floats will be a multiple of the channel count not to exceed
|
||||
* sizeInFloats.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the object isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the object is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next read()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int read(@NonNull float[] audioData, int offsetInFloats, int sizeInFloats,
|
||||
@ReadMode int readMode) {
|
||||
@@ -1213,11 +1251,17 @@ public class AudioRecord implements AudioRouting
|
||||
* @param sizeInBytes the number of requested bytes. It is recommended but not enforced
|
||||
* that the number of bytes requested be a multiple of the frame size (sample size in
|
||||
* bytes multiplied by the channel count).
|
||||
* @return the number of bytes that were read or {@link #ERROR_INVALID_OPERATION}
|
||||
* if the object wasn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes.
|
||||
* The number of bytes will not exceed sizeInBytes.
|
||||
* The number of bytes read will be truncated to be a multiple of the frame size.
|
||||
* @return zero or the positive number of bytes that were read, or one of the following
|
||||
* error codes. The number of bytes will not exceed sizeInBytes and will be truncated to be
|
||||
* a multiple of the frame size.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the object isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the object is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next read()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int read(@NonNull ByteBuffer audioBuffer, int sizeInBytes) {
|
||||
return read(audioBuffer, sizeInBytes, READ_BLOCKING);
|
||||
@@ -1240,11 +1284,17 @@ public class AudioRecord implements AudioRouting
|
||||
* is read.
|
||||
* <br>With {@link #READ_NON_BLOCKING}, the read will return immediately after
|
||||
* reading as much audio data as possible without blocking.
|
||||
* @return the number of bytes that were read or {@link #ERROR_INVALID_OPERATION}
|
||||
* if the object wasn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes.
|
||||
* The number of bytes will not exceed sizeInBytes.
|
||||
* The number of bytes read will be truncated to be a multiple of the frame size.
|
||||
* @return zero or the positive number of bytes that were read, or one of the following
|
||||
* error codes. The number of bytes will not exceed sizeInBytes and will be truncated to be
|
||||
* a multiple of the frame size.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the object isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the object is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next read()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int read(@NonNull ByteBuffer audioBuffer, int sizeInBytes, @ReadMode int readMode) {
|
||||
if (mState != STATE_INITIALIZED) {
|
||||
|
||||
@@ -156,7 +156,6 @@ public class AudioTrack extends PlayerBase
|
||||
/**
|
||||
* An error code indicating that the object reporting it is no longer valid and needs to
|
||||
* be recreated.
|
||||
* @hide
|
||||
*/
|
||||
public static final int ERROR_DEAD_OBJECT = AudioSystem.DEAD_OBJECT;
|
||||
/**
|
||||
@@ -1840,17 +1839,17 @@ public class AudioTrack extends PlayerBase
|
||||
* Must not be negative, or cause the data access to go out of bounds of the array.
|
||||
* @param sizeInBytes the number of bytes to write in audioData after the offset.
|
||||
* Must not be negative, or cause the data access to go out of bounds of the array.
|
||||
* @return zero or the positive number of bytes that were written, or
|
||||
* {@link #ERROR_INVALID_OPERATION}
|
||||
* if the track isn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes, or
|
||||
* {@link AudioManager#ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated.
|
||||
* The dead object error code is not returned if some data was successfully transferred.
|
||||
* In this case, the error is returned at the next write().
|
||||
* The number of bytes will be a multiple of the frame size in bytes
|
||||
* @return zero or the positive number of bytes that were written, or one of the following
|
||||
* error codes. The number of bytes will be a multiple of the frame size in bytes
|
||||
* not to exceed sizeInBytes.
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the track isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next write()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
* This is equivalent to {@link #write(byte[], int, int, int)} with <code>writeMode</code>
|
||||
* set to {@link #WRITE_BLOCKING}.
|
||||
*/
|
||||
@@ -1888,16 +1887,17 @@ public class AudioTrack extends PlayerBase
|
||||
* to the audio sink.
|
||||
* <br>With {@link #WRITE_NON_BLOCKING}, the write will return immediately after
|
||||
* queuing as much audio data for playback as possible without blocking.
|
||||
* @return zero or the positive number of bytes that were written, or
|
||||
* {@link #ERROR_INVALID_OPERATION}
|
||||
* if the track isn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes, or
|
||||
* {@link AudioManager#ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated.
|
||||
* The dead object error code is not returned if some data was successfully transferred.
|
||||
* In this case, the error is returned at the next write().
|
||||
* The number of bytes will be a multiple of the frame size in bytes
|
||||
* @return zero or the positive number of bytes that were written, or one of the following
|
||||
* error codes. The number of bytes will be a multiple of the frame size in bytes
|
||||
* not to exceed sizeInBytes.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the track isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next write()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int write(@NonNull byte[] audioData, int offsetInBytes, int sizeInBytes,
|
||||
@WriteMode int writeMode) {
|
||||
@@ -1950,16 +1950,17 @@ public class AudioTrack extends PlayerBase
|
||||
* Must not be negative, or cause the data access to go out of bounds of the array.
|
||||
* @param sizeInShorts the number of shorts to read in audioData after the offset.
|
||||
* Must not be negative, or cause the data access to go out of bounds of the array.
|
||||
* @return zero or the positive number of shorts that were written, or
|
||||
* {@link #ERROR_INVALID_OPERATION}
|
||||
* if the track isn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes, or
|
||||
* {@link AudioManager#ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated.
|
||||
* The dead object error code is not returned if some data was successfully transferred.
|
||||
* In this case, the error is returned at the next write().
|
||||
* The number of shorts will be a multiple of the channel count not to exceed sizeInShorts.
|
||||
*
|
||||
* @return zero or the positive number of shorts that were written, or one of the following
|
||||
* error codes. The number of shorts will be a multiple of the channel count not to
|
||||
* exceed sizeInShorts.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the track isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next write()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
* This is equivalent to {@link #write(short[], int, int, int)} with <code>writeMode</code>
|
||||
* set to {@link #WRITE_BLOCKING}.
|
||||
*/
|
||||
@@ -1995,15 +1996,17 @@ public class AudioTrack extends PlayerBase
|
||||
* to the audio sink.
|
||||
* <br>With {@link #WRITE_NON_BLOCKING}, the write will return immediately after
|
||||
* queuing as much audio data for playback as possible without blocking.
|
||||
* @return zero or the positive number of shorts that were written, or
|
||||
* {@link #ERROR_INVALID_OPERATION}
|
||||
* if the track isn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes, or
|
||||
* {@link AudioManager#ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated.
|
||||
* The dead object error code is not returned if some data was successfully transferred.
|
||||
* In this case, the error is returned at the next write().
|
||||
* The number of shorts will be a multiple of the channel count not to exceed sizeInShorts.
|
||||
* @return zero or the positive number of shorts that were written, or one of the following
|
||||
* error codes. The number of shorts will be a multiple of the channel count not to
|
||||
* exceed sizeInShorts.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the track isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next write()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int write(@NonNull short[] audioData, int offsetInShorts, int sizeInShorts,
|
||||
@WriteMode int writeMode) {
|
||||
@@ -2074,15 +2077,17 @@ public class AudioTrack extends PlayerBase
|
||||
* to the audio sink.
|
||||
* <br>With {@link #WRITE_NON_BLOCKING}, the write will return immediately after
|
||||
* queuing as much audio data for playback as possible without blocking.
|
||||
* @return zero or the positive number of floats that were written, or
|
||||
* {@link #ERROR_INVALID_OPERATION}
|
||||
* if the track isn't properly initialized, or {@link #ERROR_BAD_VALUE} if
|
||||
* the parameters don't resolve to valid data and indexes, or
|
||||
* {@link AudioManager#ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated.
|
||||
* The dead object error code is not returned if some data was successfully transferred.
|
||||
* In this case, the error is returned at the next write().
|
||||
* The number of floats will be a multiple of the channel count not to exceed sizeInFloats.
|
||||
* @return zero or the positive number of floats that were written, or one of the following
|
||||
* error codes. The number of floats will be a multiple of the channel count not to
|
||||
* exceed sizeInFloats.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the track isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next write()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int write(@NonNull float[] audioData, int offsetInFloats, int sizeInFloats,
|
||||
@WriteMode int writeMode) {
|
||||
@@ -2154,12 +2159,16 @@ public class AudioTrack extends PlayerBase
|
||||
* to the audio sink.
|
||||
* <BR>With {@link #WRITE_NON_BLOCKING}, the write will return immediately after
|
||||
* queuing as much audio data for playback as possible without blocking.
|
||||
* @return zero or the positive number of bytes that were written, or
|
||||
* {@link #ERROR_BAD_VALUE}, {@link #ERROR_INVALID_OPERATION}, or
|
||||
* {@link AudioManager#ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated.
|
||||
* The dead object error code is not returned if some data was successfully transferred.
|
||||
* In this case, the error is returned at the next write().
|
||||
* @return zero or the positive number of bytes that were written, or one of the following
|
||||
* error codes.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the track isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next write()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int write(@NonNull ByteBuffer audioData, int sizeInBytes,
|
||||
@WriteMode int writeMode) {
|
||||
@@ -2223,12 +2232,16 @@ public class AudioTrack extends PlayerBase
|
||||
* <BR>With {@link #WRITE_NON_BLOCKING}, the write will return immediately after
|
||||
* queuing as much audio data for playback as possible without blocking.
|
||||
* @param timestamp The timestamp of the first decodable audio frame in the provided audioData.
|
||||
* @return zero or a positive number of bytes that were written, or
|
||||
* {@link #ERROR_BAD_VALUE}, {@link #ERROR_INVALID_OPERATION}, or
|
||||
* {@link AudioManager#ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated.
|
||||
* The dead object error code is not returned if some data was successfully transferred.
|
||||
* In this case, the error is returned at the next write().
|
||||
* @return zero or the positive number of bytes that were written, or one of the following
|
||||
* error codes.
|
||||
* <ul>
|
||||
* <li>{@link #ERROR_INVALID_OPERATION} if the track isn't properly initialized</li>
|
||||
* <li>{@link #ERROR_BAD_VALUE} if the parameters don't resolve to valid data and indexes</li>
|
||||
* <li>{@link #ERROR_DEAD_OBJECT} if the AudioTrack is not valid anymore and
|
||||
* needs to be recreated. The dead object error code is not returned if some data was
|
||||
* successfully transferred. In this case, the error is returned at the next write()</li>
|
||||
* <li>{@link #ERROR} in case of other error</li>
|
||||
* </ul>
|
||||
*/
|
||||
public int write(@NonNull ByteBuffer audioData, int sizeInBytes,
|
||||
@WriteMode int writeMode, long timestamp) {
|
||||
|
||||
Reference in New Issue
Block a user