mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
Add customization option to disable same-release-time skipping
We have the optimization to skip buffers if the release time is exactly the same as the one for the previous buffer. This makes sense under the assumption that these buffers get released to a visible Surface and will be ignored anyway. However, it's also helpful to provide a customization option to not do this for cases where the outputting MediaCodecAdapter is not directly talking to a visible Surface or for tests where we can't fully control the vsync timing of the Surface and want to ensure we output all samples that are meant to be shown. PiperOrigin-RevId: 545906113
This commit is contained in:
parent
5050171ff6
commit
c66adfeaaf
1 changed files with 10 additions and 1 deletions
|
|
@ -1287,7 +1287,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
if (Util.SDK_INT >= 21) {
|
||||
// Let the underlying framework time the release.
|
||||
if (earlyUs < 50000) {
|
||||
if (adjustedReleaseTimeNs == lastFrameReleaseTimeNs) {
|
||||
if (shouldSkipBuffersWithIdenticalReleaseTime()
|
||||
&& adjustedReleaseTimeNs == lastFrameReleaseTimeNs) {
|
||||
// This frame should be displayed on the same vsync with the previous released frame. We
|
||||
// are likely rendering frames at a rate higher than the screen refresh rate. Skip
|
||||
// this buffer so that it's returned to MediaCodec sooner otherwise MediaCodec may not
|
||||
|
|
@ -1443,6 +1444,14 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||
return isBufferVeryLate(earlyUs) && !isLastBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether to skip buffers that have an identical release time as the previous released
|
||||
* buffer.
|
||||
*/
|
||||
protected boolean shouldSkipBuffersWithIdenticalReleaseTime() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether to force rendering an output buffer.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue