mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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 waitingForKeys;
|
||||||
private boolean waitingForFirstSyncSample;
|
private boolean waitingForFirstSyncSample;
|
||||||
private boolean waitingForFirstSampleInFormat;
|
private boolean waitingForFirstSampleInFormat;
|
||||||
|
private boolean skipMediaCodecStopOnRelease;
|
||||||
|
|
||||||
protected DecoderCounters decoderCounters;
|
protected DecoderCounters decoderCounters;
|
||||||
|
|
||||||
|
|
@ -433,6 +434,22 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||||
this.renderTimeLimitMs = renderTimeLimitMs;
|
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
|
@Override
|
||||||
public final int supportsMixedMimeTypeAdaptation() {
|
public final int supportsMixedMimeTypeAdaptation() {
|
||||||
return ADAPTIVE_NOT_SEAMLESS;
|
return ADAPTIVE_NOT_SEAMLESS;
|
||||||
|
|
@ -636,7 +653,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||||
if (codec != null) {
|
if (codec != null) {
|
||||||
decoderCounters.decoderReleaseCount++;
|
decoderCounters.decoderReleaseCount++;
|
||||||
try {
|
try {
|
||||||
|
if (!skipMediaCodecStopOnRelease) {
|
||||||
codec.stop();
|
codec.stop();
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
codec.release();
|
codec.release();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue