Java 类com.google.android.exoplayer.util.TraceUtil 实例源码

项目:miku    文件:MediaCodecTrackRenderer.java   
@Override
protected void doSomeWork(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  sourceState = source.continueBuffering(trackIndex, positionUs)
      ? (sourceState == SOURCE_STATE_NOT_READY ? SOURCE_STATE_READY : sourceState)
      : SOURCE_STATE_NOT_READY;
  checkForDiscontinuity(positionUs);
  if (format == null) {
    readFormat(positionUs);
  }
  if (codec == null && shouldInitCodec()) {
    maybeInitCodec();
  }
  if (codec != null) {
    TraceUtil.beginSection("drainAndFeed");
    while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
    if (feedInputBuffer(positionUs, true)) {
      while (feedInputBuffer(positionUs, false)) {}
    }
    TraceUtil.endSection();
  }
  codecCounters.ensureUpdated();
}
项目:ExoPlayer-Demo    文件:MediaCodecTrackRenderer.java   
@Override
protected void doSomeWork(long positionUs, long elapsedRealtimeUs, boolean sourceIsReady)
    throws ExoPlaybackException {
  sourceState = sourceIsReady
      ? (sourceState == SOURCE_STATE_NOT_READY ? SOURCE_STATE_READY : sourceState)
      : SOURCE_STATE_NOT_READY;
  if (format == null) {
    readFormat(positionUs);
  }
  maybeInitCodec();
  if (codec != null) {
    TraceUtil.beginSection("drainAndFeed");
    while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
    if (feedInputBuffer(positionUs, true)) {
      while (feedInputBuffer(positionUs, false)) {}
    }
    TraceUtil.endSection();
  }
  codecCounters.ensureUpdated();
}
项目:ExoPlayer    文件:MediaCodecTrackRenderer.java   
@Override
protected void doSomeWork(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  sourceState = source.continueBuffering(trackIndex, positionUs)
      ? (sourceState == SOURCE_STATE_NOT_READY ? SOURCE_STATE_READY : sourceState)
      : SOURCE_STATE_NOT_READY;
  checkForDiscontinuity(positionUs);
  if (format == null) {
    readFormat(positionUs);
  }
  if (codec == null && shouldInitCodec()) {
    maybeInitCodec();
  }
  if (codec != null) {
    TraceUtil.beginSection("drainAndFeed");
    while (drainOutputBuffer(positionUs, elapsedRealtimeUs)) {}
    if (feedInputBuffer(positionUs, true)) {
      while (feedInputBuffer(positionUs, false)) {}
    }
    TraceUtil.endSection();
  }
  codecCounters.ensureUpdated();
}
项目:GLMediaPlayer    文件:TextureVideoTrackRenderer.java   
protected void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
    TraceUtil.beginSection("dropVideoBuffer");
    codec.releaseOutputBuffer(bufferIndex, false);
    TraceUtil.endSection();
    codecCounters.droppedOutputBufferCount++;
    droppedFrameCount++;
    consecutiveDroppedFrameCount++;
    codecCounters.maxConsecutiveDroppedOutputBufferCount = Math.max(consecutiveDroppedFrameCount,
            codecCounters.maxConsecutiveDroppedOutputBufferCount);
    if (droppedFrameCount == maxDroppedFrameCountToNotify) {
        maybeNotifyDroppedFrameCount();
    }
}
项目:GLMediaPlayer    文件:TextureVideoTrackRenderer.java   
protected void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
    maybeNotifyVideoSizeChanged();
    TraceUtil.beginSection("releaseOutputBuffer");
    codec.releaseOutputBuffer(bufferIndex, true);
    TraceUtil.endSection();
    codecCounters.renderedOutputBufferCount++;
    renderedFirstFrame = true;
    maybeNotifyDrawnToSurface();
}
项目:GLMediaPlayer    文件:TextureVideoTrackRenderer.java   
@TargetApi(21)
protected void renderOutputBufferV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
    maybeNotifyVideoSizeChanged();
    TraceUtil.beginSection("releaseOutputBuffer");
    codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
    TraceUtil.endSection();
    codecCounters.renderedOutputBufferCount++;
    renderedFirstFrame = true;
    maybeNotifyDrawnToSurface();
}
项目:miku    文件:MediaCodecVideoTrackRenderer.java   
protected void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.droppedOutputBufferCount++;
  droppedFrameCount++;
  if (droppedFrameCount == maxDroppedFrameCountToNotify) {
    maybeNotifyDroppedFrameCount();
  }
}
项目:miku    文件:MediaCodecVideoTrackRenderer.java   
protected void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  renderedFirstFrame = true;
  maybeNotifyDrawnToSurface();
}
项目:miku    文件:MediaCodecVideoTrackRenderer.java   
@TargetApi(21)
protected void renderOutputBufferV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  renderedFirstFrame = true;
  maybeNotifyDrawnToSurface();
}
项目:ExoPlayer-Demo    文件:MediaCodecVideoTrackRenderer.java   
protected void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.droppedOutputBufferCount++;
  droppedFrameCount++;
  consecutiveDroppedFrameCount++;
  codecCounters.maxConsecutiveDroppedOutputBufferCount = Math.max(consecutiveDroppedFrameCount,
      codecCounters.maxConsecutiveDroppedOutputBufferCount);
  if (droppedFrameCount == maxDroppedFrameCountToNotify) {
    maybeNotifyDroppedFrameCount();
  }
}
项目:ExoPlayer-Demo    文件:MediaCodecVideoTrackRenderer.java   
protected void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  renderedFirstFrame = true;
  maybeNotifyDrawnToSurface();
}
项目:ExoPlayer-Demo    文件:MediaCodecVideoTrackRenderer.java   
@TargetApi(21)
protected void renderOutputBufferV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  renderedFirstFrame = true;
  maybeNotifyDrawnToSurface();
}
项目:android-exoplayer    文件:MediaCodecVideoTrackRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.droppedOutputBufferCount++;
  droppedFrameCount++;
  if (droppedFrameCount == maxDroppedFrameCountToNotify) {
    maybeNotifyDroppedFrameCount();
  }
}
项目:android-exoplayer    文件:MediaCodecVideoTrackRenderer.java   
private void renderOutputBufferImmediate(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("renderVideoBufferImmediate");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  maybeNotifyDrawnToSurface();
}
项目:android-exoplayer    文件:MediaCodecVideoTrackRenderer.java   
@TargetApi(21)
private void renderOutputBufferTimedV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBufferTimed");
  codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  maybeNotifyDrawnToSurface();
}
项目:Exoplayer_VLC    文件:Chunk.java   
@Override
public final void load() throws IOException, InterruptedException {
  TraceUtil.beginSection("chunkLoad");
  try {
    dataSourceStream.load();
  } finally {
    TraceUtil.endSection();
  }
}
项目:Exoplayer_VLC    文件:MediaCodecVideoTrackRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.droppedOutputBufferCount++;
  droppedFrameCount++;
  if (droppedFrameCount == maxDroppedFrameCountToNotify) {
    maybeNotifyDroppedFrameCount();
  }
}
项目:Exoplayer_VLC    文件:MediaCodecVideoTrackRenderer.java   
private void renderOutputBufferImmediate(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("renderVideoBufferImmediate");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  maybeNotifyDrawnToSurface();
}
项目:Exoplayer_VLC    文件:MediaCodecVideoTrackRenderer.java   
@TargetApi(21)
private void renderOutputBufferTimedV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBufferTimed");
  codec.releaseOutputBuffer(bufferIndex,false);// releaseTimeNs);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  maybeNotifyDrawnToSurface();
}
项目:edx-app-android    文件:MediaCodecVideoTrackRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.droppedOutputBufferCount++;
  droppedFrameCount++;
  if (droppedFrameCount == maxDroppedFrameCountToNotify) {
    notifyAndResetDroppedFrameCount();
  }
}
项目:edx-app-android    文件:MediaCodecVideoTrackRenderer.java   
private void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  if (lastReportedWidth != currentWidth || lastReportedHeight != currentHeight) {
    lastReportedWidth = currentWidth;
    lastReportedHeight = currentHeight;
    notifyVideoSizeChanged(currentWidth, currentHeight);
  }
  TraceUtil.beginSection("renderVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  if (!drawnToSurface) {
    drawnToSurface = true;
    notifyDrawnToSurface(surface);
  }
}
项目:ExoPlayer    文件:MediaCodecVideoTrackRenderer.java   
protected void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.droppedOutputBufferCount++;
  droppedFrameCount++;
  if (droppedFrameCount == maxDroppedFrameCountToNotify) {
    maybeNotifyDroppedFrameCount();
  }
}
项目:ExoPlayer    文件:MediaCodecVideoTrackRenderer.java   
protected void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  renderedFirstFrame = true;
  maybeNotifyDrawnToSurface();
}
项目:ExoPlayer    文件:MediaCodecVideoTrackRenderer.java   
@TargetApi(21)
protected void renderOutputBufferV21(MediaCodec codec, int bufferIndex, long releaseTimeNs) {
  maybeNotifyVideoSizeChanged();
  TraceUtil.beginSection("releaseOutputBuffer");
  codec.releaseOutputBuffer(bufferIndex, releaseTimeNs);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  renderedFirstFrame = true;
  maybeNotifyDrawnToSurface();
}
项目:ExoPlayerCompat    文件:MediaCodecVideoTrackRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("dropVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.droppedOutputBufferCount++;
  droppedFrameCount++;
  if (droppedFrameCount == maxDroppedFrameCountToNotify) {
    notifyAndResetDroppedFrameCount();
  }
}
项目:ExoPlayerCompat    文件:MediaCodecVideoTrackRenderer.java   
private void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
  if (lastReportedWidth != currentWidth || lastReportedHeight != currentHeight) {
    lastReportedWidth = currentWidth;
    lastReportedHeight = currentHeight;
    notifyVideoSizeChanged(currentWidth, currentHeight);
  }
  TraceUtil.beginSection("renderVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, true);
  TraceUtil.endSection();
  codecCounters.renderedOutputBufferCount++;
  if (!drawnToSurface) {
    drawnToSurface = true;
    notifyDrawnToSurface(surface);
  }
}
项目:MediaCodecSpeedControllableTrackRenderer    文件:MediaCodecSpeedControllableVideoTrackRenderer.java   
private void dropOutputBuffer(MediaCodec codec, int bufferIndex) {
    TraceUtil.beginSection("dropVideoBuffer");
    codec.releaseOutputBuffer(bufferIndex, false);
    TraceUtil.endSection();
    codecCounters.droppedOutputBufferCount++;
    droppedFrameCount++;
    if (droppedFrameCount == maxDroppedFrameCountToNotify) {
        notifyAndResetDroppedFrameCount();
    }
}
项目:MediaCodecSpeedControllableTrackRenderer    文件:MediaCodecSpeedControllableVideoTrackRenderer.java   
private void renderOutputBuffer(MediaCodec codec, int bufferIndex) {
    if (lastReportedWidth != currentWidth || lastReportedHeight != currentHeight) {
        lastReportedWidth = currentWidth;
        lastReportedHeight = currentHeight;
        notifyVideoSizeChanged(currentWidth, currentHeight);
    }
    TraceUtil.beginSection("renderVideoBuffer");
    codec.releaseOutputBuffer(bufferIndex, true);
    TraceUtil.endSection();
    codecCounters.renderedOutputBufferCount++;
    if (!drawnToSurface) {
        drawnToSurface = true;
        notifyDrawnToSurface(surface);
    }
}
项目:GLMediaPlayer    文件:TextureVideoTrackRenderer.java   
protected void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
    TraceUtil.beginSection("skipVideoBuffer");
    codec.releaseOutputBuffer(bufferIndex, false);
    TraceUtil.endSection();
    codecCounters.skippedOutputBufferCount++;
}
项目:miku    文件:ExoPlayerImplInternal.java   
private void doSomeWork() throws ExoPlaybackException {
  TraceUtil.beginSection("doSomeWork");
  long operationStartTimeMs = SystemClock.elapsedRealtime();
  long bufferedPositionUs = durationUs != TrackRenderer.UNKNOWN_TIME_US
      ? durationUs
      : Long.MAX_VALUE;
  boolean allRenderersEnded = true;
  boolean allRenderersReadyOrEnded = true;
  updatePositionUs();
  for (int i = 0; i < enabledRenderers.size(); i++) {
    TrackRenderer renderer = enabledRenderers.get(i);
    // TODO: Each renderer should return the maximum delay before which it wishes to be
    // invoked again. The minimum of these values should then be used as the delay before the next
    // invocation of this method.
    renderer.doSomeWork(positionUs, elapsedRealtimeUs);
    allRenderersEnded = allRenderersEnded && renderer.isEnded();

    // Determine whether the renderer is ready (or ended). If it's not, throw an error that's
    // preventing the renderer from making progress, if such an error exists.
    boolean rendererReadyOrEnded = rendererReadyOrEnded(renderer);
    if (!rendererReadyOrEnded) {
      renderer.maybeThrowError();
    }
    allRenderersReadyOrEnded = allRenderersReadyOrEnded && rendererReadyOrEnded;

    if (bufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
      // We've already encountered a track for which the buffered position is unknown. Hence the
      // media buffer position unknown regardless of the buffered position of this track.
    } else {
      long rendererDurationUs = renderer.getDurationUs();
      long rendererBufferedPositionUs = renderer.getBufferedPositionUs();
      if (rendererBufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
        bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;
      } else if (rendererBufferedPositionUs == TrackRenderer.END_OF_TRACK_US
          || (rendererDurationUs != TrackRenderer.UNKNOWN_TIME_US
              && rendererDurationUs != TrackRenderer.MATCH_LONGEST_US
              && rendererBufferedPositionUs >= rendererDurationUs)) {
        // This track is fully buffered.
      } else {
        bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
      }
    }
  }
  this.bufferedPositionUs = bufferedPositionUs;

  if (allRenderersEnded
      && (durationUs == TrackRenderer.UNKNOWN_TIME_US || durationUs <= positionUs)) {
    setState(ExoPlayer.STATE_ENDED);
    stopRenderers();
  } else if (state == ExoPlayer.STATE_BUFFERING && allRenderersReadyOrEnded) {
    setState(ExoPlayer.STATE_READY);
    if (playWhenReady) {
      startRenderers();
    }
  } else if (state == ExoPlayer.STATE_READY && !allRenderersReadyOrEnded) {
    rebuffering = playWhenReady;
    setState(ExoPlayer.STATE_BUFFERING);
    stopRenderers();
  }

  handler.removeMessages(MSG_DO_SOME_WORK);
  if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, RENDERING_INTERVAL_MS);
  } else if (!enabledRenderers.isEmpty()) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, IDLE_INTERVAL_MS);
  }

  TraceUtil.endSection();
}
项目:miku    文件:MediaCodecVideoTrackRenderer.java   
protected void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.skippedOutputBufferCount++;
}
项目:ExoPlayer-Demo    文件:ExoPlayerImplInternal.java   
private void doSomeWork() throws ExoPlaybackException {
  TraceUtil.beginSection("doSomeWork");
  long operationStartTimeMs = SystemClock.elapsedRealtime();
  long bufferedPositionUs = durationUs != TrackRenderer.UNKNOWN_TIME_US ? durationUs
      : Long.MAX_VALUE;
  boolean allRenderersEnded = true;
  boolean allRenderersReadyOrEnded = true;
  updatePositionUs();
  for (int i = 0; i < enabledRenderers.size(); i++) {
    TrackRenderer renderer = enabledRenderers.get(i);
    // TODO: Each renderer should return the maximum delay before which it wishes to be
    // invoked again. The minimum of these values should then be used as the delay before the next
    // invocation of this method.
    renderer.doSomeWork(positionUs, elapsedRealtimeUs);
    allRenderersEnded = allRenderersEnded && renderer.isEnded();

    // Determine whether the renderer is ready (or ended). If it's not, throw an error that's
    // preventing the renderer from making progress, if such an error exists.
    boolean rendererReadyOrEnded = rendererReadyOrEnded(renderer);
    if (!rendererReadyOrEnded) {
      renderer.maybeThrowError();
    }
    allRenderersReadyOrEnded = allRenderersReadyOrEnded && rendererReadyOrEnded;

    if (bufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
      // We've already encountered a track for which the buffered position is unknown. Hence the
      // media buffer position unknown regardless of the buffered position of this track.
    } else {
      long rendererDurationUs = renderer.getDurationUs();
      long rendererBufferedPositionUs = renderer.getBufferedPositionUs();
      if (rendererBufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
        bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;
      } else if (rendererBufferedPositionUs == TrackRenderer.END_OF_TRACK_US
          || (rendererDurationUs != TrackRenderer.UNKNOWN_TIME_US
              && rendererDurationUs != TrackRenderer.MATCH_LONGEST_US
              && rendererBufferedPositionUs >= rendererDurationUs)) {
        // This track is fully buffered.
      } else {
        bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
      }
    }
  }
  this.bufferedPositionUs = bufferedPositionUs;

  if (allRenderersEnded
      && (durationUs == TrackRenderer.UNKNOWN_TIME_US || durationUs <= positionUs)) {
    setState(ExoPlayer.STATE_ENDED);
    stopRenderers();
  } else if (state == ExoPlayer.STATE_BUFFERING && allRenderersReadyOrEnded) {
    setState(ExoPlayer.STATE_READY);
    if (playWhenReady) {
      startRenderers();
    }
  } else if (state == ExoPlayer.STATE_READY && !allRenderersReadyOrEnded) {
    rebuffering = playWhenReady;
    setState(ExoPlayer.STATE_BUFFERING);
    stopRenderers();
  }

  handler.removeMessages(MSG_DO_SOME_WORK);
  if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, RENDERING_INTERVAL_MS);
  } else if (!enabledRenderers.isEmpty()) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, IDLE_INTERVAL_MS);
  }

  TraceUtil.endSection();
}
项目:ExoPlayer-Demo    文件:MediaCodecVideoTrackRenderer.java   
protected void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.skippedOutputBufferCount++;
}
项目:android-exoplayer    文件:ExoPlayerImplInternal.java   
private void doSomeWork() throws ExoPlaybackException {
  TraceUtil.beginSection("doSomeWork");
  long operationStartTimeMs = SystemClock.elapsedRealtime();
  long bufferedPositionUs = durationUs != TrackRenderer.UNKNOWN_TIME_US ? durationUs
      : Long.MAX_VALUE;
  boolean isEnded = true;
  boolean allRenderersReadyOrEnded = true;
  updatePositionUs();
  for (int i = 0; i < enabledRenderers.size(); i++) {
    TrackRenderer renderer = enabledRenderers.get(i);
    // TODO: Each renderer should return the maximum delay before which it wishes to be
    // invoked again. The minimum of these values should then be used as the delay before the next
    // invocation of this method.
    renderer.doSomeWork(positionUs, elapsedRealtimeUs);
    isEnded = isEnded && renderer.isEnded();
    allRenderersReadyOrEnded = allRenderersReadyOrEnded && rendererReadyOrEnded(renderer);

    if (bufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
      // We've already encountered a track for which the buffered position is unknown. Hence the
      // media buffer position unknown regardless of the buffered position of this track.
    } else {
      long rendererDurationUs = renderer.getDurationUs();
      long rendererBufferedPositionUs = renderer.getBufferedPositionUs();
      if (rendererBufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
        bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;
      } else if (rendererBufferedPositionUs == TrackRenderer.END_OF_TRACK_US
          || (rendererDurationUs != TrackRenderer.UNKNOWN_TIME_US
              && rendererDurationUs != TrackRenderer.MATCH_LONGEST_US
              && rendererBufferedPositionUs >= rendererDurationUs)) {
        // This track is fully buffered.
      } else {
        bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
      }
    }
  }
  this.bufferedPositionUs = bufferedPositionUs;

  if (isEnded) {
    setState(ExoPlayer.STATE_ENDED);
    stopRenderers();
  } else if (state == ExoPlayer.STATE_BUFFERING && allRenderersReadyOrEnded) {
    setState(ExoPlayer.STATE_READY);
    if (playWhenReady) {
      startRenderers();
    }
  } else if (state == ExoPlayer.STATE_READY && !allRenderersReadyOrEnded) {
    rebuffering = playWhenReady;
    setState(ExoPlayer.STATE_BUFFERING);
    stopRenderers();
  }

  handler.removeMessages(MSG_DO_SOME_WORK);
  if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, RENDERING_INTERVAL_MS);
  } else if (!enabledRenderers.isEmpty()) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, IDLE_INTERVAL_MS);
  }

  TraceUtil.endSection();
}
项目:android-exoplayer    文件:MediaCodecVideoTrackRenderer.java   
private void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.skippedOutputBufferCount++;
}
项目:Exoplayer_VLC    文件:ExoPlayerImplInternal.java   
private void doSomeWork() throws ExoPlaybackException {
    TraceUtil.beginSection("doSomeWork");
    long operationStartTimeMs = SystemClock.elapsedRealtime();
    long bufferedPositionUs = durationUs != TrackRenderer.UNKNOWN_TIME_US ? durationUs
        : Long.MAX_VALUE;
    boolean isEnded = true;
    boolean allRenderersReadyOrEnded = true;
    updatePositionUs();
    for (int i = 0; i < enabledRenderers.size(); i++) {
      TrackRenderer renderer = enabledRenderers.get(i);
      // TODO: Each renderer should return the maximum delay before which it wishes to be
      // invoked again. The minimum of these values should then be used as the delay before the next
      // invocation of this method.
      renderer.doSomeWork(positionUs, elapsedRealtimeUs);
      isEnded = isEnded && renderer.isEnded();
      allRenderersReadyOrEnded = allRenderersReadyOrEnded && rendererReadyOrEnded(renderer);
      //if( state<ExoPlayer.STATE_READY)
      //Log.d(TAG, "#####doSomeWork(): ... "+i+"="+rendererReadyOrEnded(renderer));

      if (bufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
        // We've already encountered a track for which the buffered position is unknown. Hence the
        // media buffer position unknown regardless of the buffered position of this track.
      } else {
        long rendererDurationUs = renderer.getDurationUs();
        long rendererBufferedPositionUs = renderer.getBufferedPositionUs();
        if (rendererBufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
          bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;
        } else if (rendererBufferedPositionUs == TrackRenderer.END_OF_TRACK_US
            || (rendererDurationUs != TrackRenderer.UNKNOWN_TIME_US
                && rendererDurationUs != TrackRenderer.MATCH_LONGEST_US
                && rendererBufferedPositionUs >= rendererDurationUs)) {
          // This track is fully buffered.
        } else {
          bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
        }
      }
    }
    this.bufferedPositionUs = bufferedPositionUs;

    //Log.d(TAG, "#####doSomeWork(): state="+state+", allRenderersReadyOrEnded="+allRenderersReadyOrEnded+", buff="+this.bufferedPositionUs);
    if (isEnded) {
        Log.d(TAG, "#####doSomeWork(): state="+state+", isEnded=>stop");
      setState(ExoPlayer.STATE_ENDED);
      stopRenderers();
    } else if (state == ExoPlayer.STATE_BUFFERING && allRenderersReadyOrEnded) {
      setState(ExoPlayer.STATE_READY);
      if (playWhenReady) {
          Log.d(TAG, "#####doSomeWork(): state="+state+", allRenderersReadyOrEnded="+allRenderersReadyOrEnded+", buff="+this.bufferedPositionUs);
        startRenderers();
      }
    } else if (state == ExoPlayer.STATE_READY && !allRenderersReadyOrEnded) {
      rebuffering = playWhenReady;
      setState(ExoPlayer.STATE_BUFFERING);
      stopRenderers();
    }
//System.out.println("ExoPlayerImplInternal.doSomeWork() send MSG_DO_SOME_WORK ***");
    handler.removeMessages(MSG_DO_SOME_WORK);
    if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
      scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, RENDERING_INTERVAL_MS);
    } else if (!enabledRenderers.isEmpty()) {
      scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, IDLE_INTERVAL_MS);
    }

    TraceUtil.endSection();
  }
