mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add a test for SampleQueue capacity increases
Also remove redundant line PiperOrigin-RevId: 283956203
This commit is contained in:
parent
9376479553
commit
96ea436759
2 changed files with 30 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
|
||||||
|
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.FormatHolder;
|
import com.google.android.exoplayer2.FormatHolder;
|
||||||
|
|
@ -49,7 +50,7 @@ public class SampleQueue implements TrackOutput {
|
||||||
|
|
||||||
public static final int ADVANCE_FAILED = -1;
|
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 SampleDataQueue sampleDataQueue;
|
||||||
private final SampleExtrasHolder extrasHolder;
|
private final SampleExtrasHolder extrasHolder;
|
||||||
|
|
@ -652,7 +653,6 @@ public class SampleQueue implements TrackOutput {
|
||||||
formats = newFormats;
|
formats = newFormats;
|
||||||
sourceIds = newSourceIds;
|
sourceIds = newSourceIds;
|
||||||
relativeFirstIndex = 0;
|
relativeFirstIndex = 0;
|
||||||
length = capacity;
|
|
||||||
capacity = newCapacity;
|
capacity = newCapacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,34 @@ public final class SampleQueueTest {
|
||||||
inputBuffer = null;
|
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
|
@Test
|
||||||
public void testResetReleasesAllocations() {
|
public void testResetReleasesAllocations() {
|
||||||
writeTestData();
|
writeTestData();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue