mirror of
https://github.com/androidx/media.git
synced 2025-05-15 19:49:50 +08:00
Add a test for SampleQueue capacity increases
Also remove redundant line PiperOrigin-RevId: 283956203
This commit is contained in:
parent
9376479553
commit
96ea436759
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
|
||||
|
||||
import android.os.Looper;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.FormatHolder;
|
||||
@ -49,7 +50,7 @@ public class SampleQueue implements TrackOutput {
|
||||
|
||||
public static final int ADVANCE_FAILED = -1;
|
||||
|
||||
private static final int SAMPLE_CAPACITY_INCREMENT = 1000;
|
||||
@VisibleForTesting /* package */ static final int SAMPLE_CAPACITY_INCREMENT = 1000;
|
||||
|
||||
private final SampleDataQueue sampleDataQueue;
|
||||
private final SampleExtrasHolder extrasHolder;
|
||||
@ -652,7 +653,6 @@ public class SampleQueue implements TrackOutput {
|
||||
formats = newFormats;
|
||||
sourceIds = newSourceIds;
|
||||
relativeFirstIndex = 0;
|
||||
length = capacity;
|
||||
capacity = newCapacity;
|
||||
}
|
||||
}
|
||||
|
@ -157,6 +157,34 @@ public final class SampleQueueTest {
|
||||
inputBuffer = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCapacityIncreases() {
|
||||
int numberOfSamplesToInput = 3 * SampleQueue.SAMPLE_CAPACITY_INCREMENT + 1;
|
||||
sampleQueue.format(FORMAT_1);
|
||||
sampleQueue.sampleData(
|
||||
new ParsableByteArray(numberOfSamplesToInput), /* length= */ numberOfSamplesToInput);
|
||||
for (int i = 0; i < numberOfSamplesToInput; i++) {
|
||||
sampleQueue.sampleMetadata(
|
||||
/* timeUs= */ i * 1000,
|
||||
/* flags= */ C.BUFFER_FLAG_KEY_FRAME,
|
||||
/* size= */ 1,
|
||||
/* offset= */ numberOfSamplesToInput - i - 1,
|
||||
/* cryptoData= */ null);
|
||||
}
|
||||
|
||||
assertReadFormat(/* formatRequired= */ false, FORMAT_1);
|
||||
for (int i = 0; i < numberOfSamplesToInput; i++) {
|
||||
assertReadSample(
|
||||
/* timeUs= */ i * 1000,
|
||||
/* isKeyFrame= */ true,
|
||||
/* isEncrypted= */ false,
|
||||
/* sampleData= */ new byte[1],
|
||||
/* offset= */ 0,
|
||||
/* length= */ 1);
|
||||
}
|
||||
assertReadNothing(/* formatRequired= */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResetReleasesAllocations() {
|
||||
writeTestData();
|
||||
|
Loading…
x
Reference in New Issue
Block a user