Commit 047e0eb6 by olly Committed by Oliver Woodman

Renames to prepare for upcoming media buffer changes

Currently, media is discarded from DefaultTrackOutput
and SampleMetadataQueue as soon as it's been read. In
upcoming changes we'll decouple discard and read. This
will make it possible to retain already-read media in
these buffer classes, and allow the read position to
be moved backward as far as media is retained. This is
important for fixing an edge case around 608/EMSG
tracks, and could also underpin future features like
allowing retaining of X-seconds past media in the
buffer.

This change renames some variables and methods to
prepare for the upcoming changes. read/write indices
are renamed to start/end. The upcoming changes will
add a read index that's between the two. isEmpty is
inverted and renamed to hasNextSample, since it will
be possible to not have a next sample (because the
read index == end index) but for the buffer to not
be empty (because start index < read index).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158409630
parent b7b0fef6
......@@ -180,10 +180,10 @@ public final class DefaultTrackOutput implements TrackOutput {
}
/**
* Returns whether the buffer is empty.
* Returns whether a sample is available to be read.
*/
public boolean isEmpty() {
return metadataQueue.isEmpty();
public boolean hasNextSample() {
return metadataQueue.hasNextSample();
}
/**
......
......@@ -323,7 +323,7 @@ import java.io.IOException;
// SampleStream methods.
/* package */ boolean isReady(int track) {
return loadingFinished || (!isPendingReset() && !sampleQueues.valueAt(track).isEmpty());
return loadingFinished || (!isPendingReset() && sampleQueues.valueAt(track).hasNextSample());
}
/* package */ void maybeThrowError() throws IOException {
......
......@@ -228,7 +228,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
@Override
public boolean isReady() {
return loadingFinished || (!isPendingReset() && !primarySampleQueue.isEmpty());
return loadingFinished || (!isPendingReset() && primarySampleQueue.hasNextSample());
}
@Override
......@@ -451,7 +451,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
@Override
public boolean isReady() {
return loadingFinished || (!isPendingReset() && !sampleQueue.isEmpty());
return loadingFinished || (!isPendingReset() && sampleQueue.hasNextSample());
}
@Override
......
......@@ -282,7 +282,7 @@ import java.util.LinkedList;
// SampleStream implementation.
/* package */ boolean isReady(int group) {
return loadingFinished || (!isPendingReset() && !sampleQueues.valueAt(group).isEmpty());
return loadingFinished || (!isPendingReset() && sampleQueues.valueAt(group).hasNextSample());
}
/* package */ void maybeThrowError() throws IOException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment