mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Experimental API to skip MediaCodec.stop()
Add experimental API on MediaCodecRenderer to skip calling MediaCodec.stop() before the call to MediaCodec.release(). PiperOrigin-RevId: 278621032
This commit is contained in:
parent
c8170e18d0
commit
7cc3943b4f
1 changed files with 20 additions and 1 deletions
|
|
@ -372,6 +372,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
private boolean waitingForKeys;
|
||||
private boolean waitingForFirstSyncSample;
|
||||
private boolean waitingForFirstSampleInFormat;
|
||||
private boolean skipMediaCodecStopOnRelease;
|
||||
|
||||
protected DecoderCounters decoderCounters;
|
||||
|
||||
|
|
@ -433,6 +434,22 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
this.renderTimeLimitMs = renderTimeLimitMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip calling {@link MediaCodec#stop()} when the underlying MediaCodec is going to be released.
|
||||
*
|
||||
* <p>By default, when the MediaCodecRenderer is releasing the underlying {@link MediaCodec}, it
|
||||
* first calls {@link MediaCodec#stop()} and then calls {@link MediaCodec#release()}. If this
|
||||
* feature is enabled, the MediaCodecRenderer will skip the call to {@link MediaCodec#stop()}.
|
||||
*
|
||||
* <p>This method is experimental, and will be renamed or removed in a future release. It should
|
||||
* only be called before the renderer is used.
|
||||
*
|
||||
* @param enabled enable or disable the feature.
|
||||
*/
|
||||
public void experimental_setSkipMediaCodecStopOnRelease(boolean enabled) {
|
||||
skipMediaCodecStopOnRelease = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int supportsMixedMimeTypeAdaptation() {
|
||||
return ADAPTIVE_NOT_SEAMLESS;
|
||||
|
|
@ -636,7 +653,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
if (codec != null) {
|
||||
decoderCounters.decoderReleaseCount++;
|
||||
try {
|
||||
codec.stop();
|
||||
if (!skipMediaCodecStopOnRelease) {
|
||||
codec.stop();
|
||||
}
|
||||
} finally {
|
||||
codec.release();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue