Skip to content

Commit

Permalink
Fix non-inclusive language in class names.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmsch authored and icbaker committed Apr 7, 2022
1 parent 8038a53 commit 33373d0
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private boolean codecHandlesHdr10PlusOutOfBandMetadata;

@Nullable private Surface surface;
@Nullable private DummySurface dummySurface;
@Nullable private PlaceholderSurface placeholderSurface;
private boolean haveReportedFirstFrameRenderedForCurrentSurface;
private @C.VideoScalingMode int scalingMode;
private boolean renderedFirstFrameAfterReset;
Expand Down Expand Up @@ -512,7 +512,7 @@ protected void onPositionReset(long positionUs, boolean joining) throws ExoPlayb
public boolean isReady() {
if (super.isReady()
&& (renderedFirstFrameAfterReset
|| (dummySurface != null && surface == dummySurface)
|| (placeholderSurface != null && surface == placeholderSurface)
|| getCodec() == null
|| tunneling)) {
// Ready. If we were joining then we've now joined, so clear the joining deadline.
Expand Down Expand Up @@ -564,14 +564,14 @@ protected void onDisabled() {
}
}

@TargetApi(17) // Needed for dummySurface usage. dummySurface is always null on API level 16.
@TargetApi(17) // Needed for placeholderSurface usage, as it is always null on API level 16.
@Override
protected void onReset() {
try {
super.onReset();
} finally {
if (dummySurface != null) {
releaseDummySurface();
if (placeholderSurface != null) {
releasePlaceholderSurface();
}
}
}
Expand Down Expand Up @@ -621,14 +621,14 @@ private void setOutput(@Nullable Object output) throws ExoPlaybackException {
@Nullable Surface surface = output instanceof Surface ? (Surface) output : null;

if (surface == null) {
// Use a dummy surface if possible.
if (dummySurface != null) {
surface = dummySurface;
// Use a placeholder surface if possible.
if (placeholderSurface != null) {
surface = placeholderSurface;
} else {
MediaCodecInfo codecInfo = getCodecInfo();
if (codecInfo != null && shouldUseDummySurface(codecInfo)) {
dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
surface = dummySurface;
placeholderSurface = PlaceholderSurface.newInstanceV17(context, codecInfo.secure);
surface = placeholderSurface;
}
}
}
Expand All @@ -649,7 +649,7 @@ private void setOutput(@Nullable Object output) throws ExoPlaybackException {
maybeInitCodecOrBypass();
}
}
if (surface != null && surface != dummySurface) {
if (surface != null && surface != placeholderSurface) {
// If we know the video size, report it again immediately.
maybeRenotifyVideoSizeChanged();
// We haven't rendered to the new surface yet.
Expand All @@ -662,7 +662,7 @@ private void setOutput(@Nullable Object output) throws ExoPlaybackException {
clearReportedVideoSize();
clearRenderedFirstFrame();
}
} else if (surface != null && surface != dummySurface) {
} else if (surface != null && surface != placeholderSurface) {
// The surface is set and unchanged. If we know the video size and/or have already rendered to
// the surface, report these again immediately.
maybeRenotifyVideoSizeChanged();
Expand All @@ -681,16 +681,16 @@ protected boolean getCodecNeedsEosPropagation() {
return tunneling && Util.SDK_INT < 23;
}

@TargetApi(17) // Needed for dummySurface usage. dummySurface is always null on API level 16.
@TargetApi(17) // Needed for placeHolderSurface usage, as it is always null on API level 16.
@Override
protected MediaCodecAdapter.Configuration getMediaCodecConfiguration(
MediaCodecInfo codecInfo,
Format format,
@Nullable MediaCrypto crypto,
float codecOperatingRate) {
if (dummySurface != null && dummySurface.secure != codecInfo.secure) {
if (placeholderSurface != null && placeholderSurface.secure != codecInfo.secure) {
// We can't re-use the current DummySurface instance with the new decoder.
releaseDummySurface();
releasePlaceholderSurface();
}
String codecMimeType = codecInfo.codecMimeType;
codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
Expand All @@ -706,10 +706,10 @@ protected MediaCodecAdapter.Configuration getMediaCodecConfiguration(
if (!shouldUseDummySurface(codecInfo)) {
throw new IllegalStateException();
}
if (dummySurface == null) {
dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
if (placeholderSurface == null) {
placeholderSurface = PlaceholderSurface.newInstanceV17(context, codecInfo.secure);
}
surface = dummySurface;
surface = placeholderSurface;
}
return MediaCodecAdapter.Configuration.createForVideoDecoding(
codecInfo, mediaFormat, format, surface, crypto);
Expand Down Expand Up @@ -946,7 +946,7 @@ protected boolean processOutputBuffer(
earlyUs -= elapsedRealtimeNowUs - elapsedRealtimeUs;
}

if (surface == dummySurface) {
if (surface == placeholderSurface) {
// Skip frames in sync with playback, so we'll be at the right frame if the mode changes.
if (isBufferLate(earlyUs)) {
skipOutputBuffer(codec, bufferIndex, presentationTimeUs);
Expand Down Expand Up @@ -1256,16 +1256,16 @@ private boolean shouldUseDummySurface(MediaCodecInfo codecInfo) {
return Util.SDK_INT >= 23
&& !tunneling
&& !codecNeedsSetOutputSurfaceWorkaround(codecInfo.name)
&& (!codecInfo.secure || DummySurface.isSecureSupported(context));
&& (!codecInfo.secure || PlaceholderSurface.isSecureSupported(context));
}

@RequiresApi(17)
private void releaseDummySurface() {
if (surface == dummySurface) {
private void releasePlaceholderSurface() {
if (surface == placeholderSurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
placeholderSurface.release();
placeholderSurface = null;
}

private void setJoiningDeadlineMs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@
import com.google.android.exoplayer2.util.Util;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;

/** A dummy {@link Surface}. */
/** A placeholder {@link Surface}. */
@RequiresApi(17)
public final class DummySurface extends Surface {
public final class PlaceholderSurface extends Surface {

private static final String TAG = "DummySurface";
private static final String TAG = "PlaceholderSurface";

/** Whether the surface is secure. */
public final boolean secure;

private static @SecureMode int secureMode;
private static boolean secureModeInitialized;

private final DummySurfaceThread thread;
private final PlaceholderSurfaceThread thread;
private boolean threadReleased;

/**
* Returns whether the device supports secure dummy surfaces.
* Returns whether the device supports secure placeholder surfaces.
*
* @param context Any {@link Context}.
* @return Whether the device supports secure dummy surfaces.
* @return Whether the device supports secure placeholder surfaces.
*/
public static synchronized boolean isSecureSupported(Context context) {
if (!secureModeInitialized) {
Expand All @@ -65,8 +65,8 @@ public static synchronized boolean isSecureSupported(Context context) {
}

/**
* Returns a newly created dummy surface. The surface must be released by calling {@link #release}
* when it's no longer required.
* Returns a newly created placeholder surface. The surface must be released by calling {@link
* #release} when it's no longer required.
*
* <p>Must only be called if {@link Util#SDK_INT} is 17 or higher.
*
Expand All @@ -76,13 +76,14 @@ public static synchronized boolean isSecureSupported(Context context) {
* @throws IllegalStateException If a secure surface is requested on a device for which {@link
* #isSecureSupported(Context)} returns {@code false}.
*/
public static DummySurface newInstanceV17(Context context, boolean secure) {
public static PlaceholderSurface newInstanceV17(Context context, boolean secure) {
Assertions.checkState(!secure || isSecureSupported(context));
DummySurfaceThread thread = new DummySurfaceThread();
PlaceholderSurfaceThread thread = new PlaceholderSurfaceThread();
return thread.init(secure ? secureMode : SECURE_MODE_NONE);
}

private DummySurface(DummySurfaceThread thread, SurfaceTexture surfaceTexture, boolean secure) {
private PlaceholderSurface(
PlaceholderSurfaceThread thread, SurfaceTexture surfaceTexture, boolean secure) {
super(surfaceTexture);
this.thread = thread;
this.secure = secure;
Expand Down Expand Up @@ -119,7 +120,7 @@ public void release() {
}
}

private static class DummySurfaceThread extends HandlerThread implements Handler.Callback {
private static class PlaceholderSurfaceThread extends HandlerThread implements Handler.Callback {

private static final int MSG_INIT = 1;
private static final int MSG_RELEASE = 2;
Expand All @@ -128,13 +129,13 @@ private static class DummySurfaceThread extends HandlerThread implements Handler
private @MonotonicNonNull Handler handler;
@Nullable private Error initError;
@Nullable private RuntimeException initException;
@Nullable private DummySurface surface;
@Nullable private PlaceholderSurface surface;

public DummySurfaceThread() {
super("ExoPlayer:DummySurface");
public PlaceholderSurfaceThread() {
super("ExoPlayer:PlaceholderSurface");
}

public DummySurface init(@SecureMode int secureMode) {
public PlaceholderSurface init(@SecureMode int secureMode) {
start();
handler = new Handler(getLooper(), /* callback= */ this);
eglSurfaceTexture = new EGLSurfaceTexture(handler);
Expand Down Expand Up @@ -174,10 +175,10 @@ public boolean handleMessage(Message msg) {
try {
initInternal(/* secureMode= */ msg.arg1);
} catch (RuntimeException e) {
Log.e(TAG, "Failed to initialize dummy surface", e);
Log.e(TAG, "Failed to initialize placeholder surface", e);
initException = e;
} catch (Error e) {
Log.e(TAG, "Failed to initialize dummy surface", e);
Log.e(TAG, "Failed to initialize placeholder surface", e);
initError = e;
} finally {
synchronized (this) {
Expand All @@ -189,7 +190,7 @@ public boolean handleMessage(Message msg) {
try {
releaseInternal();
} catch (Throwable e) {
Log.e(TAG, "Failed to release dummy surface", e);
Log.e(TAG, "Failed to release placeholder surface", e);
} finally {
quit();
}
Expand All @@ -203,7 +204,7 @@ private void initInternal(@SecureMode int secureMode) {
Assertions.checkNotNull(eglSurfaceTexture);
eglSurfaceTexture.init(secureMode);
this.surface =
new DummySurface(
new PlaceholderSurface(
this, eglSurfaceTexture.getSurfaceTexture(), secureMode != SECURE_MODE_NONE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void onStarted() {
* @param surface The new {@link Surface}, or {@code null} if the renderer does not have one.
*/
public void onSurfaceChanged(@Nullable Surface surface) {
if (surface instanceof DummySurface) {
if (surface instanceof PlaceholderSurface) {
// We don't care about dummy surfaces for release timing, since they're not visible.
surface = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import android.net.Uri;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.upstream.DummyDataSource;
import com.google.android.exoplayer2.upstream.PlaceholderDataSource;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import org.junit.Test;
Expand All @@ -35,7 +35,7 @@ public void createProgressiveDownloader() throws Exception {
CacheDataSource.Factory cacheDataSourceFactory =
new CacheDataSource.Factory()
.setCache(Mockito.mock(Cache.class))
.setUpstreamDataSourceFactory(DummyDataSource.FACTORY);
.setUpstreamDataSourceFactory(PlaceholderDataSource.FACTORY);
DownloaderFactory factory =
new DefaultDownloaderFactory(cacheDataSourceFactory, /* executor= */ Runnable::run);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.google.android.exoplayer2.source.dash.manifest.RangedUri;
import com.google.android.exoplayer2.source.dash.manifest.Representation;
import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase;
import com.google.android.exoplayer2.upstream.DummyDataSource;
import com.google.android.exoplayer2.upstream.PlaceholderDataSource;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.common.collect.ImmutableList;
import java.util.Arrays;
Expand All @@ -43,28 +43,28 @@ public final class DashUtilTest {
@Test
public void loadDrmInitDataFromManifest() throws Exception {
Period period = newPeriod(newAdaptationSet(newRepresentation(newDrmInitData())));
Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
Format format = DashUtil.loadFormatWithDrmInitData(PlaceholderDataSource.INSTANCE, period);
assertThat(format.drmInitData).isEqualTo(newDrmInitData());
}

@Test
public void loadDrmInitDataMissing() throws Exception {
Period period = newPeriod(newAdaptationSet(newRepresentation(null /* no init data */)));
Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
Format format = DashUtil.loadFormatWithDrmInitData(PlaceholderDataSource.INSTANCE, period);
assertThat(format.drmInitData).isNull();
}

@Test
public void loadDrmInitDataNoRepresentations() throws Exception {
Period period = newPeriod(newAdaptationSet(/* no representation */ ));
Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
Format format = DashUtil.loadFormatWithDrmInitData(PlaceholderDataSource.INSTANCE, period);
assertThat(format).isNull();
}

@Test
public void loadDrmInitDataNoAdaptationSets() throws Exception {
Period period = newPeriod(/* no adaptation set */ );
Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
Format format = DashUtil.loadFormatWithDrmInitData(PlaceholderDataSource.INSTANCE, period);
assertThat(format).isNull();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import com.google.android.exoplayer2.testutil.FakeDataSource;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.DummyDataSource;
import com.google.android.exoplayer2.upstream.PlaceholderDataSource;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor;
Expand Down Expand Up @@ -86,7 +86,7 @@ public void createWithDefaultDownloaderFactory() {
CacheDataSource.Factory cacheDataSourceFactory =
new CacheDataSource.Factory()
.setCache(Mockito.mock(Cache.class))
.setUpstreamDataSourceFactory(DummyDataSource.FACTORY);
.setUpstreamDataSourceFactory(PlaceholderDataSource.FACTORY);
DownloaderFactory factory =
new DefaultDownloaderFactory(cacheDataSourceFactory, /* executor= */ Runnable::run);

Expand All @@ -96,7 +96,7 @@ public void createWithDefaultDownloaderFactory() {
.setMimeType(MimeTypes.APPLICATION_MPD)
.setStreamKeys(
Collections.singletonList(
new StreamKey(/* groupIndex= */ 0, /* trackIndex= */ 0)))
new StreamKey(/* groupIndex= */ 0, /* streamIndex= */ 0)))
.build());
assertThat(downloader).isInstanceOf(DashDownloader.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import java.io.IOException;

/** A DataSource which provides no data. {@link #open(DataSpec)} throws {@link IOException}. */
public final class DummyDataSource implements DataSource {
public final class PlaceholderDataSource implements DataSource {

public static final DummyDataSource INSTANCE = new DummyDataSource();
public static final PlaceholderDataSource INSTANCE = new PlaceholderDataSource();

/** A factory that produces {@link DummyDataSource}. */
public static final Factory FACTORY = DummyDataSource::new;
/** A factory that produces {@link PlaceholderDataSource}. */
public static final Factory FACTORY = PlaceholderDataSource::new;

private DummyDataSource() {}
private PlaceholderDataSource() {}

@Override
public void addTransferListener(TransferListener transferListener) {
Expand All @@ -36,7 +36,7 @@ public void addTransferListener(TransferListener transferListener) {

@Override
public long open(DataSpec dataSpec) throws IOException {
throw new IOException("DummyDataSource cannot be opened");
throw new IOException("PlaceholderDataSource cannot be opened");
}

@Override
Expand Down
Loading

0 comments on commit 33373d0

Please sign in to comment.