Program: 110357
Project: 110357
Buggy source:
@Override public void selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  Assertions.checkState(prepared);
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) {
      int track=((SampleStreamImpl)streams[i]).track;
      Assertions.checkState(trackEnabledStates[track]);
      enabledTrackCount--;
      trackEnabledStates[track]=false;
      sampleQueues[track].disable();
      streams[i]=null;
    }
  }
  boolean selectedNewTracks=false;
  for (int i=0; i < selections.length; i++) {
    if (streams[i] == null && selections[i] != null) {
      TrackSelection selection=selections[i];
      Assertions.checkState(selection.length() == 1);
      Assertions.checkState(selection.getIndexInTrackGroup(0) == 0);
      int track=tracks.indexOf(selection.getTrackGroup());
      Assertions.checkState(!trackEnabledStates[track]);
      enabledTrackCount++;
      trackEnabledStates[track]=true;
      streams[i]=new SampleStreamImpl(track);
      streamResetFlags[i]=true;
      selectedNewTracks=true;
    }
  }
  if (!seenFirstTrackSelection) {
    for (int i=0; i < sampleQueues.length; i++) {
      if (!trackEnabledStates[i]) {
        sampleQueues[i].disable();
      }
    }
  }
  if (enabledTrackCount == 0) {
    notifyReset=false;
    if (loader.isLoading()) {
      loader.cancelLoading();
    }
  }
 else   if (seenFirstTrackSelection ? selectedNewTracks : positionUs != 0) {
    seekToUs(positionUs);
    for (int i=0; i < streams.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){
  Assertions.checkState(prepared);
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) {
      int track=((SampleStreamImpl)streams[i]).track;
      Assertions.checkState(trackEnabledStates[track]);
      enabledTrackCount--;
      trackEnabledStates[track]=false;
      sampleQueues[track].disable();
      streams[i]=null;
    }
  }
  boolean selectedNewTracks=false;
  for (int i=0; i < selections.length; i++) {
    if (streams[i] == null && selections[i] != null) {
      TrackSelection selection=selections[i];
      Assertions.checkState(selection.length() == 1);
      Assertions.checkState(selection.getIndexInTrackGroup(0) == 0);
      int track=tracks.indexOf(selection.getTrackGroup());
      Assertions.checkState(!trackEnabledStates[track]);
      enabledTrackCount++;
      trackEnabledStates[track]=true;
      streams[i]=new SampleStreamImpl(track);
      streamResetFlags[i]=true;
      selectedNewTracks=true;
    }
  }
  if (!seenFirstTrackSelection) {
    for (int i=0; i < sampleQueues.length; i++) {
      if (!trackEnabledStates[i]) {
        sampleQueues[i].disable();
      }
    }
  }
  if (enabledTrackCount == 0) {
    notifyReset=false;
    if (loader.isLoading()) {
      loader.cancelLoading();
    }
  }
 else   if (seenFirstTrackSelection ? selectedNewTracks : positionUs != 0) {
    positionUs=seekToUs(positionUs);
    for (int i=0; i < streams.length; i++) {
      if (streams[i] != null) {
        streamResetFlags[i]=true;
      }
    }
  }
  seenFirstTrackSelection=true;
  return positionUs;
}