mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
Make ExoPlayer systrace consistent.
Plus remove some unused util methods + make a few warnings go away. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123888046
This commit is contained in:
parent
5cde3aa314
commit
14cb76a112
@ -27,6 +27,7 @@ import com.google.android.exoplayer.TrackStream;
|
||||
import com.google.android.exoplayer.VideoTrackRendererEventListener;
|
||||
import com.google.android.exoplayer.VideoTrackRendererEventListener.EventDispatcher;
|
||||
import com.google.android.exoplayer.util.MimeTypes;
|
||||
import com.google.android.exoplayer.util.TraceUtil;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@ -152,15 +153,19 @@ public final class LibvpxVideoTrackRenderer extends TrackRenderer {
|
||||
if (decoder == null) {
|
||||
// If we don't have a decoder yet, we need to instantiate one.
|
||||
long codecInitializingTimestamp = SystemClock.elapsedRealtime();
|
||||
TraceUtil.beginSection("createVpxDecoder");
|
||||
decoder = new VpxDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE);
|
||||
decoder.setOutputMode(outputMode);
|
||||
TraceUtil.endSection();
|
||||
long codecInitializedTimestamp = SystemClock.elapsedRealtime();
|
||||
eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
|
||||
codecInitializedTimestamp - codecInitializingTimestamp);
|
||||
codecCounters.codecInitCount++;
|
||||
}
|
||||
TraceUtil.beginSection("drainAndFeed");
|
||||
while (drainOutputBuffer(positionUs)) {}
|
||||
while (feedInputBuffer()) {}
|
||||
TraceUtil.endSection();
|
||||
} catch (VpxDecoderException e) {
|
||||
throw ExoPlaybackException.createForRenderer(e, getIndex());
|
||||
}
|
||||
|
@ -306,13 +306,13 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
||||
codecNeedsMonoChannelCountWorkaround = codecNeedsMonoChannelCountWorkaround(codecName, format);
|
||||
try {
|
||||
long codecInitializingTimestamp = SystemClock.elapsedRealtime();
|
||||
TraceUtil.beginSection("createByCodecName(" + codecName + ")");
|
||||
TraceUtil.beginSection("createCodec:" + codecName);
|
||||
codec = MediaCodec.createByCodecName(codecName);
|
||||
TraceUtil.endSection();
|
||||
TraceUtil.beginSection("configureCodec");
|
||||
configureCodec(codec, format, mediaCrypto);
|
||||
TraceUtil.endSection();
|
||||
TraceUtil.beginSection("codec.start()");
|
||||
TraceUtil.beginSection("startCodec");
|
||||
codec.start();
|
||||
TraceUtil.endSection();
|
||||
long codecInitializedTimestamp = SystemClock.elapsedRealtime();
|
||||
|
@ -28,6 +28,7 @@ import com.google.android.exoplayer.TrackRenderer;
|
||||
import com.google.android.exoplayer.TrackStream;
|
||||
import com.google.android.exoplayer.audio.AudioTrack;
|
||||
import com.google.android.exoplayer.util.MimeTypes;
|
||||
import com.google.android.exoplayer.util.TraceUtil;
|
||||
|
||||
import android.media.PlaybackParams;
|
||||
import android.os.Handler;
|
||||
@ -98,7 +99,9 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
|
||||
if (decoder == null) {
|
||||
try {
|
||||
long codecInitializingTimestamp = SystemClock.elapsedRealtime();
|
||||
TraceUtil.beginSection("createAudioDecoder");
|
||||
decoder = createDecoder(inputFormat);
|
||||
TraceUtil.endSection();
|
||||
long codecInitializedTimestamp = SystemClock.elapsedRealtime();
|
||||
eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
|
||||
codecInitializedTimestamp - codecInitializingTimestamp);
|
||||
@ -110,8 +113,10 @@ public abstract class AudioDecoderTrackRenderer extends TrackRenderer implements
|
||||
|
||||
// Rendering loop.
|
||||
try {
|
||||
TraceUtil.beginSection("drainAndFeed");
|
||||
while (drainOutputBuffer()) {}
|
||||
while (feedInputBuffer()) {}
|
||||
TraceUtil.endSection();
|
||||
} catch (AudioTrack.InitializationException | AudioTrack.WriteException
|
||||
| AudioDecoderException e) {
|
||||
throw ExoPlaybackException.createForRenderer(e, getIndex());
|
||||
|
@ -251,7 +251,7 @@ public final class Loader {
|
||||
try {
|
||||
executorThread = Thread.currentThread();
|
||||
if (!loadable.isLoadCanceled()) {
|
||||
TraceUtil.beginSection(loadable.getClass().getSimpleName() + ".load()");
|
||||
TraceUtil.beginSection("load:" + loadable.getClass().getSimpleName());
|
||||
try {
|
||||
loadable.load();
|
||||
} finally {
|
||||
|
@ -116,7 +116,7 @@ public final class UriUtil {
|
||||
return removeDotSegments(uri, baseLimit + refIndices[PATH], baseLimit + refIndices[QUERY]);
|
||||
}
|
||||
|
||||
if (refIndices[PATH] != refIndices[QUERY] && referenceUri.charAt(refIndices[PATH]) == '/') {
|
||||
if (referenceUri.charAt(refIndices[PATH]) == '/') {
|
||||
// The reference path is rooted. The target is the base scheme and authority (if any), plus
|
||||
// the reference.
|
||||
uri.append(baseUri, 0, baseIndices[PATH]).append(referenceUri);
|
||||
|
@ -20,10 +20,8 @@ import com.google.android.exoplayer.ExoPlayerLibraryInfo;
|
||||
import com.google.android.exoplayer.upstream.DataSource;
|
||||
import com.google.android.exoplayer.upstream.DataSpec;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@ -46,7 +44,6 @@ import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -118,17 +115,6 @@ public final class Util {
|
||||
|
||||
private Util() {}
|
||||
|
||||
/**
|
||||
* Returns whether the device is an AndroidTV.
|
||||
*
|
||||
* @param context A context.
|
||||
* @return True if the device is an AndroidTV. False otherwise.
|
||||
*/
|
||||
@SuppressLint("InlinedApi")
|
||||
public static boolean isAndroidTv(Context context) {
|
||||
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts microseconds to milliseconds (rounding down).
|
||||
*
|
||||
@ -213,21 +199,6 @@ public final class Util {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new single threaded scheduled executor whose thread has the specified name.
|
||||
*
|
||||
* @param threadName The name of the thread.
|
||||
* @return The executor.
|
||||
*/
|
||||
public static ScheduledExecutorService newSingleThreadScheduledExecutor(final String threadName) {
|
||||
return Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
return new Thread(r, threadName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a {@link DataSource}, suppressing any {@link IOException} that may occur.
|
||||
*
|
||||
@ -598,10 +569,10 @@ public final class Util {
|
||||
unexpectedEndOfInput.setAccessible(true);
|
||||
unexpectedEndOfInput.invoke(inputStream);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// The connection didn't ever have an input stream, or it was closed already.
|
||||
} catch (Exception e) {
|
||||
// Something went wrong. The device probably isn't using okhttp.
|
||||
// If an IOException then the connection didn't ever have an input stream, or it was closed
|
||||
// already. If another type of exception then something went wrong, most likely the device
|
||||
// isn't using okhttp.
|
||||
}
|
||||
}
|
||||
|
||||
@ -660,22 +631,6 @@ public final class Util {
|
||||
return ((long) topInteger << 32) | (bottomInteger & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hex string representation of the data provided.
|
||||
*
|
||||
* @param data The byte array containing the data to be turned into a hex string.
|
||||
* @param beginIndex The begin index, inclusive.
|
||||
* @param endIndex The end index, exclusive.
|
||||
* @return A string containing the hex representation of the data provided.
|
||||
*/
|
||||
public static String getHexStringFromBytes(byte[] data, int beginIndex, int endIndex) {
|
||||
StringBuilder dataStringBuilder = new StringBuilder(endIndex - beginIndex);
|
||||
for (int i = beginIndex; i < endIndex; i++) {
|
||||
dataStringBuilder.append(String.format(Locale.US, "%02X", data[i]));
|
||||
}
|
||||
return dataStringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a byte array containing values parsed from the hex string provided.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user