Skip to content

Commit

Permalink
Temporarily disable codec reuse
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ojw28 committed Oct 24, 2018
1 parent bb5a9ef commit f3b4575
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,7 @@ public final void setOperatingRate(float operatingRate) throws ExoPlaybackExcept

@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 {
Expand All @@ -591,6 +580,7 @@ protected void onReset() {
}

protected void releaseCodec() {
availableCodecInfos = null;
codecHotswapDeadlineMs = C.TIME_UNSET;
resetInputBuffer();
resetOutputBuffer();
Expand Down Expand Up @@ -1307,7 +1297,6 @@ private void updateCodecOperatingRate() throws ExoPlaybackException {
* @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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,7 @@ private void setSurface(Surface surface) throws ExoPlaybackException {
setOutputSurfaceV23(codec, surface);
} else {
releaseCodec();
if (state == STATE_ENABLED || state == STATE_STARTED) {
maybeInitCodec();
}
maybeInitCodec();
}
}
if (surface != null && surface != dummySurface) {
Expand Down

0 comments on commit f3b4575

Please sign in to comment.