Program: 110362
Project: 110362
Buggy source:
@Override public void selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  int[] streamChildIndices=new int[selections.length];
  int[] selectionChildIndices=new int[selections.length];
  for (int i=0; i < selections.length; i++) {
    streamChildIndices[i]=streams[i] == null ? -1 : streamWrapperIndices.get(streams[i]);
    selectionChildIndices[i]=-1;
    if (selections[i] != null) {
      TrackGroup trackGroup=selections[i].getTrackGroup();
      for (int j=0; j < sampleStreamWrappers.length; j++) {
        if (sampleStreamWrappers[j].getTrackGroups().indexOf(trackGroup) != -1) {
          selectionChildIndices[i]=j;
          break;
        }
      }
    }
  }
  boolean selectedNewTracks=false;
  streamWrapperIndices.clear();
  SampleStream[] childStreams=new SampleStream[selections.length];
  TrackSelection[] childSelections=new TrackSelection[selections.length];
  ArrayList<HlsSampleStreamWrapper> enabledSampleStreamWrapperList=new ArrayList<>(sampleStreamWrappers.length);
  for (int i=0; i < sampleStreamWrappers.length; i++) {
    for (int j=0; j < selections.length; j++) {
      childStreams[j]=streamChildIndices[j] == i ? streams[j] : null;
      childSelections[j]=selectionChildIndices[j] == i ? selections[j] : null;
    }
    selectedNewTracks|=sampleStreamWrappers[i].selectTracks(childSelections,mayRetainStreamFlags,childStreams,streamResetFlags,!seenFirstTrackSelection);
    boolean wrapperEnabled=false;
    for (int j=0; j < selections.length; j++) {
      if (selectionChildIndices[j] == i) {
        streams[j]=childStreams[j];
        if (childStreams[j] != null) {
          wrapperEnabled=true;
          streamWrapperIndices.put(childStreams[j],i);
        }
      }
    }
    if (wrapperEnabled) {
      enabledSampleStreamWrapperList.add(sampleStreamWrappers[i]);
    }
  }
  enabledSampleStreamWrappers=new HlsSampleStreamWrapper[enabledSampleStreamWrapperList.size()];
  enabledSampleStreamWrapperList.toArray(enabledSampleStreamWrappers);
  sequenceableLoader=new CompositeSequenceableLoader(enabledSampleStreamWrappers);
  if (seenFirstTrackSelection && selectedNewTracks) {
    seekToUs(positionUs);
    for (int i=0; i < selections.length; i++) {
      if (streams[i] != null) {
        streamResetFlags[i]=true;
      }
    }
  }
  seenFirstTrackSelection=true;
}

Fixed version (ground truth):
@Override public long selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  int[] streamChildIndices=new int[selections.length];
  int[] selectionChildIndices=new int[selections.length];
  for (int i=0; i < selections.length; i++) {
    streamChildIndices[i]=streams[i] == null ? -1 : streamWrapperIndices.get(streams[i]);
    selectionChildIndices[i]=-1;
    if (selections[i] != null) {
      TrackGroup trackGroup=selections[i].getTrackGroup();
      for (int j=0; j < sampleStreamWrappers.length; j++) {
        if (sampleStreamWrappers[j].getTrackGroups().indexOf(trackGroup) != -1) {
          selectionChildIndices[i]=j;
          break;
        }
      }
    }
  }
  boolean selectedNewTracks=false;
  streamWrapperIndices.clear();
  SampleStream[] childStreams=new SampleStream[selections.length];
  TrackSelection[] childSelections=new TrackSelection[selections.length];
  ArrayList<HlsSampleStreamWrapper> enabledSampleStreamWrapperList=new ArrayList<>(sampleStreamWrappers.length);
  for (int i=0; i < sampleStreamWrappers.length; i++) {
    for (int j=0; j < selections.length; j++) {
      childStreams[j]=streamChildIndices[j] == i ? streams[j] : null;
      childSelections[j]=selectionChildIndices[j] == i ? selections[j] : null;
    }
    selectedNewTracks|=sampleStreamWrappers[i].selectTracks(childSelections,mayRetainStreamFlags,childStreams,streamResetFlags,!seenFirstTrackSelection);
    boolean wrapperEnabled=false;
    for (int j=0; j < selections.length; j++) {
      if (selectionChildIndices[j] == i) {
        streams[j]=childStreams[j];
        if (childStreams[j] != null) {
          wrapperEnabled=true;
          streamWrapperIndices.put(childStreams[j],i);
        }
      }
    }
    if (wrapperEnabled) {
      enabledSampleStreamWrapperList.add(sampleStreamWrappers[i]);
    }
  }
  enabledSampleStreamWrappers=new HlsSampleStreamWrapper[enabledSampleStreamWrapperList.size()];
  enabledSampleStreamWrapperList.toArray(enabledSampleStreamWrappers);
  sequenceableLoader=new CompositeSequenceableLoader(enabledSampleStreamWrappers);
  if (seenFirstTrackSelection && selectedNewTracks) {
    seekToUs(positionUs);
    for (int i=0; i < selections.length; i++) {
      if (streams[i] != null) {
        streamResetFlags[i]=true;
      }
    }
  }
  seenFirstTrackSelection=true;
  return positionUs;
}