本文整理汇总了Java中com.google.android.exoplayer.audio.AudioTrack.RESULT_BUFFER_CONSUMED属性的典型用法代码示例。如果您正苦于以下问题:Java AudioTrack.RESULT_BUFFER_CONSUMED属性的具体用法?Java AudioTrack.RESULT_BUFFER_CONSUMED怎么用?Java AudioTrack.RESULT_BUFFER_CONSUMED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.exoplayer.audio.AudioTrack
的用法示例。
在下文中一共展示了AudioTrack.RESULT_BUFFER_CONSUMED属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOutput
private boolean processOutput() throws ExoPlaybackException {
if (mOutputStreamEnded) {
return false;
}
if (!mOutputReady) {
if (mInputStreamEnded) {
mOutputStreamEnded = true;
mEndOfStreamMs = SystemClock.elapsedRealtime();
return false;
}
return true;
}
ensureAudioTrackInitialized();
int handleBufferResult;
try {
// To reduce discontinuity, interpolate presentation time.
mInterpolatedTimeUs = mPresentationTimeUs
+ mPresentationCount * AC3_SAMPLE_DURATION_US;
handleBufferResult = AUDIO_TRACK.handleBuffer(mOutputBuffer,
0, mOutputBuffer.limit(), mInterpolatedTimeUs);
} catch (AudioTrack.WriteException e) {
notifyAudioTrackWriteError(e);
throw new ExoPlaybackException(e);
}
if ((handleBufferResult & AudioTrack.RESULT_POSITION_DISCONTINUITY) != 0) {
Log.i(TAG, "Play discontinuity happened");
mCurrentPositionUs = Long.MIN_VALUE;
}
if ((handleBufferResult & AudioTrack.RESULT_BUFFER_CONSUMED) != 0) {
mCodecCounters.renderedOutputBufferCount++;
mOutputReady = false;
return true;
}
return false;
}
示例2: handleBuffer
public int handleBuffer(ByteBuffer buffer, int offset, int size, long presentationTimeUs)
throws AudioTrack.WriteException {
if (!mIsEnabled) {
return AudioTrack.RESULT_BUFFER_CONSUMED;
}
return mAudioTrack.handleBuffer(buffer, offset, size, presentationTimeUs);
}
示例3: renderBuffer
private void renderBuffer() throws OpusDecoderException, AudioTrack.InitializationException,
AudioTrack.WriteException {
if (outputStreamEnded) {
return;
}
if (outputBuffer == null) {
outputBuffer = decoder.dequeueOutputBuffer();
if (outputBuffer == null) {
return;
}
}
if (outputBuffer.getFlag(Buffer.FLAG_END_OF_STREAM)) {
outputStreamEnded = true;
audioTrack.handleEndOfStream();
outputBuffer.release();
outputBuffer = null;
return;
}
if (!audioTrack.isInitialized()) {
if (audioSessionId != AudioTrack.SESSION_ID_NOT_SET) {
audioTrack.initialize(audioSessionId);
} else {
audioSessionId = audioTrack.initialize();
}
if (getState() == TrackRenderer.STATE_STARTED) {
audioTrack.play();
}
}
int handleBufferResult;
handleBufferResult = audioTrack.handleBuffer(outputBuffer.data, outputBuffer.data.position(),
outputBuffer.data.remaining(), outputBuffer.timestampUs);
// If we are out of sync, allow currentPositionUs to jump backwards.
if ((handleBufferResult & AudioTrack.RESULT_POSITION_DISCONTINUITY) != 0) {
allowPositionDiscontinuity = true;
}
// Release the buffer if it was consumed.
if ((handleBufferResult & AudioTrack.RESULT_BUFFER_CONSUMED) != 0) {
codecCounters.renderedOutputBufferCount++;
outputBuffer.release();
outputBuffer = null;
}
}
示例4: renderBuffer
private void renderBuffer() throws FlacDecoderException, AudioTrack.InitializationException,
AudioTrack.WriteException {
if (outputStreamEnded) {
return;
}
if (outputBuffer == null) {
outputBuffer = decoder.dequeueOutputBuffer();
if (outputBuffer == null) {
return;
}
}
if (outputBuffer.getFlag(Buffer.FLAG_END_OF_STREAM)) {
outputStreamEnded = true;
audioTrack.handleEndOfStream();
outputBuffer.release();
outputBuffer = null;
return;
}
if (!audioTrack.isInitialized()) {
if (audioSessionId != AudioTrack.SESSION_ID_NOT_SET) {
audioTrack.initialize(audioSessionId);
} else {
audioSessionId = audioTrack.initialize();
}
if (getState() == TrackRenderer.STATE_STARTED) {
audioTrack.play();
}
}
int handleBufferResult;
handleBufferResult = audioTrack.handleBuffer(outputBuffer.data, outputBuffer.data.position(),
outputBuffer.data.remaining(), outputBuffer.timestampUs);
// If we are out of sync, allow currentPositionUs to jump backwards.
if ((handleBufferResult & AudioTrack.RESULT_POSITION_DISCONTINUITY) != 0) {
allowPositionDiscontinuity = true;
}
// Release the buffer if it was consumed.
if ((handleBufferResult & AudioTrack.RESULT_BUFFER_CONSUMED) != 0) {
codecCounters.renderedOutputBufferCount++;
outputBuffer.release();
outputBuffer = null;
}
}