mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00
BaseRenderer: Add getStartPositionUs
This is useful for subclasses to easily query the point up to which they should only decode (but not render) content, rather than each subclass having to have its own startPositionUs and update it in onPositionReset. PiperOrigin-RevId: 320163677
This commit is contained in:
parent
61acd434f6
commit
01249bf1cd
@ -36,6 +36,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
|
|||||||
private SampleStream stream;
|
private SampleStream stream;
|
||||||
private Format[] streamFormats;
|
private Format[] streamFormats;
|
||||||
private long streamOffsetUs;
|
private long streamOffsetUs;
|
||||||
|
private long startPositionUs;
|
||||||
private long readingPositionUs;
|
private long readingPositionUs;
|
||||||
private boolean streamIsFinal;
|
private boolean streamIsFinal;
|
||||||
private boolean throwRendererExceptionIsExecuting;
|
private boolean throwRendererExceptionIsExecuting;
|
||||||
@ -89,6 +90,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
|
|||||||
Assertions.checkState(state == STATE_DISABLED);
|
Assertions.checkState(state == STATE_DISABLED);
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
state = STATE_ENABLED;
|
state = STATE_ENABLED;
|
||||||
|
startPositionUs = positionUs;
|
||||||
onEnabled(joining, mayRenderStartOfStream);
|
onEnabled(joining, mayRenderStartOfStream);
|
||||||
replaceStream(formats, stream, offsetUs);
|
replaceStream(formats, stream, offsetUs);
|
||||||
onPositionReset(positionUs, joining);
|
onPositionReset(positionUs, joining);
|
||||||
@ -146,6 +148,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
|
|||||||
@Override
|
@Override
|
||||||
public final void resetPosition(long positionUs) throws ExoPlaybackException {
|
public final void resetPosition(long positionUs) throws ExoPlaybackException {
|
||||||
streamIsFinal = false;
|
streamIsFinal = false;
|
||||||
|
startPositionUs = positionUs;
|
||||||
readingPositionUs = positionUs;
|
readingPositionUs = positionUs;
|
||||||
onPositionReset(positionUs, false);
|
onPositionReset(positionUs, false);
|
||||||
}
|
}
|
||||||
@ -282,6 +285,14 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
|
|||||||
|
|
||||||
// Methods to be called by subclasses.
|
// Methods to be called by subclasses.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the position passed to the most recent call to {@link #enable} or {@link
|
||||||
|
* #resetPosition}.
|
||||||
|
*/
|
||||||
|
protected final long getStartPositionUs() {
|
||||||
|
return startPositionUs;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a clear {@link FormatHolder}. */
|
/** Returns a clear {@link FormatHolder}. */
|
||||||
protected final FormatHolder getFormatHolder() {
|
protected final FormatHolder getFormatHolder() {
|
||||||
formatHolder.clear();
|
formatHolder.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user