项目:Exoplayer_VLC    文件:MediaCodecVideoTrackRenderer.java   
private void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.skippedOutputBufferCount++;
}
项目:edx-app-android    文件:ExoPlayerImplInternal.java   
private void doSomeWork() throws ExoPlaybackException {
  TraceUtil.beginSection("doSomeWork");
  long operationStartTimeMs = SystemClock.elapsedRealtime();
  long bufferedPositionUs = durationUs != TrackRenderer.UNKNOWN_TIME_US ? durationUs
      : Long.MAX_VALUE;
  boolean isEnded = true;
  boolean allRenderersReadyOrEnded = true;
  updatePositionUs();
  for (int i = 0; i < enabledRenderers.size(); i++) {
    TrackRenderer renderer = enabledRenderers.get(i);
    // rohan's code: set the playback speed
    renderer.setPlaybackSpeed(playbackSpeed);
    // TODO: Each renderer should return the maximum delay before which it wishes to be
    // invoked again. The minimum of these values should then be used as the delay before the next
    // invocation of this method.
    // rohan's code: long timeUs = (long) (positionUs * playbackSpeed);
    renderer.doSomeWork(positionUs);
    isEnded = isEnded && renderer.isEnded();
    allRenderersReadyOrEnded = allRenderersReadyOrEnded && rendererReadyOrEnded(renderer);

    if (bufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
      // We've already encountered a track for which the buffered position is unknown. Hence the
      // media buffer position unknown regardless of the buffered position of this track.
    } else {
      long rendererDurationUs = renderer.getDurationUs();
      long rendererBufferedPositionUs = renderer.getBufferedPositionUs();
      if (rendererBufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
        bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;
      } else if (rendererBufferedPositionUs == TrackRenderer.END_OF_TRACK_US
          || (rendererDurationUs != TrackRenderer.UNKNOWN_TIME_US
              && rendererDurationUs != TrackRenderer.MATCH_LONGEST_US
              && rendererBufferedPositionUs >= rendererDurationUs)) {
        // This track is fully buffered.
      } else {
        bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
      }
    }
  }
  this.bufferedPositionUs = bufferedPositionUs;

  if (isEnded) {
    setState(ExoPlayer.STATE_ENDED);
    stopRenderers();
  } else if (state == ExoPlayer.STATE_BUFFERING && allRenderersReadyOrEnded) {
    setState(ExoPlayer.STATE_READY);
    if (playWhenReady) {
      startRenderers();
    }
  } else if (state == ExoPlayer.STATE_READY && !allRenderersReadyOrEnded) {
    rebuffering = playWhenReady;
    setState(ExoPlayer.STATE_BUFFERING);
    stopRenderers();
  }

  handler.removeMessages(MSG_DO_SOME_WORK);
  if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, RENDERING_INTERVAL_MS);
  } else if (!enabledRenderers.isEmpty()) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, IDLE_INTERVAL_MS);
  }

  TraceUtil.endSection();
}
项目:edx-app-android    文件:MediaCodecVideoTrackRenderer.java   
private void skipOutputBuffer(MediaCodec codec, int bufferIndex) {
  TraceUtil.beginSection("skipVideoBuffer");
  codec.releaseOutputBuffer(bufferIndex, false);
  TraceUtil.endSection();
  codecCounters.skippedOutputBufferCount++;
}
项目:ExoPlayer    文件:ExoPlayerImplInternal.java   
private void doSomeWork() throws ExoPlaybackException {
  TraceUtil.beginSection("doSomeWork");
  long operationStartTimeMs = SystemClock.elapsedRealtime();
  long bufferedPositionUs = durationUs != TrackRenderer.UNKNOWN_TIME_US ? durationUs
      : Long.MAX_VALUE;
  boolean allRenderersEnded = true;
  boolean allRenderersReadyOrEnded = true;
  updatePositionUs();
  for (int i = 0; i < enabledRenderers.size(); i++) {
    TrackRenderer renderer = enabledRenderers.get(i);
    // TODO: Each renderer should return the maximum delay before which it wishes to be
    // invoked again. The minimum of these values should then be used as the delay before the next
    // invocation of this method.
    renderer.doSomeWork(positionUs, elapsedRealtimeUs);
    allRenderersEnded = allRenderersEnded && renderer.isEnded();

    // Determine whether the renderer is ready (or ended). If it's not, throw an error that's
    // preventing the renderer from making progress, if such an error exists.
    boolean rendererReadyOrEnded = rendererReadyOrEnded(renderer);
    if (!rendererReadyOrEnded) {
      renderer.maybeThrowError();
    }
    allRenderersReadyOrEnded = allRenderersReadyOrEnded && rendererReadyOrEnded;

    if (bufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
      // We've already encountered a track for which the buffered position is unknown. Hence the
      // media buffer position unknown regardless of the buffered position of this track.
    } else {
      long rendererDurationUs = renderer.getDurationUs();
      long rendererBufferedPositionUs = renderer.getBufferedPositionUs();
      if (rendererBufferedPositionUs == TrackRenderer.UNKNOWN_TIME_US) {
        bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;
      } else if (rendererBufferedPositionUs == TrackRenderer.END_OF_TRACK_US
          || (rendererDurationUs != TrackRenderer.UNKNOWN_TIME_US
              && rendererDurationUs != TrackRenderer.MATCH_LONGEST_US
              && rendererBufferedPositionUs >= rendererDurationUs)) {
        // This track is fully buffered.
      } else {
        bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
      }
    }
  }
  this.bufferedPositionUs = bufferedPositionUs;

  if (allRenderersEnded
      && (durationUs == TrackRenderer.UNKNOWN_TIME_US || durationUs <= positionUs)) {
    setState(ExoPlayer.STATE_ENDED);
    stopRenderers();
  } else if (state == ExoPlayer.STATE_BUFFERING && allRenderersReadyOrEnded) {
    setState(ExoPlayer.STATE_READY);
    if (playWhenReady) {
      startRenderers();
    }
  } else if (state == ExoPlayer.STATE_READY && !allRenderersReadyOrEnded) {
    rebuffering = playWhenReady;
    setState(ExoPlayer.STATE_BUFFERING);
    stopRenderers();
  }

  handler.removeMessages(MSG_DO_SOME_WORK);
  if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, RENDERING_INTERVAL_MS);
  } else if (!enabledRenderers.isEmpty()) {
    scheduleNextOperation(MSG_DO_SOME_WORK, operationStartTimeMs, IDLE_INTERVAL_MS);
  }

  TraceUtil.endSection();
}