Merge "Improve error handling for AudioTrack write with PTS" into mnc-dev

This commit is contained in:
Glenn Kasten
2015-05-29 00:12:53 +00:00
committed by Android (Google) Code Review

View File

@@ -1990,9 +1990,24 @@ public class AudioTrack
* 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().
*/
public int write(ByteBuffer audioData, int sizeInBytes,
public int write(@NonNull ByteBuffer audioData, int sizeInBytes,
@WriteMode int writeMode, long timestamp) {
if (mState == STATE_UNINITIALIZED) {
Log.e(TAG, "AudioTrack.write() called in invalid state STATE_UNINITIALIZED");
return ERROR_INVALID_OPERATION;
}
if ((writeMode != WRITE_BLOCKING) && (writeMode != WRITE_NON_BLOCKING)) {
Log.e(TAG, "AudioTrack.write() called with invalid blocking mode");
return ERROR_BAD_VALUE;
}
if (mDataLoadMode != MODE_STREAM) {
Log.e(TAG, "AudioTrack.write() with timestamp called for non-streaming mode track");
return ERROR_INVALID_OPERATION;
}
if ((mAttributes.getFlags() & AudioAttributes.FLAG_HW_AV_SYNC) == 0) {
Log.d(TAG, "AudioTrack.write() called on a regular AudioTrack. Ignoring pts...");
return write(audioData, sizeInBytes, writeMode);