Program: 110166
Project: 110166
Buggy source:
@Override public TrackOutput track(int id,int type){
  int trackCount=sampleQueues.length;
  if (type == C.TRACK_TYPE_AUDIO) {
    if (audioSampleQueueIndex != C.INDEX_UNSET) {
      if (audioSampleQueueMappingDone) {
        return sampleQueueTrackIds[audioSampleQueueIndex] == id ? sampleQueues[audioSampleQueueIndex] : createDummyTrackOutput(id,type);
      }
      audioSampleQueueMappingDone=true;
      sampleQueueTrackIds[audioSampleQueueIndex]=id;
      return sampleQueues[audioSampleQueueIndex];
    }
 else     if (tracksEnded) {
      return createDummyTrackOutput(id,type);
    }
  }
 else   if (type == C.TRACK_TYPE_VIDEO) {
    if (videoSampleQueueIndex != C.INDEX_UNSET) {
      if (videoSampleQueueMappingDone) {
        return sampleQueueTrackIds[videoSampleQueueIndex] == id ? sampleQueues[videoSampleQueueIndex] : createDummyTrackOutput(id,type);
      }
      videoSampleQueueMappingDone=true;
      sampleQueueTrackIds[videoSampleQueueIndex]=id;
      return sampleQueues[videoSampleQueueIndex];
    }
 else     if (tracksEnded) {
      return createDummyTrackOutput(id,type);
    }
  }
 else {
    for (int i=0; i < trackCount; i++) {
      if (sampleQueueTrackIds[i] == id) {
        return sampleQueues[i];
      }
    }
    if (tracksEnded) {
      return createDummyTrackOutput(id,type);
    }
  }
  SampleQueue trackOutput=new SampleQueue(allocator);
  trackOutput.setSampleOffsetUs(sampleOffsetUs);
  trackOutput.setUpstreamFormatChangeListener(this);
  sampleQueueTrackIds=Arrays.copyOf(sampleQueueTrackIds,trackCount + 1);
  sampleQueueTrackIds[trackCount]=id;
  sampleQueues=Arrays.copyOf(sampleQueues,trackCount + 1);
  sampleQueues[trackCount]=trackOutput;
  sampleQueueIsAudioVideoFlags=Arrays.copyOf(sampleQueueIsAudioVideoFlags,trackCount + 1);
  sampleQueueIsAudioVideoFlags[trackCount]=type == C.TRACK_TYPE_AUDIO || type == C.TRACK_TYPE_VIDEO;
  haveAudioVideoSampleQueues|=sampleQueueIsAudioVideoFlags[trackCount];
  if (type == C.TRACK_TYPE_AUDIO) {
    audioSampleQueueMappingDone=true;
    audioSampleQueueIndex=trackCount;
  }
 else   if (type == C.TRACK_TYPE_VIDEO) {
    videoSampleQueueMappingDone=true;
    videoSampleQueueIndex=trackCount;
  }
  sampleQueuesEnabledStates=Arrays.copyOf(sampleQueuesEnabledStates,trackCount + 1);
  return trackOutput;
}

Fixed version (ground truth):
@Override public TrackOutput track(int id,int type){
  int trackCount=sampleQueues.length;
  if (type == C.TRACK_TYPE_AUDIO) {
    if (audioSampleQueueIndex != C.INDEX_UNSET) {
      if (audioSampleQueueMappingDone) {
        return sampleQueueTrackIds[audioSampleQueueIndex] == id ? sampleQueues[audioSampleQueueIndex] : createDummyTrackOutput(id,type);
      }
      audioSampleQueueMappingDone=true;
      sampleQueueTrackIds[audioSampleQueueIndex]=id;
      return sampleQueues[audioSampleQueueIndex];
    }
 else     if (tracksEnded) {
      return createDummyTrackOutput(id,type);
    }
  }
 else   if (type == C.TRACK_TYPE_VIDEO) {
    if (videoSampleQueueIndex != C.INDEX_UNSET) {
      if (videoSampleQueueMappingDone) {
        return sampleQueueTrackIds[videoSampleQueueIndex] == id ? sampleQueues[videoSampleQueueIndex] : createDummyTrackOutput(id,type);
      }
      videoSampleQueueMappingDone=true;
      sampleQueueTrackIds[videoSampleQueueIndex]=id;
      return sampleQueues[videoSampleQueueIndex];
    }
 else     if (tracksEnded) {
      return createDummyTrackOutput(id,type);
    }
  }
 else {
    for (int i=0; i < trackCount; i++) {
      if (sampleQueueTrackIds[i] == id) {
        return sampleQueues[i];
      }
    }
    if (tracksEnded) {
      return createDummyTrackOutput(id,type);
    }
  }
  SampleQueue trackOutput=new SampleQueue(allocator);
  trackOutput.sourceId(chunkUid);
  trackOutput.setSampleOffsetUs(sampleOffsetUs);
  trackOutput.setUpstreamFormatChangeListener(this);
  sampleQueueTrackIds=Arrays.copyOf(sampleQueueTrackIds,trackCount + 1);
  sampleQueueTrackIds[trackCount]=id;
  sampleQueues=Arrays.copyOf(sampleQueues,trackCount + 1);
  sampleQueues[trackCount]=trackOutput;
  sampleQueueIsAudioVideoFlags=Arrays.copyOf(sampleQueueIsAudioVideoFlags,trackCount + 1);
  sampleQueueIsAudioVideoFlags[trackCount]=type == C.TRACK_TYPE_AUDIO || type == C.TRACK_TYPE_VIDEO;
  haveAudioVideoSampleQueues|=sampleQueueIsAudioVideoFlags[trackCount];
  if (type == C.TRACK_TYPE_AUDIO) {
    audioSampleQueueMappingDone=true;
    audioSampleQueueIndex=trackCount;
  }
 else   if (type == C.TRACK_TYPE_VIDEO) {
    videoSampleQueueMappingDone=true;
    videoSampleQueueIndex=trackCount;
  }
  sampleQueuesEnabledStates=Arrays.copyOf(sampleQueuesEnabledStates,trackCount + 1);
  return trackOutput;
}