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


Java SimulatedIOException类代码示例

本文整理汇总了Java中com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException的典型用法代码示例。如果您正苦于以下问题:Java SimulatedIOException类的具体用法?Java SimulatedIOException怎么用?Java SimulatedIOException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimulatedIOException类属于com.google.android.exoplayer2.testutil.FakeExtractorInput包,在下文中一共展示了SimulatedIOException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readSetupHeaders

import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException; //导入依赖的package包/类
private static VorbisSetup readSetupHeaders(VorbisReader reader, ExtractorInput input)
    throws IOException, InterruptedException {
  OggPacket oggPacket = new OggPacket();
  while (true) {
    try {
      if (!oggPacket.populate(input)) {
        fail();
      }
      VorbisSetup vorbisSetup = reader.readSetupHeaders(oggPacket.getPayload());
      if (vorbisSetup != null) {
        return vorbisSetup;
      }
    } catch (SimulatedIOException e) {
      // Ignore.
    }
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:18,代码来源:VorbisReaderTest.java

示例2: testReadVarintFlaky

import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException; //导入依赖的package包/类
private static void testReadVarintFlaky(VarintReader reader, boolean removeMask, byte[] data,
    int expectedLength, long expectedValue) throws IOException, InterruptedException {
  ExtractorInput input = new FakeExtractorInput.Builder()
      .setData(data)
      .setSimulateUnknownLength(true)
      .setSimulateIOErrors(true)
      .setSimulatePartialReads(true)
      .build();
  long result = -1;
  while (result == -1) {
    try {
      result = reader.readUnsignedVarint(input, false, removeMask, 8);
      if (result == C.RESULT_END_OF_INPUT || result == C.RESULT_MAX_LENGTH_EXCEEDED) {
        // Unexpected.
        fail();
      }
    } catch (SimulatedIOException e) {
      // Expected.
    }
  }
  assertEquals(expectedLength, input.getPosition());
  assertEquals(expectedValue, result);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:24,代码来源:VarintReaderTest.java

示例3: testReadVarintFlaky

import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException; //导入依赖的package包/类
private static void testReadVarintFlaky(VarintReader reader, boolean removeMask, byte[] data,
    int expectedLength, long expectedValue) throws IOException, InterruptedException {
  ExtractorInput input = new FakeExtractorInput.Builder()
      .setData(data)
      .setSimulateUnknownLength(true)
      .setSimulateIOErrors(true)
      .setSimulatePartialReads(true)
      .build();
  long result = -1;
  while (result == -1) {
    try {
      result = reader.readUnsignedVarint(input, false, removeMask, 8);
      if (result == C.RESULT_END_OF_INPUT || result == C.RESULT_MAX_LENGTH_EXCEEDED) {
        // Unexpected.
        fail();
      }
    } catch (SimulatedIOException e) {
      // Expected.
    }
  }
  assertThat(input.getPosition()).isEqualTo(expectedLength);
  assertThat(result).isEqualTo(expectedValue);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:24,代码来源:VarintReaderTest.java

示例4: sniffTestData

import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException; //导入依赖的package包/类
public static boolean sniffTestData(Extractor extractor, FakeExtractorInput input)
    throws IOException, InterruptedException {
  while (true) {
    try {
      return extractor.sniff(input);
    } catch (SimulatedIOException e) {
      // Ignore.
    }
  }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:11,代码来源:TestUtil.java

示例5: consumeTestData

import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException; //导入依赖的package包/类
private static void consumeTestData(Extractor extractor, FakeExtractorInput input, long timeUs,
    FakeExtractorOutput output, boolean retryFromStartIfLive)
    throws IOException, InterruptedException {
  extractor.seek(input.getPosition(), timeUs);
  PositionHolder seekPositionHolder = new PositionHolder();
  int readResult = Extractor.RESULT_CONTINUE;
  while (readResult != Extractor.RESULT_END_OF_INPUT) {
    try {
      // Extractor.read should not read seekPositionHolder.position. Set it to a value that's
      // likely to cause test failure if a read does occur.
      seekPositionHolder.position = Long.MIN_VALUE;
      readResult = extractor.read(input, seekPositionHolder);
      if (readResult == Extractor.RESULT_SEEK) {
        long seekPosition = seekPositionHolder.position;
        Assertions.checkState(0 <= seekPosition && seekPosition <= Integer.MAX_VALUE);
        input.setPosition((int) seekPosition);
      }
    } catch (SimulatedIOException e) {
      if (!retryFromStartIfLive) {
        continue;
      }
      boolean isOnDemand = input.getLength() != C.LENGTH_UNSET
          || (output.seekMap != null && output.seekMap.getDurationUs() != C.TIME_UNSET);
      if (isOnDemand) {
        continue;
      }
      input.setPosition(0);
      for (int i = 0; i < output.numberOfTracks; i++) {
        output.trackOutputs.valueAt(i).clear();
      }
      extractor.seek(0, 0);
    }
  }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:35,代码来源:TestUtil.java

示例6: populatePageHeader

import com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException; //导入依赖的package包/类
private boolean populatePageHeader(FakeExtractorInput input, OggPageHeader header,
    boolean quite) throws IOException, InterruptedException {
  while (true) {
    try {
      return header.populate(input, quite);
    } catch (SimulatedIOException e) {
      // ignored
    }
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:11,代码来源:OggPageHeaderTest.java


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