mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
PlaybackVideoGraphWrapper: simplify flushing logic
PiperOrigin-RevId: 685610127
This commit is contained in:
parent
7e023f915b
commit
7dbacdb011
1 changed files with 4 additions and 20 deletions
|
|
@ -436,9 +436,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
||||||
* taken approximately at the time the playback position was {@code positionUs}.
|
* taken approximately at the time the playback position was {@code positionUs}.
|
||||||
*/
|
*/
|
||||||
private void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
|
private void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
|
||||||
if (pendingFlushCount == 0) {
|
videoFrameRenderControl.render(positionUs, elapsedRealtimeUs);
|
||||||
videoFrameRenderControl.render(positionUs, elapsedRealtimeUs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flush() {
|
private void flush() {
|
||||||
|
|
@ -446,24 +444,10 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pendingFlushCount++;
|
pendingFlushCount++;
|
||||||
// Flush the render control now to ensure it has no data, eg calling isReady() must return false
|
|
||||||
// and render() should not render any frames.
|
|
||||||
videoFrameRenderControl.flush();
|
|
||||||
// Finish flushing after handling pending video graph callbacks to ensure video size changes
|
|
||||||
// reach the video render control.
|
|
||||||
checkStateNotNull(handler).post(this::flushInternal);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void flushInternal() {
|
|
||||||
pendingFlushCount--;
|
|
||||||
if (pendingFlushCount > 0) {
|
|
||||||
// Another flush has been issued.
|
|
||||||
return;
|
|
||||||
} else if (pendingFlushCount < 0) {
|
|
||||||
throw new IllegalStateException(String.valueOf(pendingFlushCount));
|
|
||||||
}
|
|
||||||
// Flush the render control again.
|
|
||||||
videoFrameRenderControl.flush();
|
videoFrameRenderControl.flush();
|
||||||
|
// Handle pending video graph callbacks to ensure video size changes reach the video render
|
||||||
|
// control.
|
||||||
|
checkStateNotNull(handler).post(() -> pendingFlushCount--);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVideoFrameMetadataListener(
|
private void setVideoFrameMetadataListener(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue