mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Reset release control from video sink when enabled
PiperOrigin-RevId: 643950097
This commit is contained in:
parent
aeb8fd134b
commit
eedfb9960e
4 changed files with 13 additions and 9 deletions
|
|
@ -567,7 +567,7 @@ public final class CompositingVideoSinkProvider implements VideoSinkProvider, Vi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush(boolean resetPosition) {
|
||||||
if (isInitialized()) {
|
if (isInitialized()) {
|
||||||
videoFrameProcessor.flush();
|
videoFrameProcessor.flush();
|
||||||
}
|
}
|
||||||
|
|
@ -575,6 +575,9 @@ public final class CompositingVideoSinkProvider implements VideoSinkProvider, Vi
|
||||||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
lastBufferPresentationTimeUs = C.TIME_UNSET;
|
lastBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
CompositingVideoSinkProvider.this.flush();
|
CompositingVideoSinkProvider.this.flush();
|
||||||
|
if (resetPosition) {
|
||||||
|
videoFrameReleaseControl.reset();
|
||||||
|
}
|
||||||
// Don't change input stream offset or reset the pending input stream offset change so that
|
// Don't change input stream offset or reset the pending input stream offset change so that
|
||||||
// it's announced with the next input frame.
|
// it's announced with the next input frame.
|
||||||
// Don't reset pendingInputStreamBufferPresentationTimeUs because it's not guaranteed to
|
// Don't reset pendingInputStreamBufferPresentationTimeUs because it's not guaranteed to
|
||||||
|
|
|
||||||
|
|
@ -714,16 +714,16 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
|
||||||
@Override
|
@Override
|
||||||
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||||
if (videoSink != null) {
|
if (videoSink != null) {
|
||||||
// When this renderer doesn't own the VideoSink, it's possible that the VideoSink is already
|
|
||||||
// initialized by another renderer, before this renderer is enabled.
|
|
||||||
// Flush the video sink first to ensure it stops reading textures that will be owned by
|
// Flush the video sink first to ensure it stops reading textures that will be owned by
|
||||||
// MediaCodec once the codec is flushed.
|
// MediaCodec once the codec is flushed.
|
||||||
videoSink.flush();
|
videoSink.flush(/* resetPosition= */ true);
|
||||||
videoSink.setStreamOffsetAndAdjustmentUs(
|
videoSink.setStreamOffsetAndAdjustmentUs(
|
||||||
getOutputStreamOffsetUs(), getBufferTimestampAdjustmentUs());
|
getOutputStreamOffsetUs(), getBufferTimestampAdjustmentUs());
|
||||||
}
|
}
|
||||||
super.onPositionReset(positionUs, joining);
|
super.onPositionReset(positionUs, joining);
|
||||||
videoFrameReleaseControl.reset();
|
if (videoSink == null) {
|
||||||
|
videoFrameReleaseControl.reset();
|
||||||
|
}
|
||||||
if (joining) {
|
if (joining) {
|
||||||
// Don't render next frame immediately to let the codec catch up with the playback position
|
// Don't render next frame immediately to let the codec catch up with the playback position
|
||||||
// first. This prevents a stuttering effect caused by showing the first frame and then
|
// first. This prevents a stuttering effect caused by showing the first frame and then
|
||||||
|
|
@ -1624,7 +1624,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
|
||||||
}
|
}
|
||||||
flushOrReinitializeCodec();
|
flushOrReinitializeCodec();
|
||||||
if (videoSink != null) {
|
if (videoSink != null) {
|
||||||
videoSink.flush();
|
videoSink.flush(/* resetPosition= */ false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,8 +141,10 @@ public interface VideoSink {
|
||||||
* Flushes the video sink.
|
* Flushes the video sink.
|
||||||
*
|
*
|
||||||
* <p>After calling this method, any frames stored inside the video sink are discarded.
|
* <p>After calling this method, any frames stored inside the video sink are discarded.
|
||||||
|
*
|
||||||
|
* @param resetPosition Whether to reset the current position.
|
||||||
*/
|
*/
|
||||||
void flush();
|
void flush(boolean resetPosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the video sink is able to immediately render media from the current position.
|
* Returns whether the video sink is able to immediately render media from the current position.
|
||||||
|
|
|
||||||
|
|
@ -375,10 +375,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||||
videoSink.flush();
|
videoSink.flush(/* resetPosition= */ true);
|
||||||
super.onPositionReset(positionUs, joining);
|
super.onPositionReset(positionUs, joining);
|
||||||
timestampIterator = createTimestampIterator(positionUs);
|
timestampIterator = createTimestampIterator(positionUs);
|
||||||
videoFrameReleaseControl.reset();
|
|
||||||
if (joining) {
|
if (joining) {
|
||||||
videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false);
|
videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue