Commit 0978227a by olly Committed by Oliver Woodman

Create a new CodecCounters on enable

If the same instance is reset then rapidly re-enabling the
renderer after disabling it can prevent an application from
reading the final values at the time when the renderer was
disabled. Hence we now instantiate a new CodecCounters each
time. This is needed to migrate DashTest to V2.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124721106
parent 7ae9bf40
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package com.google.android.exoplayer.demo; package com.google.android.exoplayer.demo;
import com.google.android.exoplayer.CodecCounters;
import com.google.android.exoplayer.DefaultTrackSelector; import com.google.android.exoplayer.DefaultTrackSelector;
import com.google.android.exoplayer.DefaultTrackSelector.TrackInfo; import com.google.android.exoplayer.DefaultTrackSelector.TrackInfo;
import com.google.android.exoplayer.ExoPlaybackException; import com.google.android.exoplayer.ExoPlaybackException;
...@@ -133,6 +134,11 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -133,6 +134,11 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
// SimpleExoPlayer.DebugListener // SimpleExoPlayer.DebugListener
@Override @Override
public void onAudioEnabled(CodecCounters counters) {
Log.d(TAG, "audioEnabled [" + getSessionTimeString() + "]");
}
@Override
public void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs, public void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs) { long initializationDurationMs) {
Log.d(TAG, "audioDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]"); Log.d(TAG, "audioDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]");
...@@ -145,6 +151,16 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -145,6 +151,16 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
} }
@Override @Override
public void onAudioDisabled(CodecCounters counters) {
Log.d(TAG, "audioDisabled [" + getSessionTimeString() + "]");
}
@Override
public void onVideoEnabled(CodecCounters counters) {
Log.d(TAG, "videoEnabled [" + getSessionTimeString() + "]");
}
@Override
public void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs, public void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs) { long initializationDurationMs) {
Log.d(TAG, "videoDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]"); Log.d(TAG, "videoDecoderInitialized [" + getSessionTimeString() + ", " + decoderName + "]");
...@@ -157,6 +173,11 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -157,6 +173,11 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
} }
@Override @Override
public void onVideoDisabled(CodecCounters counters) {
Log.d(TAG, "videoDisabled [" + getSessionTimeString() + "]");
}
@Override
public void onDroppedFrames(int count, long elapsed) { public void onDroppedFrames(int count, long elapsed) {
Log.d(TAG, "droppedFrames [" + getSessionTimeString() + ", " + count + "]"); Log.d(TAG, "droppedFrames [" + getSessionTimeString() + ", " + count + "]");
} }
......
...@@ -55,14 +55,13 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer { ...@@ -55,14 +55,13 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
private static final int NUM_BUFFERS = 16; private static final int NUM_BUFFERS = 16;
private static final int INITIAL_INPUT_BUFFER_SIZE = 768 * 1024; // Value based on cs/SoftVpx.cpp. private static final int INITIAL_INPUT_BUFFER_SIZE = 768 * 1024; // Value based on cs/SoftVpx.cpp.
public final CodecCounters codecCounters = new CodecCounters();
private final boolean scaleToFit; private final boolean scaleToFit;
private final long allowedJoiningTimeMs; private final long allowedJoiningTimeMs;
private final int maxDroppedFrameCountToNotify; private final int maxDroppedFrameCountToNotify;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final FormatHolder formatHolder; private final FormatHolder formatHolder;
private CodecCounters codecCounters;
private Format format; private Format format;
private VpxDecoder decoder; private VpxDecoder decoder;
private DecoderInputBuffer inputBuffer; private DecoderInputBuffer inputBuffer;
...@@ -213,7 +212,7 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer { ...@@ -213,7 +212,7 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
// and that's also late. Else we'll render what we have. // and that's also late. Else we'll render what we have.
if ((joiningDeadlineMs != -1 && outputBuffer.timestampUs < positionUs - 30000) if ((joiningDeadlineMs != -1 && outputBuffer.timestampUs < positionUs - 30000)
|| (nextOutputBuffer != null && !nextOutputBuffer.isEndOfStream() || (nextOutputBuffer != null && !nextOutputBuffer.isEndOfStream()
&& nextOutputBuffer.timestampUs < positionUs)) { && nextOutputBuffer.timestampUs < positionUs)) {
codecCounters.droppedOutputBufferCount++; codecCounters.droppedOutputBufferCount++;
droppedFrameCount++; droppedFrameCount++;
consecutiveDroppedFrameCount++; consecutiveDroppedFrameCount++;
...@@ -349,7 +348,7 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer { ...@@ -349,7 +348,7 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
@Override @Override
protected void onEnabled(boolean joining) throws ExoPlaybackException { protected void onEnabled(boolean joining) throws ExoPlaybackException {
codecCounters.reset(); codecCounters = new CodecCounters();
eventDispatcher.enabled(codecCounters); eventDispatcher.enabled(codecCounters);
} }
...@@ -390,8 +389,8 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer { ...@@ -390,8 +389,8 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
codecCounters.codecReleaseCount++; codecCounters.codecReleaseCount++;
} }
} finally { } finally {
super.onDisabled(); codecCounters.ensureUpdated();
eventDispatcher.disabled(); eventDispatcher.disabled(codecCounters);
} }
} }
......
...@@ -29,7 +29,8 @@ public interface AudioTrackRendererEventListener { ...@@ -29,7 +29,8 @@ public interface AudioTrackRendererEventListener {
/** /**
* Invoked when the renderer is enabled. * Invoked when the renderer is enabled.
* *
* @param counters {@link CodecCounters} that will be updated by the renderer. * @param counters {@link CodecCounters} that will be updated by the renderer for as long as it
* remains enabled.
*/ */
void onAudioEnabled(CodecCounters counters); void onAudioEnabled(CodecCounters counters);
...@@ -64,8 +65,10 @@ public interface AudioTrackRendererEventListener { ...@@ -64,8 +65,10 @@ public interface AudioTrackRendererEventListener {
/** /**
* Invoked when the renderer is disabled. * Invoked when the renderer is disabled.
*
* @param counters {@link CodecCounters} that were updated by the renderer.
*/ */
void onAudioDisabled(); void onAudioDisabled(CodecCounters counters);
/** /**
* Dispatches events to a {@link AudioTrackRendererEventListener}. * Dispatches events to a {@link AudioTrackRendererEventListener}.
...@@ -127,12 +130,12 @@ public interface AudioTrackRendererEventListener { ...@@ -127,12 +130,12 @@ public interface AudioTrackRendererEventListener {
} }
} }
public void disabled() { public void disabled(final CodecCounters counters) {
if (listener != null) { if (listener != null) {
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
listener.onAudioDisabled(); listener.onAudioDisabled(counters);
} }
}); });
} }
......
...@@ -71,16 +71,19 @@ public final class CodecCounters { ...@@ -71,16 +71,19 @@ public final class CodecCounters {
} }
/** /**
* Resets all counters to zero. * Merges the counts from {@code other} into this instance.
*
* @param other The {@link CodecCounters} to merge into this instance.
*/ */
public void reset() { public void merge(CodecCounters other) {
codecInitCount = 0; codecInitCount += other.codecInitCount;
codecReleaseCount = 0; codecReleaseCount += other.codecReleaseCount;
inputBufferCount = 0; inputBufferCount += other.inputBufferCount;
renderedOutputBufferCount = 0; renderedOutputBufferCount += other.renderedOutputBufferCount;
skippedOutputBufferCount = 0; skippedOutputBufferCount += other.skippedOutputBufferCount;
droppedOutputBufferCount = 0; droppedOutputBufferCount += other.droppedOutputBufferCount;
maxConsecutiveDroppedOutputBufferCount = 0; maxConsecutiveDroppedOutputBufferCount = Math.max(maxConsecutiveDroppedOutputBufferCount,
other.maxConsecutiveDroppedOutputBufferCount);
} }
} }
...@@ -156,9 +156,9 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem ...@@ -156,9 +156,9 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
// Note: We assume support for unknown sampleRate and channelCount. // Note: We assume support for unknown sampleRate and channelCount.
boolean decoderCapable = Util.SDK_INT < 21 boolean decoderCapable = Util.SDK_INT < 21
|| ((format.sampleRate == Format.NO_VALUE || ((format.sampleRate == Format.NO_VALUE
|| decoderInfo.isAudioSampleRateSupportedV21(format.sampleRate)) || decoderInfo.isAudioSampleRateSupportedV21(format.sampleRate))
&& (format.channelCount == Format.NO_VALUE && (format.channelCount == Format.NO_VALUE
|| decoderInfo.isAudioChannelCountSupportedV21(format.channelCount))); || decoderInfo.isAudioChannelCountSupportedV21(format.channelCount)));
int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES; int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
return ADAPTIVE_NOT_SEAMLESS | formatSupport; return ADAPTIVE_NOT_SEAMLESS | formatSupport;
} }
...@@ -255,7 +255,6 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem ...@@ -255,7 +255,6 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
@Override @Override
protected void onEnabled(boolean joining) throws ExoPlaybackException { protected void onEnabled(boolean joining) throws ExoPlaybackException {
super.onEnabled(joining); super.onEnabled(joining);
codecCounters.reset();
eventDispatcher.enabled(codecCounters); eventDispatcher.enabled(codecCounters);
} }
...@@ -281,12 +280,16 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem ...@@ -281,12 +280,16 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
@Override @Override
protected void onDisabled() { protected void onDisabled() {
eventDispatcher.disabled();
audioSessionId = AudioTrack.SESSION_ID_NOT_SET; audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
try { try {
audioTrack.release(); audioTrack.release();
} finally { } finally {
super.onDisabled(); try {
super.onDisabled();
} finally {
codecCounters.ensureUpdated();
eventDispatcher.disabled(codecCounters);
}
} }
} }
......
...@@ -147,8 +147,6 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -147,8 +147,6 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
*/ */
private static final int REINITIALIZATION_STATE_WAIT_END_OF_STREAM = 2; private static final int REINITIALIZATION_STATE_WAIT_END_OF_STREAM = 2;
public final CodecCounters codecCounters;
private final MediaCodecSelector mediaCodecSelector; private final MediaCodecSelector mediaCodecSelector;
private final DrmSessionManager drmSessionManager; private final DrmSessionManager drmSessionManager;
private final boolean playClearSamplesWithoutKeys; private final boolean playClearSamplesWithoutKeys;
...@@ -182,6 +180,8 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -182,6 +180,8 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
private boolean outputStreamEnded; private boolean outputStreamEnded;
private boolean waitingForKeys; private boolean waitingForKeys;
protected CodecCounters codecCounters;
/** /**
* @param mediaCodecSelector A decoder selector. * @param mediaCodecSelector A decoder selector.
* @param drmSessionManager For use with encrypted media. May be null if support for encrypted * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
...@@ -198,7 +198,6 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -198,7 +198,6 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
this.mediaCodecSelector = Assertions.checkNotNull(mediaCodecSelector); this.mediaCodecSelector = Assertions.checkNotNull(mediaCodecSelector);
this.drmSessionManager = drmSessionManager; this.drmSessionManager = drmSessionManager;
this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys; this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
codecCounters = new CodecCounters();
buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED); buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
formatHolder = new FormatHolder(); formatHolder = new FormatHolder();
decodeOnlyPresentationTimestamps = new ArrayList<>(); decodeOnlyPresentationTimestamps = new ArrayList<>();
...@@ -356,6 +355,11 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -356,6 +355,11 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
} }
@Override @Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
codecCounters = new CodecCounters();
}
@Override
protected void onReset(long positionUs, boolean joining) throws ExoPlaybackException { protected void onReset(long positionUs, boolean joining) throws ExoPlaybackException {
inputStreamEnded = false; inputStreamEnded = false;
outputStreamEnded = false; outputStreamEnded = false;
...@@ -370,13 +374,9 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -370,13 +374,9 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
try { try {
releaseCodec(); releaseCodec();
} finally { } finally {
try { if (drmSession != null) {
if (drmSession != null) { drmSessionManager.releaseSession(drmSession);
drmSessionManager.releaseSession(drmSession); drmSession = null;
drmSession = null;
}
} finally {
super.onDisabled();
} }
} }
} }
...@@ -907,9 +907,9 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -907,9 +907,9 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
private static boolean codecNeedsFlushWorkaround(String name) { private static boolean codecNeedsFlushWorkaround(String name) {
return Util.SDK_INT < 18 return Util.SDK_INT < 18
|| (Util.SDK_INT == 18 || (Util.SDK_INT == 18
&& ("OMX.SEC.avc.dec".equals(name) || "OMX.SEC.avc.dec.secure".equals(name))) && ("OMX.SEC.avc.dec".equals(name) || "OMX.SEC.avc.dec.secure".equals(name)))
|| (Util.SDK_INT == 19 && Util.MODEL.startsWith("SM-G800") || (Util.SDK_INT == 19 && Util.MODEL.startsWith("SM-G800")
&& ("OMX.Exynos.avc.dec".equals(name) || "OMX.Exynos.avc.dec.secure".equals(name))); && ("OMX.Exynos.avc.dec".equals(name) || "OMX.Exynos.avc.dec.secure".equals(name)));
} }
/** /**
......
...@@ -204,7 +204,6 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -204,7 +204,6 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
@Override @Override
protected void onEnabled(boolean joining) throws ExoPlaybackException { protected void onEnabled(boolean joining) throws ExoPlaybackException {
super.onEnabled(joining); super.onEnabled(joining);
codecCounters.reset();
eventDispatcher.enabled(codecCounters); eventDispatcher.enabled(codecCounters);
frameReleaseTimeHelper.enable(); frameReleaseTimeHelper.enable();
} }
...@@ -271,7 +270,6 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -271,7 +270,6 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
@Override @Override
protected void onDisabled() { protected void onDisabled() {
eventDispatcher.disabled();
currentWidth = -1; currentWidth = -1;
currentHeight = -1; currentHeight = -1;
currentPixelWidthHeightRatio = -1; currentPixelWidthHeightRatio = -1;
...@@ -280,7 +278,12 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -280,7 +278,12 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
lastReportedHeight = -1; lastReportedHeight = -1;
lastReportedPixelWidthHeightRatio = -1; lastReportedPixelWidthHeightRatio = -1;
frameReleaseTimeHelper.disable(); frameReleaseTimeHelper.disable();
super.onDisabled(); try {
super.onDisabled();
} finally {
codecCounters.ensureUpdated();
eventDispatcher.disabled(codecCounters);
}
} }
@Override @Override
...@@ -378,7 +381,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { ...@@ -378,7 +381,7 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer {
Format oldFormat, Format newFormat) { Format oldFormat, Format newFormat) {
return newFormat.sampleMimeType.equals(oldFormat.sampleMimeType) return newFormat.sampleMimeType.equals(oldFormat.sampleMimeType)
&& (codecIsAdaptive && (codecIsAdaptive
|| (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height)); || (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height));
} }
@Override @Override
......
...@@ -61,12 +61,16 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -61,12 +61,16 @@ public final class SimpleExoPlayer implements ExoPlayer {
* A listener for debugging information. * A listener for debugging information.
*/ */
public interface DebugListener { public interface DebugListener {
void onAudioEnabled(CodecCounters counters);
void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs, void onAudioDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs); long initializationDurationMs);
void onAudioFormatChanged(Format format); void onAudioFormatChanged(Format format);
void onAudioDisabled(CodecCounters counters);
void onVideoEnabled(CodecCounters counters);
void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs, void onVideoDecoderInitialized(String decoderName, long elapsedRealtimeMs,
long initializationDurationMs); long initializationDurationMs);
void onVideoFormatChanged(Format format); void onVideoFormatChanged(Format format);
void onVideoDisabled(CodecCounters counters);
void onDroppedFrames(int count, long elapsed); void onDroppedFrames(int count, long elapsed);
void onAudioTrackUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs); void onAudioTrackUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs);
} }
...@@ -469,6 +473,9 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -469,6 +473,9 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override @Override
public void onVideoEnabled(CodecCounters counters) { public void onVideoEnabled(CodecCounters counters) {
videoCodecCounters = counters; videoCodecCounters = counters;
if (debugListener != null) {
debugListener.onVideoEnabled(counters);
}
} }
@Override @Override
...@@ -512,14 +519,12 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -512,14 +519,12 @@ public final class SimpleExoPlayer implements ExoPlayer {
} }
@Override @Override
public void onVideoDisabled() { public void onVideoDisabled(CodecCounters counters) {
videoCodecCounters = null; if (debugListener != null) {
if (videoFormat != null) { debugListener.onVideoDisabled(counters);
videoFormat = null;
if (debugListener != null) {
debugListener.onVideoFormatChanged(null);
}
} }
videoFormat = null;
videoCodecCounters = null;
} }
// AudioTrackRendererEventListener implementation // AudioTrackRendererEventListener implementation
...@@ -527,6 +532,9 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -527,6 +532,9 @@ public final class SimpleExoPlayer implements ExoPlayer {
@Override @Override
public void onAudioEnabled(CodecCounters counters) { public void onAudioEnabled(CodecCounters counters) {
audioCodecCounters = counters; audioCodecCounters = counters;
if (debugListener != null) {
debugListener.onAudioEnabled(counters);
}
} }
@Override @Override
...@@ -555,14 +563,12 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -555,14 +563,12 @@ public final class SimpleExoPlayer implements ExoPlayer {
} }
@Override @Override
public void onAudioDisabled() { public void onAudioDisabled(CodecCounters counters) {
audioCodecCounters = null; if (debugListener != null) {
if (audioFormat != null) { debugListener.onAudioDisabled(counters);
audioFormat = null;
if (debugListener != null) {
debugListener.onAudioFormatChanged(null);
}
} }
audioFormat = null;
audioCodecCounters = null;
} }
// TextRenderer implementation // TextRenderer implementation
......
...@@ -30,7 +30,8 @@ public interface VideoTrackRendererEventListener { ...@@ -30,7 +30,8 @@ public interface VideoTrackRendererEventListener {
/** /**
* Invoked when the renderer is enabled. * Invoked when the renderer is enabled.
* *
* @param counters {@link CodecCounters} that will be updated by the renderer. * @param counters {@link CodecCounters} that will be updated by the renderer for as long as it
* remains enabled.
*/ */
void onVideoEnabled(CodecCounters counters); void onVideoEnabled(CodecCounters counters);
...@@ -94,8 +95,10 @@ public interface VideoTrackRendererEventListener { ...@@ -94,8 +95,10 @@ public interface VideoTrackRendererEventListener {
/** /**
* Invoked when the renderer is disabled. * Invoked when the renderer is disabled.
*
* @param counters {@link CodecCounters} that were updated by the renderer.
*/ */
void onVideoDisabled(); void onVideoDisabled(CodecCounters counters);
/** /**
* Dispatches events to a {@link VideoTrackRendererEventListener}. * Dispatches events to a {@link VideoTrackRendererEventListener}.
...@@ -180,12 +183,12 @@ public interface VideoTrackRendererEventListener { ...@@ -180,12 +183,12 @@ public interface VideoTrackRendererEventListener {
} }
} }
public void disabled() { public void disabled(final CodecCounters counters) {
if (listener != null) { if (listener != null) {
handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
listener.onVideoDisabled(); listener.onVideoDisabled(counters);
} }
}); });
} }
......
...@@ -39,11 +39,10 @@ import android.os.SystemClock; ...@@ -39,11 +39,10 @@ import android.os.SystemClock;
*/ */
public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements MediaClock { public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements MediaClock {
public final CodecCounters codecCounters = new CodecCounters();
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final FormatHolder formatHolder; private final FormatHolder formatHolder;
private CodecCounters codecCounters;
private Format inputFormat; private Format inputFormat;
private SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, private SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer,
? extends AudioDecoderException> decoder; ? extends AudioDecoderException> decoder;
...@@ -292,7 +291,7 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements ...@@ -292,7 +291,7 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
@Override @Override
protected void onEnabled(boolean joining) throws ExoPlaybackException { protected void onEnabled(boolean joining) throws ExoPlaybackException {
codecCounters.reset(); codecCounters = new CodecCounters();
eventDispatcher.enabled(codecCounters); eventDispatcher.enabled(codecCounters);
} }
...@@ -320,7 +319,6 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements ...@@ -320,7 +319,6 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
@Override @Override
protected void onDisabled() { protected void onDisabled() {
eventDispatcher.disabled();
inputBuffer = null; inputBuffer = null;
outputBuffer = null; outputBuffer = null;
inputFormat = null; inputFormat = null;
...@@ -333,7 +331,8 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements ...@@ -333,7 +331,8 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
} }
audioTrack.release(); audioTrack.release();
} finally { } finally {
super.onDisabled(); codecCounters.ensureUpdated();
eventDispatcher.disabled(codecCounters);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment