mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Replace hash by Object reference for uids.
There is the small (but unlikely) chance that the uids clash because the Objects have the same hash code. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198855724
This commit is contained in:
parent
b6113763b4
commit
bf3c943b23
1 changed files with 9 additions and 13 deletions
|
|
@ -19,7 +19,6 @@ import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.SparseIntArray;
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
|
|
@ -34,6 +33,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -664,7 +664,7 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
||||||
/* package */ static final class MediaSourceHolder implements Comparable<MediaSourceHolder> {
|
/* package */ static final class MediaSourceHolder implements Comparable<MediaSourceHolder> {
|
||||||
|
|
||||||
public final MediaSource mediaSource;
|
public final MediaSource mediaSource;
|
||||||
public final int uid;
|
public final Object uid;
|
||||||
|
|
||||||
public DeferredTimeline timeline;
|
public DeferredTimeline timeline;
|
||||||
public int childIndex;
|
public int childIndex;
|
||||||
|
|
@ -679,7 +679,7 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
||||||
this.mediaSource = mediaSource;
|
this.mediaSource = mediaSource;
|
||||||
this.timeline = new DeferredTimeline();
|
this.timeline = new DeferredTimeline();
|
||||||
this.activeMediaPeriods = new ArrayList<>();
|
this.activeMediaPeriods = new ArrayList<>();
|
||||||
this.uid = System.identityHashCode(this);
|
this.uid = new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(int childIndex, int firstWindowIndexInChild, int firstPeriodIndexInChild) {
|
public void reset(int childIndex, int firstWindowIndexInChild, int firstPeriodIndexInChild) {
|
||||||
|
|
@ -738,8 +738,8 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
||||||
private final int[] firstPeriodInChildIndices;
|
private final int[] firstPeriodInChildIndices;
|
||||||
private final int[] firstWindowInChildIndices;
|
private final int[] firstWindowInChildIndices;
|
||||||
private final Timeline[] timelines;
|
private final Timeline[] timelines;
|
||||||
private final int[] uids;
|
private final Object[] uids;
|
||||||
private final SparseIntArray childIndexByUid;
|
private final HashMap<Object, Integer> childIndexByUid;
|
||||||
|
|
||||||
public ConcatenatedTimeline(
|
public ConcatenatedTimeline(
|
||||||
Collection<MediaSourceHolder> mediaSourceHolders,
|
Collection<MediaSourceHolder> mediaSourceHolders,
|
||||||
|
|
@ -754,8 +754,8 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
||||||
firstPeriodInChildIndices = new int[childCount];
|
firstPeriodInChildIndices = new int[childCount];
|
||||||
firstWindowInChildIndices = new int[childCount];
|
firstWindowInChildIndices = new int[childCount];
|
||||||
timelines = new Timeline[childCount];
|
timelines = new Timeline[childCount];
|
||||||
uids = new int[childCount];
|
uids = new Object[childCount];
|
||||||
childIndexByUid = new SparseIntArray();
|
childIndexByUid = new HashMap<>();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) {
|
for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) {
|
||||||
timelines[index] = mediaSourceHolder.timeline;
|
timelines[index] = mediaSourceHolder.timeline;
|
||||||
|
|
@ -778,11 +778,8 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getChildIndexByChildUid(Object childUid) {
|
protected int getChildIndexByChildUid(Object childUid) {
|
||||||
if (!(childUid instanceof Integer)) {
|
Integer index = childIndexByUid.get(childUid);
|
||||||
return C.INDEX_UNSET;
|
return index == null ? C.INDEX_UNSET : index;
|
||||||
}
|
|
||||||
int index = childIndexByUid.get((int) childUid, -1);
|
|
||||||
return index == -1 ? C.INDEX_UNSET : index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -814,7 +811,6 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
||||||
public int getPeriodCount() {
|
public int getPeriodCount() {
|
||||||
return periodCount;
|
return periodCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue