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


Java Assertions.checkState方法代码示例

本文整理汇总了Java中com.google.android.exoplayer.util.Assertions.checkState方法的典型用法代码示例。如果您正苦于以下问题:Java Assertions.checkState方法的具体用法?Java Assertions.checkState怎么用?Java Assertions.checkState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer.util.Assertions的用法示例。


在下文中一共展示了Assertions.checkState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: seekToUs

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public void seekToUs(long positionUs) {
  Assertions.checkState(prepared);
  Assertions.checkState(enabledTrackCount > 0);

  long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs;
  downstreamPositionUs = positionUs;
  lastSeekPositionUs = positionUs;
  if (currentPositionUs == positionUs) {
    return;
  }

  // TODO: Optimize the seek for the case where the position is already buffered.
  downstreamPositionUs = positionUs;
  for (int i = 0; i < pendingDiscontinuities.length; i++) {
    pendingDiscontinuities[i] = true;
  }
  restartFrom(positionUs);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:20,代码来源:HlsSampleSource.java

示例2: seekToUs

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public void seekToUs(long positionUs) {
  Assertions.checkState(prepared);
  Assertions.checkState(enabledTrackCount > 0);
  // Treat all seeks into live streams as being to t=0.
  positionUs = chunkSource.isLive() ? 0 : positionUs;

  // Ignore seeks to the current position.
  long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs;
  downstreamPositionUs = positionUs;
  lastSeekPositionUs = positionUs;
  if (currentPositionUs == positionUs) {
    return;
  }

  seekToInternal(positionUs);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:18,代码来源:HlsSampleSource.java

示例3: decodeDone

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
private void decodeDone(ByteBuffer outputBuffer, long presentationTimeUs) {
    if (outputBuffer == null || mOutputBuffer == null) {
        return;
    }
    if (presentationTimeUs < 0) {
        Log.e(TAG, "decodeDone - invalid presentationTimeUs");
        return;
    }

    if (TunerDebug.ENABLED) {
        TunerDebug.setAudioPtsUs(presentationTimeUs);
    }

    mOutputBuffer.clear();
    Assertions.checkState(mOutputBuffer.remaining() >= outputBuffer.limit());

    mOutputBuffer.put(outputBuffer);
    mMonitor.addPts(presentationTimeUs, mOutputBuffer.position(),
            mOutputBuffer.get(AC3_HEADER_BITRATE_OFFSET));
    if (presentationTimeUs == mPresentationTimeUs) {
        mPresentationCount++;
    } else {
        mPresentationCount = 0;
        mPresentationTimeUs = presentationTimeUs;
    }
    mOutputBuffer.flip();
    mOutputReady = true;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:29,代码来源:Ac3PassthroughTrackRenderer.java

示例4: removeSpan

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public synchronized void removeSpan(CacheSpan span) {
  TreeSet<CacheSpan> spansForKey = cachedSpans.get(span.key);
  totalSpace -= span.length;
  Assertions.checkState(spansForKey.remove(span));
  span.file.delete();
  if (spansForKey.isEmpty()) {
    cachedSpans.remove(span.key);
  }
  notifySpanRemoved(span);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:12,代码来源:SimpleCache.java

示例5: release

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public void release() {
  Assertions.checkState(remainingReleaseCount > 0);
  if (--remainingReleaseCount == 0 && extractor != null) {
    extractor.release();
    extractor = null;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:9,代码来源:FrameworkSampleSource.java

示例6: onReleased

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * Releases the renderer.
 *
 * @throws ExoPlaybackException If an error occurs.
 */
/* package */ final void release() throws ExoPlaybackException {
  Assertions.checkState(state != STATE_ENABLED
      && state != STATE_STARTED
      && state != STATE_RELEASED);
  state = STATE_RELEASED;
  onReleased();
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:13,代码来源:TrackRenderer.java

示例7: readData

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public int readData(int track, long positionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder, boolean onlyReadDiscontinuity) {
  Assertions.checkState(prepared);
  Assertions.checkState(trackStates[track] != TRACK_STATE_DISABLED);
  if (pendingDiscontinuities[track]) {
    pendingDiscontinuities[track] = false;
    return DISCONTINUITY_READ;
  }
  if (onlyReadDiscontinuity) {
    return NOTHING_READ;
  }
  if (trackStates[track] != TRACK_STATE_FORMAT_SENT) {
    formatHolder.format = MediaFormat.createFromFrameworkMediaFormatV16(
        extractor.getTrackFormat(track));
    formatHolder.drmInitData = Util.SDK_INT >= 18 ? getDrmInitDataV18() : null;
    trackStates[track] = TRACK_STATE_FORMAT_SENT;
    return FORMAT_READ;
  }
  int extractorTrackIndex = extractor.getSampleTrackIndex();
  if (extractorTrackIndex == track) {
    if (sampleHolder.data != null) {
      int offset = sampleHolder.data.position();
      sampleHolder.size = extractor.readSampleData(sampleHolder.data, offset);
      sampleHolder.data.position(offset + sampleHolder.size);
    } else {
      sampleHolder.size = 0;
    }
    sampleHolder.timeUs = extractor.getSampleTime();
    sampleHolder.flags = extractor.getSampleFlags() & ALLOWED_FLAGS_MASK;
    if (sampleHolder.isEncrypted()) {
      sampleHolder.cryptoInfo.setFromExtractorV16(extractor);
    }
    seekPositionUs = C.UNKNOWN_TIME_US;
    extractor.advance();
    return SAMPLE_READ;
  } else {
    return extractorTrackIndex < 0 ? END_OF_STREAM : NOTHING_READ;
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:41,代码来源:FrameworkSampleSource.java

示例8: enable

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public void enable(int track, long positionUs) {
  Assertions.checkState(state == STATE_PREPARED);
  Assertions.checkState(track == 0);
  state = STATE_ENABLED;
  chunkSource.enable();
  loadControl.register(this, bufferSizeContribution);
  downstreamFormat = null;
  downstreamMediaFormat = null;
  downstreamPositionUs = positionUs;
  lastSeekPositionUs = positionUs;
  pendingDiscontinuity = false;
  restartFrom(positionUs);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:15,代码来源:ChunkSampleSource.java

示例9: read

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public int read(byte[] buffer, int offset, int length) throws IOException {
  Assertions.checkState(!closed);
  checkOpened();
  return dataSource.read(buffer, offset, length);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:7,代码来源:DataSourceInputStream.java

示例10: skip

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public long skip(long byteCount) throws IOException {
  Assertions.checkState(!closed);
  checkOpened();
  return super.skip(byteCount);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:7,代码来源:DataSourceInputStream.java

示例11: appendReadData

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * Appends to the underlying data.
 */
public Builder appendReadData(byte[] data) {
  Assertions.checkState(data != null && data.length > 0);
  segments.add(new Segment(data, null));
  return this;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:9,代码来源:FakeDataSource.java

示例12: track

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public TrackOutput track(int id) {
  Assertions.checkState(!seenTrack);
  seenTrack = true;
  return this;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:7,代码来源:ChunkExtractorWrapper.java

示例13: maybeStartLoading

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
private void maybeStartLoading() {
  if (loadingFinished || loader.isLoading()) {
    return;
  }

  if (currentLoadableException != null) {
    if (isCurrentLoadableExceptionFatal()) {
      return;
    }
    Assertions.checkState(loadable != null);
    long elapsedMillis = SystemClock.elapsedRealtime() - currentLoadableExceptionTimestamp;
    if (elapsedMillis >= getRetryDelayMillis(currentLoadableExceptionCount)) {
      currentLoadableException = null;
      if (!prepared) {
        // We don't know whether we're playing an on-demand or a live stream. For a live stream
        // we need to load from the start, as outlined below. Since we might be playing a live
        // stream, play it safe and load from the start.
        for (int i = 0; i < sampleQueues.size(); i++) {
          sampleQueues.valueAt(i).clear();
        }
        loadable = createLoadableFromStart();
      } else if (!seekMap.isSeekable()) {
        // We're playing a non-seekable stream. Assume it's live, and therefore that the data at
        // the uri is a continuously shifting window of the latest available media. For this case
        // there's no way to continue loading from where a previous load finished, and hence it's
        // necessary to load from the start whenever commencing a new load.
        for (int i = 0; i < sampleQueues.size(); i++) {
          sampleQueues.valueAt(i).clear();
        }
        loadable = createLoadableFromStart();
        // To avoid introducing a discontinuity, we shift the sample timestamps so that they will
        // continue from the current downstream position.
        pendingNextSampleUs = downstreamPositionUs;
        havePendingNextSampleUs = true;
      } else {
        // We're playing a seekable on-demand stream. Resume the current loadable, which will
        // request data starting from the point it left off.
      }
      extractedSampleCountAtStartOfLoad = extractedSampleCount;
      loader.startLoading(loadable, this);
    }
    return;
  }

  // We're not retrying, so we're either starting a playback or responding to an explicit seek.
  // In both cases sampleTimeOffsetUs should be reset to zero, and any pending adjustment to
  // sample timestamps should be discarded.
  sampleTimeOffsetUs = 0;
  havePendingNextSampleUs = false;

  if (!prepared) {
    loadable = createLoadableFromStart();
  } else {
    Assertions.checkState(isPendingReset());
    if (maxTrackDurationUs != C.UNKNOWN_TIME_US && pendingResetPositionUs >= maxTrackDurationUs) {
      loadingFinished = true;
      pendingResetPositionUs = NO_RESET_PENDING;
      return;
    }
    loadable = createLoadableFromPositionUs(pendingResetPositionUs);
    pendingResetPositionUs = NO_RESET_PENDING;
  }
  extractedSampleCountAtStartOfLoad = extractedSampleCount;
  loader.startLoading(loadable, this);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:66,代码来源:ExtractorSampleSource.java

示例14: resumeFromBackOff

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * Resumes loading.
 * <p>
 * If the {@link ChunkSource} returns a chunk equivalent to the backed off chunk B, then the
 * loading of B will be resumed. In all other cases B will be discarded and the new chunk will
 * be loaded.
 */
private void resumeFromBackOff() {
  currentLoadableException = null;

  Chunk backedOffChunk = currentLoadableHolder.chunk;
  if (!isMediaChunk(backedOffChunk)) {
    currentLoadableHolder.queueSize = readOnlyMediaChunks.size();
    chunkSource.getChunkOperation(readOnlyMediaChunks, pendingResetPositionUs,
        downstreamPositionUs, currentLoadableHolder);
    discardUpstreamMediaChunks(currentLoadableHolder.queueSize);
    if (currentLoadableHolder.chunk == backedOffChunk) {
      // Chunk was unchanged. Resume loading.
      loader.startLoading(backedOffChunk, this);
    } else {
      // Chunk was changed. Notify that the existing load was canceled.
      notifyLoadCanceled(backedOffChunk.bytesLoaded());
      // Start loading the replacement.
      maybeStartLoading();
    }
    return;
  }

  if (backedOffChunk == mediaChunks.getFirst()) {
    // We're not able to clear the first media chunk, so we have no choice but to continue
    // loading it.
    loader.startLoading(backedOffChunk, this);
    return;
  }

  // The current loadable is the last media chunk. Remove it before we invoke the chunk source,
  // and add it back again afterwards.
  BaseMediaChunk removedChunk = mediaChunks.removeLast();
  Assertions.checkState(backedOffChunk == removedChunk);
  currentLoadableHolder.queueSize = readOnlyMediaChunks.size();
  chunkSource.getChunkOperation(readOnlyMediaChunks, pendingResetPositionUs, downstreamPositionUs,
      currentLoadableHolder);
  mediaChunks.add(removedChunk);

  if (currentLoadableHolder.chunk == backedOffChunk) {
    // Chunk was unchanged. Resume loading.
    loader.startLoading(backedOffChunk, this);
  } else {
    // Chunk was changed. Notify that the existing load was canceled.
    notifyLoadCanceled(backedOffChunk.bytesLoaded());
    // This call will remove and release at least one chunk from the end of mediaChunks. Since
    // the current loadable is the last media chunk, it is guaranteed to be removed.
    discardUpstreamMediaChunks(currentLoadableHolder.queueSize);
    clearCurrentLoadableException();
    maybeStartLoading();
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:58,代码来源:ChunkSampleSource.java

示例15: getTrackCount

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public int getTrackCount() {
  Assertions.checkState(prepared);
  return trackStates.length;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:6,代码来源:FrameworkSampleSource.java


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