Temporarily disable codec reuse

There are multiple subtle issues with the current implementation:

1. setOperatingRate can cause a codec initialization even if the
   renderer is disabled. This is not supposed to happen.
2. If the codec is released whilst the renderer is disabled, the
   renderer can instantiate a new codec using the old format when
   it's enabled again, only to immediately have to reconfigure or
   release it if the actual format to be played is different.
3. Codec reuse does not take into account renderer configuration.
   The specific case where this is problematic is if the video
   renderer is re-enabled with a different tunneling session id.
   The reused codec is then not configured correctly.

Also moved availableCodecInfos reset into releaseCodec for sanity.

Issue: #2826

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217924592
This commit is contained in:
olly 2018-10-19 13:47:45 -07:00 committed by Oliver Woodman
parent bb5a9ef8ad
commit f3b4575436
2 changed files with 2 additions and 15 deletions

View File

@ -558,18 +558,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
@Override
protected void onDisabled() {
if (drmSession != null || pendingDrmSession != null) {
// TODO: Do something better with this case.
onReset();
} else {
flushOrReleaseCodec();
}
}
@Override
protected void onReset() {
format = null;
availableCodecInfos = null;
try {
releaseCodec();
} finally {
@ -591,6 +580,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
protected void releaseCodec() {
availableCodecInfos = null;
codecHotswapDeadlineMs = C.TIME_UNSET;
resetInputBuffer();
resetOutputBuffer();
@ -1307,7 +1297,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
* @throws ExoPlaybackException If an error occurs releasing or initializing a codec.
*/
private void reinitializeCodec(boolean release) throws ExoPlaybackException {
availableCodecInfos = null;
if (codecReceivedBuffers) {
// Signal end of stream and wait for any final output buffers before re-initialization.
codecReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM;

View File

@ -436,9 +436,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
setOutputSurfaceV23(codec, surface);
} else {
releaseCodec();
if (state == STATE_ENABLED || state == STATE_STARTED) {
maybeInitCodec();
}
maybeInitCodec();
}
}
if (surface != null && surface != dummySurface) {