Program: 110379
Project: 110379
Buggy source:
@Override public TrackStream[] selectTracks(List<TrackStream> oldStreams,List<TrackSelection> newSelections,long positionUs){
  Assertions.checkState(prepared);
  boolean tracksWereEnabled=enabledTrackCount > 0;
  for (int i=0; i < oldStreams.size(); i++) {
    int track=((TrackStreamImpl)oldStreams.get(i)).track;
    Assertions.checkState(trackEnabledStates[track]);
    enabledTrackCount--;
    trackEnabledStates[track]=false;
    sampleQueues[track].disable();
  }
  TrackStream[] newStreams=new TrackStream[newSelections.size()];
  for (int i=0; i < newStreams.length; i++) {
    TrackSelection selection=newSelections.get(i);
    Assertions.checkState(selection.length == 1);
    Assertions.checkState(selection.getTrack(0) == 0);
    int track=selection.group;
    Assertions.checkState(!trackEnabledStates[track]);
    enabledTrackCount++;
    trackEnabledStates[track]=true;
    newStreams[i]=new TrackStreamImpl(track);
  }
  if (!seenFirstTrackSelection) {
    for (int i=0; i < sampleQueues.length; i++) {
      if (!trackEnabledStates[i]) {
        sampleQueues[i].disable();
      }
    }
  }
  if (enabledTrackCount == 0) {
    if (tracksWereEnabled) {
      loadControl.unregister(this);
      loadCondition.close();
    }
    if (loader.isLoading()) {
      loader.cancelLoading();
    }
  }
 else {
    if (!tracksWereEnabled) {
      loadControl.register(this);
      loadCondition.open();
    }
    if (seenFirstTrackSelection ? newStreams.length > 0 : positionUs != 0) {
      seekToUs(positionUs);
    }
  }
  seenFirstTrackSelection=true;
  return newStreams;
}

Fixed version (ground truth):
@Override public TrackStream[] selectTracks(List<TrackStream> oldStreams,List<TrackSelection> newSelections,long positionUs){
  Assertions.checkState(prepared);
  boolean tracksWereEnabled=enabledTrackCount > 0;
  for (int i=0; i < oldStreams.size(); i++) {
    int track=((TrackStreamImpl)oldStreams.get(i)).track;
    Assertions.checkState(trackEnabledStates[track]);
    enabledTrackCount--;
    trackEnabledStates[track]=false;
    sampleQueues[track].disable();
  }
  TrackStream[] newStreams=new TrackStream[newSelections.size()];
  for (int i=0; i < newStreams.length; i++) {
    TrackSelection selection=newSelections.get(i);
    Assertions.checkState(selection.length == 1);
    Assertions.checkState(selection.getTrack(0) == 0);
    int track=selection.group;
    Assertions.checkState(!trackEnabledStates[track]);
    enabledTrackCount++;
    trackEnabledStates[track]=true;
    newStreams[i]=new TrackStreamImpl(track);
  }
  if (!seenFirstTrackSelection) {
    for (int i=0; i < sampleQueues.length; i++) {
      if (!trackEnabledStates[i]) {
        sampleQueues[i].disable();
      }
    }
  }
  if (enabledTrackCount == 0) {
    if (tracksWereEnabled) {
      loadControl.unregister(this);
      loadCondition.close();
    }
    if (loader.isLoading()) {
      loader.cancelLoading();
    }
  }
 else {
    if (!tracksWereEnabled) {
      loadControl.register(this);
      loadCondition.open();
    }
    if (seenFirstTrackSelection ? newStreams.length > 0 : positionUs != 0) {
      long seekPositionUs=seekToUs(positionUs);
      if (seekPositionUs != positionUs) {
        notifyReset=true;
      }
    }
  }
  seenFirstTrackSelection=true;
  return newStreams;
}