mirror of
https://github.com/samsonjs/media.git
synced 2026-04-23 14:15:48 +00:00
Add reset() to SampleQueue. Deprecate reset(boolean) and disable()
The deprecated methods will be removed as soon as HLS is migrated to use the new ones. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160827936
This commit is contained in:
parent
d733bb4101
commit
ad3d1e0cf2
4 changed files with 40 additions and 25 deletions
|
|
@ -93,10 +93,10 @@ public class SampleQueueTest extends TestCase {
|
|||
inputBuffer = null;
|
||||
}
|
||||
|
||||
public void testDisableReleasesAllocations() {
|
||||
public void testResetReleasesAllocations() {
|
||||
writeTestData();
|
||||
assertAllocationCount(10);
|
||||
sampleQueue.disable();
|
||||
sampleQueue.reset();
|
||||
assertAllocationCount(0);
|
||||
}
|
||||
|
||||
|
|
@ -545,8 +545,8 @@ public class SampleQueueTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts {@link SampleQueue#readData} is behaving correctly, given there are no samples
|
||||
* to read and the last format to be written to the sample queue is {@code endFormat}.
|
||||
* Asserts {@link SampleQueue#read} is behaving correctly, given there are no samples to read and
|
||||
* the last format to be written to the sample queue is {@code endFormat}.
|
||||
*
|
||||
* @param endFormat The last format to be written to the sample queue, or null of no format has
|
||||
* been written.
|
||||
|
|
@ -573,7 +573,7 @@ public class SampleQueueTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts {@link SampleQueue#readData} returns {@link C#RESULT_NOTHING_READ}.
|
||||
* Asserts {@link SampleQueue#read} returns {@link C#RESULT_NOTHING_READ}.
|
||||
*
|
||||
* @param formatRequired The value of {@code formatRequired} passed to readData.
|
||||
*/
|
||||
|
|
@ -589,7 +589,7 @@ public class SampleQueueTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts {@link SampleQueue#readData} returns {@link C#RESULT_BUFFER_READ} and that the
|
||||
* Asserts {@link SampleQueue#read} returns {@link C#RESULT_BUFFER_READ} and that the
|
||||
* {@link DecoderInputBuffer#isEndOfStream()} is set.
|
||||
*
|
||||
* @param formatRequired The value of {@code formatRequired} passed to readData.
|
||||
|
|
@ -608,8 +608,8 @@ public class SampleQueueTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts {@link SampleQueue#readData} returns {@link C#RESULT_FORMAT_READ} and that the
|
||||
* format holder is filled with a {@link Format} that equals {@code format}.
|
||||
* Asserts {@link SampleQueue#read} returns {@link C#RESULT_FORMAT_READ} and that the format
|
||||
* holder is filled with a {@link Format} that equals {@code format}.
|
||||
*
|
||||
* @param formatRequired The value of {@code formatRequired} passed to readData.
|
||||
* @param format The expected format.
|
||||
|
|
@ -626,8 +626,8 @@ public class SampleQueueTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts {@link SampleQueue#readData} returns {@link C#RESULT_BUFFER_READ} and that the
|
||||
* buffer is filled with the specified sample data.
|
||||
* Asserts {@link SampleQueue#read} returns {@link C#RESULT_BUFFER_READ} and that the buffer is
|
||||
* filled with the specified sample data.
|
||||
*
|
||||
* @param timeUs The expected buffer timestamp.
|
||||
* @param isKeyframe The expected keyframe flag.
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ import java.util.Arrays;
|
|||
public void release() {
|
||||
boolean releasedSynchronously = loader.release(this);
|
||||
if (prepared && !releasedSynchronously) {
|
||||
// Discard as much as we can synchronously. We only do this if we're prepared, since
|
||||
// otherwise sampleQueues may still be being modified by the loading thread.
|
||||
// Discard as much as we can synchronously. We only do this if we're prepared, since otherwise
|
||||
// sampleQueues may still be being modified by the loading thread.
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.discardToEnd();
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ import java.util.Arrays;
|
|||
public void onLoaderReleased() {
|
||||
extractorHolder.release();
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.reset(true);
|
||||
sampleQueue.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +227,15 @@ import java.util.Arrays;
|
|||
if (enabledTrackCount == 0) {
|
||||
notifyReset = false;
|
||||
if (loader.isLoading()) {
|
||||
// Discard as much as we can synchronously.
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.discardToEnd();
|
||||
}
|
||||
loader.cancelLoading();
|
||||
} else {
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.reset();
|
||||
}
|
||||
}
|
||||
} else if (seekRequired) {
|
||||
positionUs = seekToUs(positionUs);
|
||||
|
|
@ -327,7 +335,7 @@ import java.util.Arrays;
|
|||
loader.cancelLoading();
|
||||
} else {
|
||||
for (int i = 0; i < trackCount; i++) {
|
||||
sampleQueues[i].reset(trackEnabledStates[i]);
|
||||
sampleQueues[i].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -388,7 +396,7 @@ import java.util.Arrays;
|
|||
}
|
||||
copyLengthFromLoader(loadable);
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.reset(true);
|
||||
sampleQueue.reset();
|
||||
}
|
||||
if (enabledTrackCount > 0) {
|
||||
callback.onContinueLoadingRequested(this);
|
||||
|
|
@ -526,7 +534,7 @@ import java.util.Arrays;
|
|||
lastSeekPositionUs = 0;
|
||||
notifyReset = prepared;
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.reset(true);
|
||||
sampleQueue.reset();
|
||||
}
|
||||
loadable.setLoadPosition(0, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,9 +98,15 @@ public final class SampleQueue implements TrackOutput {
|
|||
|
||||
/**
|
||||
* Resets the output.
|
||||
*
|
||||
* @param enable Whether the output should be enabled. False if it should be disabled.
|
||||
*/
|
||||
public void reset() {
|
||||
reset(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #reset()}. Don't disable sample queues.
|
||||
*/
|
||||
@Deprecated
|
||||
public void reset(boolean enable) {
|
||||
int previousState = state.getAndSet(enable ? STATE_ENABLED : STATE_DISABLED);
|
||||
clearSampleData();
|
||||
|
|
@ -169,8 +175,9 @@ public final class SampleQueue implements TrackOutput {
|
|||
// Called by the consuming thread.
|
||||
|
||||
/**
|
||||
* Disables buffering of sample data and metadata.
|
||||
* @deprecated Don't disable sample queues.
|
||||
*/
|
||||
@Deprecated
|
||||
public void disable() {
|
||||
if (state.getAndSet(STATE_DISABLED) == STATE_ENABLED) {
|
||||
clearSampleData();
|
||||
|
|
|
|||
|
|
@ -203,9 +203,9 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
if (loader.isLoading()) {
|
||||
loader.cancelLoading();
|
||||
} else {
|
||||
primarySampleQueue.reset(true);
|
||||
primarySampleQueue.reset();
|
||||
for (SampleQueue embeddedSampleQueue : embeddedSampleQueues) {
|
||||
embeddedSampleQueue.reset(true);
|
||||
embeddedSampleQueue.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -229,9 +229,9 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
|
||||
@Override
|
||||
public void onLoaderReleased() {
|
||||
primarySampleQueue.reset(true);
|
||||
primarySampleQueue.reset();
|
||||
for (SampleQueue embeddedSampleQueue : embeddedSampleQueues) {
|
||||
embeddedSampleQueue.reset(true);
|
||||
embeddedSampleQueue.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,9 +295,9 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
loadable.startTimeUs, loadable.endTimeUs, elapsedRealtimeMs, loadDurationMs,
|
||||
loadable.bytesLoaded());
|
||||
if (!released) {
|
||||
primarySampleQueue.reset(true);
|
||||
primarySampleQueue.reset();
|
||||
for (SampleQueue embeddedSampleQueue : embeddedSampleQueues) {
|
||||
embeddedSampleQueue.reset(true);
|
||||
embeddedSampleQueue.reset();
|
||||
}
|
||||
callback.onContinueLoadingRequested(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue