Fix some documentation nits in AudioTrack.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145554504
This commit is contained in:
andrewlewis 2017-01-25 09:00:50 -08:00 committed by Oliver Woodman
parent e9ab71a280
commit 98db14e7e5

View File

@ -54,7 +54,9 @@ import java.nio.ByteOrder;
* safe to call {@link #handleBuffer(ByteBuffer, long)} after {@link #reset()} without calling * safe to call {@link #handleBuffer(ByteBuffer, long)} after {@link #reset()} without calling
* {@link #configure(String, int, int, int, int)}. * {@link #configure(String, int, int, int, int)}.
* <p> * <p>
* Call {@link #release()} when the instance is no longer required. * Call {@link #handleEndOfStream()} to play out all data when no more input buffers will be
* provided via {@link #handleBuffer(ByteBuffer, long)} until the next {@link #reset}. Call
* {@link #release()} when the instance is no longer required.
*/ */
public final class AudioTrack { public final class AudioTrack {
@ -120,13 +122,15 @@ public final class AudioTrack {
public static final class WriteException extends Exception { public static final class WriteException extends Exception {
/** /**
* An error value returned from {@link android.media.AudioTrack#write(byte[], int, int)}. * The error value returned from {@link android.media.AudioTrack#write(byte[], int, int)} or
* {@link android.media.AudioTrack#write(ByteBuffer, int, int)}.
*/ */
public final int errorCode; public final int errorCode;
/** /**
* @param errorCode An error value returned from * @param errorCode The error value returned from
* {@link android.media.AudioTrack#write(byte[], int, int)}. * {@link android.media.AudioTrack#write(byte[], int, int)} or
* {@link android.media.AudioTrack#write(ByteBuffer, int, int)}.
*/ */
public WriteException(int errorCode) { public WriteException(int errorCode) {
super("AudioTrack write failed: " + errorCode); super("AudioTrack write failed: " + errorCode);
@ -212,15 +216,15 @@ public final class AudioTrack {
/** /**
* AudioTrack timestamps are deemed spurious if they are offset from the system clock by more * AudioTrack timestamps are deemed spurious if they are offset from the system clock by more
* than this amount. * than this amount.
* * <p>
* <p>This is a fail safe that should not be required on correctly functioning devices. * This is a fail safe that should not be required on correctly functioning devices.
*/ */
private static final long MAX_AUDIO_TIMESTAMP_OFFSET_US = 5 * C.MICROS_PER_SECOND; private static final long MAX_AUDIO_TIMESTAMP_OFFSET_US = 5 * C.MICROS_PER_SECOND;
/** /**
* AudioTrack latencies are deemed impossibly large if they are greater than this amount. * AudioTrack latencies are deemed impossibly large if they are greater than this amount.
* * <p>
* <p>This is a fail safe that should not be required on correctly functioning devices. * This is a fail safe that should not be required on correctly functioning devices.
*/ */
private static final long MAX_LATENCY_US = 5 * C.MICROS_PER_SECOND; private static final long MAX_LATENCY_US = 5 * C.MICROS_PER_SECOND;
@ -386,7 +390,7 @@ public final class AudioTrack {
// The AudioTrack has started, but we don't have any samples to compute a smoothed position. // The AudioTrack has started, but we don't have any samples to compute a smoothed position.
currentPositionUs = audioTrackUtil.getPlaybackHeadPositionUs() + startMediaTimeUs; currentPositionUs = audioTrackUtil.getPlaybackHeadPositionUs() + startMediaTimeUs;
} else { } else {
// getPlayheadPositionUs() only has a granularity of ~20ms, so we base the position off the // getPlayheadPositionUs() only has a granularity of ~20 ms, so we base the position off the
// system clock (and a smoothed offset between it and the playhead position) so as to // system clock (and a smoothed offset between it and the playhead position) so as to
// prevent jitter in the reported positions. // prevent jitter in the reported positions.
currentPositionUs = systemClockUs + smoothedPlayheadOffsetUs + startMediaTimeUs; currentPositionUs = systemClockUs + smoothedPlayheadOffsetUs + startMediaTimeUs;
@ -627,6 +631,7 @@ public final class AudioTrack {
return result; return result;
} }
@SuppressWarnings("ReferenceEquality")
private boolean writeBuffer(ByteBuffer buffer, long presentationTimeUs) throws WriteException { private boolean writeBuffer(ByteBuffer buffer, long presentationTimeUs) throws WriteException {
boolean isNewSourceBuffer = currentSourceBuffer == null; boolean isNewSourceBuffer = currentSourceBuffer == null;
Assertions.checkState(isNewSourceBuffer || currentSourceBuffer == buffer); Assertions.checkState(isNewSourceBuffer || currentSourceBuffer == buffer);