mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +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
|
||||
public void flush() {
|
||||
public void flush(boolean resetPosition) {
|
||||
if (isInitialized()) {
|
||||
videoFrameProcessor.flush();
|
||||
}
|
||||
|
|
@ -575,6 +575,9 @@ public final class CompositingVideoSinkProvider implements VideoSinkProvider, Vi
|
|||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||
lastBufferPresentationTimeUs = C.TIME_UNSET;
|
||||
CompositingVideoSinkProvider.this.flush();
|
||||
if (resetPosition) {
|
||||
videoFrameReleaseControl.reset();
|
||||
}
|
||||
// Don't change input stream offset or reset the pending input stream offset change so that
|
||||
// it's announced with the next input frame.
|
||||
// Don't reset pendingInputStreamBufferPresentationTimeUs because it's not guaranteed to
|
||||
|
|
|
|||
|
|
@ -714,16 +714,16 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
|
|||
@Override
|
||||
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||
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
|
||||
// MediaCodec once the codec is flushed.
|
||||
videoSink.flush();
|
||||
videoSink.flush(/* resetPosition= */ true);
|
||||
videoSink.setStreamOffsetAndAdjustmentUs(
|
||||
getOutputStreamOffsetUs(), getBufferTimestampAdjustmentUs());
|
||||
}
|
||||
super.onPositionReset(positionUs, joining);
|
||||
videoFrameReleaseControl.reset();
|
||||
if (videoSink == null) {
|
||||
videoFrameReleaseControl.reset();
|
||||
}
|
||||
if (joining) {
|
||||
// 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
|
||||
|
|
@ -1624,7 +1624,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer
|
|||
}
|
||||
flushOrReinitializeCodec();
|
||||
if (videoSink != null) {
|
||||
videoSink.flush();
|
||||
videoSink.flush(/* resetPosition= */ false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,8 +141,10 @@ public interface VideoSink {
|
|||
* Flushes the video sink.
|
||||
*
|
||||
* <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.
|
||||
|
|
|
|||
|
|
@ -375,10 +375,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
|
||||
@Override
|
||||
protected void onPositionReset(long positionUs, boolean joining) throws ExoPlaybackException {
|
||||
videoSink.flush();
|
||||
videoSink.flush(/* resetPosition= */ true);
|
||||
super.onPositionReset(positionUs, joining);
|
||||
timestampIterator = createTimestampIterator(positionUs);
|
||||
videoFrameReleaseControl.reset();
|
||||
if (joining) {
|
||||
videoFrameReleaseControl.join(/* renderNextFrameImmediately= */ false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue