当前位置: 首页>>代码示例>>Java>>正文


Java AudioTrack.RESULT_BUFFER_CONSUMED属性代码示例

本文整理汇总了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;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:37,代码来源:Ac3PassthroughTrackRenderer.java

示例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);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:7,代码来源:AudioTrackWrapper.java

示例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;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:48,代码来源:LibopusAudioTrackRenderer.java

示例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;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:48,代码来源:LibflacAudioTrackRenderer.java


注:本文中的com.google.android.exoplayer.audio.AudioTrack.RESULT_BUFFER_CONSUMED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。