Decouple dummySurface lifespan from codec lifespans

I don't think there's any particular reason for releasing
dummySurface when we release the codec. It seems to make
more sense to decouple the two, and treat a dummySurface as
a resource that should be released on reset.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=217711788
This commit is contained in:
olly 2018-10-18 09:17:28 -07:00 committed by Oliver Woodman
parent 80e9c84a9e
commit 3805717026

View file

@ -381,6 +381,21 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
}
@Override
protected void onReset() {
try {
super.onReset();
} finally {
if (dummySurface != null) {
if (surface == dummySurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
}
}
}
@Override
public void handleMessage(int messageType, @Nullable Object message) throws ExoPlaybackException {
if (messageType == C.MSG_SET_SURFACE) {
@ -509,13 +524,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
super.releaseCodec();
} finally {
buffersInCodecCount = 0;
if (dummySurface != null) {
if (surface == dummySurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
}
}
}