nus-yam/ex-repair huggingface dataset:
Program: 110314
Project: 110314
Buggy source:
private static ApicFrame decodeApicFrame(ParsableByteArray id3Data,int frameSize,int majorVersion) throws UnsupportedEncodingException {
  int encoding=id3Data.readUnsignedByte();
  String charset=getCharsetName(encoding);
  byte[] data=new byte[frameSize - 1];
  id3Data.readBytes(data,0,frameSize - 1);
  String mimeType;
  int mimeTypeEndIndex;
  if (majorVersion == 2) {
    mimeTypeEndIndex=2;
    mimeType="String_Node_Str" + new String(data,0,3,"String_Node_Str").toLowerCase();
    if (mimeType.equals("String_Node_Str")) {
      mimeType="String_Node_Str";
    }
  }
 else {
    mimeTypeEndIndex=indexOfZeroByte(data,0);
    mimeType=new String(data,0,mimeTypeEndIndex,"String_Node_Str").toLowerCase();
    if (mimeType.indexOf('/') == -1) {
      mimeType="String_Node_Str" + mimeType;
    }
  }
  int pictureType=data[mimeTypeEndIndex + 1] & 0xFF;
  int descriptionStartIndex=mimeTypeEndIndex + 2;
  int descriptionEndIndex=indexOfEos(data,descriptionStartIndex,encoding);
  String description=new String(data,descriptionStartIndex,descriptionEndIndex - descriptionStartIndex,charset);
  int pictureDataStartIndex=descriptionEndIndex + delimiterLength(encoding);
  byte[] pictureData=Arrays.copyOfRange(data,pictureDataStartIndex,data.length);
  return new ApicFrame(mimeType,description,pictureType,pictureData);
}

Fixed version (ground truth):
private static ApicFrame decodeApicFrame(ParsableByteArray id3Data,int frameSize,int majorVersion) throws UnsupportedEncodingException {
  int encoding=id3Data.readUnsignedByte();
  String charset=getCharsetName(encoding);
  byte[] data=new byte[frameSize - 1];
  id3Data.readBytes(data,0,frameSize - 1);
  String mimeType;
  int mimeTypeEndIndex;
  if (majorVersion == 2) {
    mimeTypeEndIndex=2;
    mimeType="String_Node_Str" + Util.toLowerInvariant(new String(data,0,3,"String_Node_Str"));
    if (mimeType.equals("String_Node_Str")) {
      mimeType="String_Node_Str";
    }
  }
 else {
    mimeTypeEndIndex=indexOfZeroByte(data,0);
    mimeType=Util.toLowerInvariant(new String(data,0,mimeTypeEndIndex,"String_Node_Str"));
    if (mimeType.indexOf('/') == -1) {
      mimeType="String_Node_Str" + mimeType;
    }
  }
  int pictureType=data[mimeTypeEndIndex + 1] & 0xFF;
  int descriptionStartIndex=mimeTypeEndIndex + 2;
  int descriptionEndIndex=indexOfEos(data,descriptionStartIndex,encoding);
  String description=new String(data,descriptionStartIndex,descriptionEndIndex - descriptionStartIndex,charset);
  int pictureDataStartIndex=descriptionEndIndex + delimiterLength(encoding);
  byte[] pictureData=Arrays.copyOfRange(data,pictureDataStartIndex,data.length);
  return new ApicFrame(mimeType,description,pictureType,pictureData);
}
Program: 110315
Project: 110315
Buggy source:
public void testParseXsDateTime() throws Exception {
  assertEquals(1403219262000L,Util.parseXsDateTime("String_Node_Str"));
  assertEquals(1407322800000L,Util.parseXsDateTime("String_Node_Str"));
}

Fixed version (ground truth):
public void testParseXsDateTime() throws Exception {
  assertEquals(1403219262000L,Util.parseXsDateTime("String_Node_Str"));
  assertEquals(1407322800000L,Util.parseXsDateTime("String_Node_Str"));
  assertEquals(1411161535000L,Util.parseXsDateTime("String_Node_Str"));
  assertEquals(1411161535000L,Util.parseXsDateTime("String_Node_Str"));
}
Program: 110316
Project: 110316
Buggy source:
private void closeCurrentOutputStream() throws IOException {
  if (outputStream == null) {
    return;
  }
  boolean success=false;
  try {
    outputStream.flush();
    underlyingFileOutputStream.getFD().sync();
    success=true;
  }
  finally {
    Util.closeQuietly(outputStream);
    if (success) {
      cache.commitFile(file);
    }
 else {
      file.delete();
    }
    outputStream=null;
    file=null;
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void closeCurrentOutputStream() throws IOException {
  if (outputStream == null) {
    return;
  }
  boolean success=false;
  try {
    outputStream.flush();
    underlyingFileOutputStream.getFD().sync();
    success=true;
  }
  finally {
    Util.closeQuietly(outputStream);
    outputStream=null;
    File fileToCommit=file;
    file=null;
    if (success) {
      cache.commitFile(fileToCommit);
    }
 else {
      fileToCommit.delete();
    }
  }
}
Program: 110317
Project: 110317
Buggy source:
/** 
 * Called when cache has beeen initialized.
 */
void onCacheInitialized();

Fixed version (ground truth):
/** 
 * Called when cache has been initialized.
 */
void onCacheInitialized();
Program: 110318
Project: 110318
Buggy source:
/** 
 * Converts a   {@link SeekPosition} into the corresponding (periodIndex, periodPositionUs) for theinternal timeline.
 * @param seekPosition The position to resolve.
 * @return The resolved position, or null if resolution was not successful.
 */
private Pair<Integer,Long> resolveSeekPosition(SeekPosition seekPosition){
  Timeline seekTimeline=seekPosition.timeline;
  if (seekTimeline == null) {
    seekTimeline=timeline;
    Assertions.checkIndex(seekPosition.windowIndex,0,timeline.getWindowCount());
  }
  Pair<Integer,Long> periodPosition=getPeriodPosition(seekTimeline,seekPosition.windowIndex,seekPosition.windowPositionUs);
  if (timeline == seekTimeline) {
    return periodPosition;
  }
  int periodIndex=timeline.getIndexOfPeriod(seekTimeline.getPeriod(periodPosition.first,period,true).uid);
  if (periodIndex != C.INDEX_UNSET) {
    return Pair.create(periodIndex,periodPosition.second);
  }
  periodIndex=resolveSubsequentPeriod(periodPosition.first,seekTimeline,timeline);
  if (periodIndex != C.INDEX_UNSET) {
    return getPeriodPosition(timeline.getPeriod(periodIndex,period).windowIndex,C.TIME_UNSET);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Converts a   {@link SeekPosition} into the corresponding (periodIndex, periodPositionUs) for theinternal timeline.
 * @param seekPosition The position to resolve.
 * @return The resolved position, or null if resolution was not successful.
 */
private Pair<Integer,Long> resolveSeekPosition(SeekPosition seekPosition){
  Timeline seekTimeline=seekPosition.timeline;
  if (seekTimeline.isEmpty()) {
    seekTimeline=timeline;
    Assertions.checkIndex(seekPosition.windowIndex,0,timeline.getWindowCount());
  }
  Pair<Integer,Long> periodPosition=getPeriodPosition(seekTimeline,seekPosition.windowIndex,seekPosition.windowPositionUs);
  if (timeline == seekTimeline) {
    return periodPosition;
  }
  int periodIndex=timeline.getIndexOfPeriod(seekTimeline.getPeriod(periodPosition.first,period,true).uid);
  if (periodIndex != C.INDEX_UNSET) {
    return Pair.create(periodIndex,periodPosition.second);
  }
  periodIndex=resolveSubsequentPeriod(periodPosition.first,seekTimeline,timeline);
  if (periodIndex != C.INDEX_UNSET) {
    return getPeriodPosition(timeline.getPeriod(periodIndex,period).windowIndex,C.TIME_UNSET);
  }
  return null;
}
Program: 110319
Project: 110319
Buggy source:
/** 
 * Returns the index of the period currently being played, or   {@link C#INDEX_UNSET} if unknown.
 */
int getCurrentPeriodIndex();

Fixed version (ground truth):
/** 
 * Returns the index of the period currently being played.
 */
int getCurrentPeriodIndex();
Program: 110320
Project: 110320
Buggy source:
/** 
 * Called when timeline and/or manifest has been refreshed.
 * @param timeline The latest timeline, or null if the timeline is being cleared.
 * @param manifest The latest manifest, or null if the manifest is being cleared.
 */
void onTimelineChanged(Timeline timeline,Object manifest);

Fixed version (ground truth):
/** 
 * Called when the timeline and/or manifest has been refreshed. <p> Note that if the timeline has changed then a position discontinuity may also have occurred. For example the current period index may have changed as a result of periods being added or removed from the timeline. The will <em>not</em> be reported via a separate call to  {@link #onPositionDiscontinuity()}.
 * @param timeline The latest timeline, or null if the timeline is being cleared.
 * @param manifest The latest manifest, or null if the manifest is being cleared.
 */
void onTimelineChanged(Timeline timeline,Object manifest);
Program: 110321
Project: 110321
Buggy source:
/** 
 * Called when a position discontinuity occurs. Position discontinuities occur when seeks are performed, when playbacks transition from one period in the timeline to the next, and when the player introduces discontinuities internally.
 */
void onPositionDiscontinuity();

Fixed version (ground truth):
/** 
 * Called when a position discontinuity occurs without a change to the timeline. A position discontinuity occurs when the current window or period index changes (as a result of playback transitioning from one period in the timeline to the next), or when the playback position jumps within the period currently being played (as a result of a seek being performed, or when the source introduces a discontinuity internally). <p> When a position discontinuity occurs as a result of a change to the timeline this method is <em>not</em> called.   {@link #onTimelineChanged(Timeline,Object)} is called in this case.
 */
void onPositionDiscontinuity();
Program: 110324
Project: 110324
Buggy source:
private void attemptRestart(int oldPeriodIndex,Timeline oldTimeline,Timeline newTimeline){
  int newPeriodIndex=resolveSubsequentPeriod(oldPeriodIndex,oldTimeline,newTimeline);
  if (newPeriodIndex == C.INDEX_UNSET) {
    stopInternal();
    return;
  }
  releasePeriodHoldersFrom(playingPeriodHolder != null ? playingPeriodHolder : loadingPeriodHolder);
  bufferAheadPeriodCount=0;
  playingPeriodHolder=null;
  readingPeriodHolder=null;
  loadingPeriodHolder=null;
  Pair<Integer,Long> defaultPosition=getPeriodPosition(timeline.getPeriod(newPeriodIndex,period).windowIndex,C.TIME_UNSET);
  newPeriodIndex=defaultPosition.first;
  long newPlayingPositionUs=defaultPosition.second;
  playbackInfo=new PlaybackInfo(newPeriodIndex,newPlayingPositionUs);
  eventHandler.obtainMessage(MSG_POSITION_DISCONTINUITY,playbackInfo).sendToTarget();
}

Fixed version (ground truth):
private boolean attemptRestart(int oldPeriodIndex,Timeline oldTimeline,Timeline newTimeline){
  int newPeriodIndex=resolveSubsequentPeriod(oldPeriodIndex,oldTimeline,newTimeline);
  if (newPeriodIndex == C.INDEX_UNSET) {
    return false;
  }
  releasePeriodHoldersFrom(playingPeriodHolder != null ? playingPeriodHolder : loadingPeriodHolder);
  bufferAheadPeriodCount=0;
  playingPeriodHolder=null;
  readingPeriodHolder=null;
  loadingPeriodHolder=null;
  Pair<Integer,Long> defaultPosition=getPeriodPosition(timeline.getPeriod(newPeriodIndex,period).windowIndex,C.TIME_UNSET);
  newPeriodIndex=defaultPosition.first;
  long newPlayingPositionUs=defaultPosition.second;
  playbackInfo=new PlaybackInfo(newPeriodIndex,newPlayingPositionUs);
  return true;
}
Program: 110327
Project: 110327
Buggy source:
private void seekToInternal(SeekPosition seekPosition) throws ExoPlaybackException {
  if (timeline == null) {
    pendingInitialSeekCount++;
    pendingSeekPosition=seekPosition;
    return;
  }
  Pair<Integer,Long> periodPosition=resolveSeekPosition(seekPosition);
  if (periodPosition == null) {
    stopInternal();
    return;
  }
  int periodIndex=periodPosition.first;
  long periodPositionUs=periodPosition.second;
  try {
    if (periodIndex == playbackInfo.periodIndex && ((periodPositionUs == C.TIME_UNSET && playbackInfo.positionUs == C.TIME_UNSET) || ((periodPositionUs / 1000) == (playbackInfo.positionUs / 1000)))) {
      return;
    }
    periodPositionUs=seekToPeriodPosition(periodIndex,periodPositionUs);
  }
  finally {
    playbackInfo=new PlaybackInfo(periodIndex,periodPositionUs);
    eventHandler.obtainMessage(MSG_SEEK_ACK,1,0,playbackInfo).sendToTarget();
  }
}

Fixed version (ground truth):
private void seekToInternal(SeekPosition seekPosition) throws ExoPlaybackException {
  if (timeline == null) {
    pendingInitialSeekCount++;
    pendingSeekPosition=seekPosition;
    return;
  }
  Pair<Integer,Long> periodPosition=resolveSeekPosition(seekPosition);
  if (periodPosition == null) {
    stopInternal();
    return;
  }
  int periodIndex=periodPosition.first;
  long periodPositionUs=periodPosition.second;
  try {
    if (periodIndex == playbackInfo.periodIndex && ((periodPositionUs / 1000) == (playbackInfo.positionUs / 1000))) {
      return;
    }
    periodPositionUs=seekToPeriodPosition(periodIndex,periodPositionUs);
  }
  finally {
    playbackInfo=new PlaybackInfo(periodIndex,periodPositionUs);
    eventHandler.obtainMessage(MSG_SEEK_ACK,playbackInfo).sendToTarget();
  }
}
Program: 110328
Project: 110328
Buggy source:
@Override public long getBufferedPositionUs(){
  if (loadingFinished) {
    return C.TIME_END_OF_SOURCE;
  }
 else   if (isPendingReset()) {
    return pendingResetPositionUs;
  }
 else {
    long largestQueuedTimestampUs=getLargestQueuedTimestampUs();
    return largestQueuedTimestampUs == Long.MIN_VALUE ? lastSeekPositionUs : largestQueuedTimestampUs;
  }
}

Fixed version (ground truth):
@Override public long getBufferedPositionUs(){
  if (loadingFinished) {
    return C.TIME_END_OF_SOURCE;
  }
 else   if (isPendingReset()) {
    return pendingResetPositionUs;
  }
  long largestQueuedTimestampUs;
  if (haveAudioVideoTracks) {
    largestQueuedTimestampUs=Long.MAX_VALUE;
    int trackCount=sampleQueues.size();
    for (int i=0; i < trackCount; i++) {
      if (trackIsAudioVideoFlags[i]) {
        largestQueuedTimestampUs=Math.min(largestQueuedTimestampUs,sampleQueues.valueAt(i).getLargestQueuedTimestampUs());
      }
    }
  }
 else {
    largestQueuedTimestampUs=getLargestQueuedTimestampUs();
  }
  return largestQueuedTimestampUs == Long.MIN_VALUE ? lastSeekPositionUs : largestQueuedTimestampUs;
}
Program: 110329
Project: 110329
Buggy source:
private void maybeFinishPrepare(){
  if (released || prepared || seekMap == null || !tracksBuilt) {
    return;
  }
  int trackCount=sampleQueues.size();
  for (int i=0; i < trackCount; i++) {
    if (sampleQueues.valueAt(i).getUpstreamFormat() == null) {
      return;
    }
  }
  loadCondition.close();
  TrackGroup[] trackArray=new TrackGroup[trackCount];
  trackEnabledStates=new boolean[trackCount];
  durationUs=seekMap.getDurationUs();
  for (int i=0; i < trackCount; i++) {
    trackArray[i]=new TrackGroup(sampleQueues.valueAt(i).getUpstreamFormat());
  }
  tracks=new TrackGroupArray(trackArray);
  prepared=true;
  sourceListener.onSourceInfoRefreshed(new SinglePeriodTimeline(durationUs,seekMap.isSeekable()),null);
  callback.onPrepared(this);
}

Fixed version (ground truth):
private void maybeFinishPrepare(){
  if (released || prepared || seekMap == null || !tracksBuilt) {
    return;
  }
  int trackCount=sampleQueues.size();
  for (int i=0; i < trackCount; i++) {
    if (sampleQueues.valueAt(i).getUpstreamFormat() == null) {
      return;
    }
  }
  loadCondition.close();
  TrackGroup[] trackArray=new TrackGroup[trackCount];
  trackIsAudioVideoFlags=new boolean[trackCount];
  trackEnabledStates=new boolean[trackCount];
  durationUs=seekMap.getDurationUs();
  for (int i=0; i < trackCount; i++) {
    Format trackFormat=sampleQueues.valueAt(i).getUpstreamFormat();
    trackArray[i]=new TrackGroup(trackFormat);
    String mimeType=trackFormat.sampleMimeType;
    boolean isAudioVideo=MimeTypes.isVideo(mimeType) || MimeTypes.isAudio(mimeType);
    trackIsAudioVideoFlags[i]=isAudioVideo;
    haveAudioVideoTracks|=isAudioVideo;
  }
  tracks=new TrackGroupArray(trackArray);
  prepared=true;
  sourceListener.onSourceInfoRefreshed(new SinglePeriodTimeline(durationUs,seekMap.isSeekable()),null);
  callback.onPrepared(this);
}
Program: 110330
Project: 110330
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  if (videoAspectRatio == 0) {
    return;
  }
  int width=getMeasuredWidth();
  int height=getMeasuredHeight();
  float viewAspectRatio=(float)width / height;
  float aspectDeformation=videoAspectRatio / viewAspectRatio - 1;
  if (Math.abs(aspectDeformation) <= MAX_ASPECT_RATIO_DEFORMATION_FRACTION) {
    return;
  }
switch (resizeMode) {
case RESIZE_MODE_FIXED_WIDTH:
    height=(int)(width / videoAspectRatio);
  break;
case RESIZE_MODE_FIXED_HEIGHT:
width=(int)(height * videoAspectRatio);
break;
default :
if (aspectDeformation > 0) {
height=(int)(width / videoAspectRatio);
}
 else {
width=(int)(height * videoAspectRatio);
}
break;
}
super.onMeasure(MeasureSpec.makeMeasureSpec(width,MeasureSpec.EXACTLY),MeasureSpec.makeMeasureSpec(height,MeasureSpec.EXACTLY));
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  if (resizeMode == RESIZE_MODE_FILL || videoAspectRatio <= 0) {
    return;
  }
  int width=getMeasuredWidth();
  int height=getMeasuredHeight();
  float viewAspectRatio=(float)width / height;
  float aspectDeformation=videoAspectRatio / viewAspectRatio - 1;
  if (Math.abs(aspectDeformation) <= MAX_ASPECT_RATIO_DEFORMATION_FRACTION) {
    return;
  }
switch (resizeMode) {
case RESIZE_MODE_FIXED_WIDTH:
    height=(int)(width / videoAspectRatio);
  break;
case RESIZE_MODE_FIXED_HEIGHT:
width=(int)(height * videoAspectRatio);
break;
default :
if (aspectDeformation > 0) {
height=(int)(width / videoAspectRatio);
}
 else {
width=(int)(height * videoAspectRatio);
}
break;
}
super.onMeasure(MeasureSpec.makeMeasureSpec(width,MeasureSpec.EXACTLY),MeasureSpec.makeMeasureSpec(height,MeasureSpec.EXACTLY));
}
Program: 110331
Project: 110331
Buggy source:
@Override public void onVideoSizeChanged(int width,int height,int unappliedRotationDegrees,float pixelWidthHeightRatio){
  if (aspectRatioVideoFrame != null) {
    float aspectRatio=height == 0 ? 1 : (width * pixelWidthHeightRatio) / height;
    aspectRatioVideoFrame.setAspectRatio(aspectRatio);
  }
}

Fixed version (ground truth):
@Override public void onVideoSizeChanged(int width,int height,int unappliedRotationDegrees,float pixelWidthHeightRatio){
  if (contentFrame != null) {
    float aspectRatio=height == 0 ? 1 : (width * pixelWidthHeightRatio) / height;
    contentFrame.setAspectRatio(aspectRatio);
  }
}
Program: 110332
Project: 110332
Buggy source:
private void updateForCurrentTrackSelections(){
  if (player == null) {
    return;
  }
  TrackSelectionArray selections=player.getCurrentTrackSelections();
  for (int i=0; i < selections.length; i++) {
    if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
      hideArtwork();
      return;
    }
  }
  if (shutterView != null) {
    shutterView.setVisibility(VISIBLE);
  }
  if (useArtwork) {
    for (int i=0; i < selections.length; i++) {
      TrackSelection selection=selections.get(i);
      if (selection != null) {
        for (int j=0; j < selection.length(); j++) {
          Metadata metadata=selection.getFormat(j).metadata;
          if (metadata != null) {
            for (int k=0; k < metadata.length(); k++) {
              Metadata.Entry metadataEntry=metadata.get(k);
              if (metadataEntry instanceof ApicFrame) {
                byte[] data=((ApicFrame)metadataEntry).pictureData;
                ;
                artworkView.setImageBitmap(BitmapFactory.decodeByteArray(data,0,data.length));
                artworkView.setVisibility(VISIBLE);
                return;
              }
            }
          }
        }
      }
    }
  }
  hideArtwork();
}

Fixed version (ground truth):
private void updateForCurrentTrackSelections(){
  if (player == null) {
    return;
  }
  TrackSelectionArray selections=player.getCurrentTrackSelections();
  for (int i=0; i < selections.length; i++) {
    if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
      hideArtwork();
      return;
    }
  }
  if (shutterView != null) {
    shutterView.setVisibility(VISIBLE);
  }
  if (useArtwork) {
    for (int i=0; i < selections.length; i++) {
      TrackSelection selection=selections.get(i);
      if (selection != null) {
        for (int j=0; j < selection.length(); j++) {
          Metadata metadata=selection.getFormat(j).metadata;
          if (metadata != null && setArtworkFromMetadata(metadata)) {
            return;
          }
        }
      }
    }
  }
  hideArtwork();
}
Program: 110333
Project: 110333
Buggy source:
/** 
 * Sets the resize mode.
 * @param resizeMode The resize mode.
 */
public void setResizeMode(@ResizeMode int resizeMode){
  Assertions.checkState(aspectRatioVideoFrame != null);
  aspectRatioVideoFrame.setResizeMode(resizeMode);
}

Fixed version (ground truth):
/** 
 * Sets the resize mode.
 * @param resizeMode The resize mode.
 */
public void setResizeMode(@ResizeMode int resizeMode){
  Assertions.checkState(contentFrame != null);
  contentFrame.setResizeMode(resizeMode);
}
Program: 110336
Project: 110336
Buggy source:
private Class<?> getDecoderClass(String mimeType){
  try {
switch (mimeType) {
case MimeTypes.TEXT_VTT:
      return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_TTML:
    return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_MP4VTT:
  return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_SUBRIP:
return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_TX3G:
return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_CEA608:
return Class.forName("String_Node_Str");
default :
return null;
}
}
 catch (ClassNotFoundException e) {
return null;
}
}

Fixed version (ground truth):
private Class<?> getDecoderClass(String mimeType){
  if (mimeType == null) {
    return null;
  }
  try {
switch (mimeType) {
case MimeTypes.TEXT_VTT:
      return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_TTML:
    return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_MP4VTT:
  return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_SUBRIP:
return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_TX3G:
return Class.forName("String_Node_Str");
case MimeTypes.APPLICATION_CEA608:
return Class.forName("String_Node_Str");
default :
return null;
}
}
 catch (ClassNotFoundException e) {
return null;
}
}
Program: 110337
Project: 110337
Buggy source:
/** 
 * Whether the top-level type of   {@code mimeType} is video.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is video.
 */
public static boolean isVideo(String mimeType){
  return getTopLevelType(mimeType).equals(BASE_TYPE_VIDEO);
}

Fixed version (ground truth):
/** 
 * Whether the top-level type of   {@code mimeType} is video.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is video.
 */
public static boolean isVideo(String mimeType){
  return BASE_TYPE_VIDEO.equals(getTopLevelType(mimeType));
}
Program: 110338
Project: 110338
Buggy source:
/** 
 * Returns the top-level type of   {@code mimeType}.
 * @param mimeType The mimeType whose top-level type is required.
 * @return The top-level type.
 */
private static String getTopLevelType(String mimeType){
  int indexOfSlash=mimeType.indexOf('/');
  if (indexOfSlash == -1) {
    throw new IllegalArgumentException("String_Node_Str" + mimeType);
  }
  return mimeType.substring(0,indexOfSlash);
}

Fixed version (ground truth):
/** 
 * Returns the top-level type of   {@code mimeType}.
 * @param mimeType The mimeType whose top-level type is required.
 * @return The top-level type, or null if the mimeType is null.
 */
private static String getTopLevelType(String mimeType){
  if (mimeType == null) {
    return null;
  }
  int indexOfSlash=mimeType.indexOf('/');
  if (indexOfSlash == -1) {
    throw new IllegalArgumentException("String_Node_Str" + mimeType);
  }
  return mimeType.substring(0,indexOfSlash);
}
Program: 110339
Project: 110339
Buggy source:
/** 
 * Whether the top-level type of   {@code mimeType} is audio.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is audio.
 */
public static boolean isAudio(String mimeType){
  return getTopLevelType(mimeType).equals(BASE_TYPE_AUDIO);
}

Fixed version (ground truth):
/** 
 * Whether the top-level type of   {@code mimeType} is audio.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is audio.
 */
public static boolean isAudio(String mimeType){
  return BASE_TYPE_AUDIO.equals(getTopLevelType(mimeType));
}
Program: 110340
Project: 110340
Buggy source:
/** 
 * Whether the top-level type of   {@code mimeType} is text.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is text.
 */
public static boolean isText(String mimeType){
  return getTopLevelType(mimeType).equals(BASE_TYPE_TEXT);
}

Fixed version (ground truth):
/** 
 * Whether the top-level type of   {@code mimeType} is text.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is text.
 */
public static boolean isText(String mimeType){
  return BASE_TYPE_TEXT.equals(getTopLevelType(mimeType));
}
Program: 110341
Project: 110341
Buggy source:
/** 
 * Whether the top-level type of   {@code mimeType} is application.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is application.
 */
public static boolean isApplication(String mimeType){
  return getTopLevelType(mimeType).equals(BASE_TYPE_APPLICATION);
}

Fixed version (ground truth):
/** 
 * Whether the top-level type of   {@code mimeType} is application.
 * @param mimeType The mimeType to test.
 * @return Whether the top level type is application.
 */
public static boolean isApplication(String mimeType){
  return BASE_TYPE_APPLICATION.equals(getTopLevelType(mimeType));
}
Program: 110342
Project: 110342
Buggy source:
@Override public long open(DataSpec dataSpec) throws HttpDataSourceException {
  Assertions.checkNotNull(dataSpec);
synchronized (this) {
    Assertions.checkState(connectionState == IDLE_CONNECTION,"String_Node_Str");
    connectionState=OPENING_CONNECTION;
  }
  operation.close();
  resetConnectTimeout();
  currentDataSpec=dataSpec;
  UrlRequest.Builder urlRequestBuilder=new UrlRequest.Builder(dataSpec.uri.toString(),this,executor,cronetEngine);
  fillCurrentRequestHeader(urlRequestBuilder);
  fillCurrentRequestPostBody(urlRequestBuilder,dataSpec);
  currentUrlRequest=urlRequestBuilder.build();
  currentUrlRequest.start();
  boolean requestStarted=blockUntilConnectTimeout();
  if (exception != null) {
    throw exception;
  }
 else   if (!requestStarted) {
    throw new OpenException(new SocketTimeoutException(),dataSpec,getStatus(currentUrlRequest));
  }
  if (listener != null) {
    listener.onTransferStart(this,dataSpec);
  }
  connectionState=OPEN_CONNECTION;
  return contentLength;
}

Fixed version (ground truth):
@Override public long open(DataSpec dataSpec) throws HttpDataSourceException {
  Assertions.checkNotNull(dataSpec);
synchronized (this) {
    Assertions.checkState(connectionState == IDLE_CONNECTION,"String_Node_Str");
    connectionState=OPENING_CONNECTION;
  }
  operation.close();
  resetConnectTimeout();
  currentDataSpec=dataSpec;
  currentUrlRequest=buildRequest(dataSpec);
  currentUrlRequest.start();
  boolean requestStarted=blockUntilConnectTimeout();
  if (exception != null) {
    throw exception;
  }
 else   if (!requestStarted) {
    throw new OpenException(new SocketTimeoutException(),dataSpec,getStatus(currentUrlRequest));
  }
  if (listener != null) {
    listener.onTransferStart(this,dataSpec);
  }
  connectionState=OPEN_CONNECTION;
  return contentLength;
}
Program: 110343
Project: 110343
Buggy source:
/** 
 * Rolls up the Cue one row.
 * @return true if rolling was possible.
 */
public boolean rollUp(){
  if (row < 1) {
    return false;
  }
  setRow(row - 1);
  return true;
}

Fixed version (ground truth):
/** 
 * Rolls up the Cue one row.
 * @return true if rolling was possible.
 */
public boolean rollUp(){
  if (row <= 1) {
    return false;
  }
  setRow(row - 1);
  return true;
}
Program: 110344
Project: 110344
Buggy source:
private void handleMiscCode(byte cc2){
switch (cc2) {
case CTRL_ROLL_UP_CAPTIONS_2_ROWS:
    captionRowCount=2;
  setCaptionMode(CC_MODE_ROLL_UP);
return;
case CTRL_ROLL_UP_CAPTIONS_3_ROWS:
captionRowCount=3;
setCaptionMode(CC_MODE_ROLL_UP);
return;
case CTRL_ROLL_UP_CAPTIONS_4_ROWS:
captionRowCount=4;
setCaptionMode(CC_MODE_ROLL_UP);
return;
case CTRL_RESUME_CAPTION_LOADING:
setCaptionMode(CC_MODE_POP_ON);
return;
case CTRL_RESUME_DIRECT_CAPTIONING:
setCaptionMode(CC_MODE_PAINT_ON);
return;
}
if (captionMode == CC_MODE_UNKNOWN) {
return;
}
switch (cc2) {
case CTRL_ERASE_DISPLAYED_MEMORY:
if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) {
currentCue=new Eia608CueBuilder();
cues.clear();
}
subtitle.setCues(Collections.<Cue>emptyList());
return;
case CTRL_ERASE_NON_DISPLAYED_MEMORY:
currentCue=new Eia608CueBuilder();
cues.clear();
return;
case CTRL_END_OF_CAPTION:
renderCues();
cues.clear();
return;
case CTRL_CARRIAGE_RETURN:
if (captionMode == CC_MODE_ROLL_UP) {
for (Eia608CueBuilder cue : cues) {
if (!cue.rollUp()) {
cues.remove(cue);
}
}
currentCue=new Eia608CueBuilder();
cues.add(currentCue);
while (cues.size() > captionRowCount) {
cues.pollFirst();
}
}
return;
case CTRL_BACKSPACE:
currentCue.backspace();
return;
case CTRL_DELETE_TO_END_OF_ROW:
return;
}
}

Fixed version (ground truth):
private void handleMiscCode(byte cc2){
switch (cc2) {
case CTRL_ROLL_UP_CAPTIONS_2_ROWS:
    captionRowCount=2;
  setCaptionMode(CC_MODE_ROLL_UP);
return;
case CTRL_ROLL_UP_CAPTIONS_3_ROWS:
captionRowCount=3;
setCaptionMode(CC_MODE_ROLL_UP);
return;
case CTRL_ROLL_UP_CAPTIONS_4_ROWS:
captionRowCount=4;
setCaptionMode(CC_MODE_ROLL_UP);
return;
case CTRL_RESUME_CAPTION_LOADING:
setCaptionMode(CC_MODE_POP_ON);
return;
case CTRL_RESUME_DIRECT_CAPTIONING:
setCaptionMode(CC_MODE_PAINT_ON);
return;
}
if (captionMode == CC_MODE_UNKNOWN) {
return;
}
switch (cc2) {
case CTRL_ERASE_DISPLAYED_MEMORY:
if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) {
currentCue=new Eia608CueBuilder();
cues.clear();
}
subtitle.setCues(Collections.<Cue>emptyList());
return;
case CTRL_ERASE_NON_DISPLAYED_MEMORY:
currentCue=new Eia608CueBuilder();
cues.clear();
return;
case CTRL_END_OF_CAPTION:
renderCues();
cues.clear();
return;
case CTRL_CARRIAGE_RETURN:
if (captionMode == CC_MODE_ROLL_UP) {
Iterator<Eia608CueBuilder> iterator=cues.iterator();
while (iterator.hasNext()) {
Eia608CueBuilder cue=iterator.next();
if (!cue.rollUp()) {
iterator.remove();
}
}
currentCue=new Eia608CueBuilder();
cues.add(currentCue);
while (cues.size() > captionRowCount) {
cues.pollFirst();
}
}
return;
case CTRL_BACKSPACE:
currentCue.backspace();
return;
case CTRL_DELETE_TO_END_OF_ROW:
return;
}
}
Program: 110345
Project: 110345
Buggy source:
@Override public long getBufferedPosition(){
  if (timeline == null || pendingSeekAcks > 0) {
    return maskingWindowPositionMs;
  }
 else {
    int periodIndex=playbackInfo.periodIndex;
    timeline.getPeriod(periodIndex,period);
    int windowIndex=period.windowIndex;
    timeline.getWindow(windowIndex,window);
    if (window.firstPeriodIndex == periodIndex && window.lastPeriodIndex == periodIndex && window.getPositionInFirstPeriodUs() == 0 && window.getDurationUs() == period.getDurationUs()) {
      return C.usToMs(playbackInfo.bufferedPositionUs);
    }
    return getCurrentPosition();
  }
}

Fixed version (ground truth):
@Override public long getBufferedPosition(){
  if (timeline == null || pendingSeekAcks > 0) {
    return maskingWindowPositionMs;
  }
 else {
    timeline.getPeriod(playbackInfo.periodIndex,period);
    return period.getPositionInWindowMs() + C.usToMs(playbackInfo.bufferedPositionUs);
  }
}
Program: 110346
Project: 110346
Buggy source:
private void maybeContinueLoading(){
  long nextLoadPositionUs=loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
  if (nextLoadPositionUs != C.TIME_END_OF_SOURCE) {
    long loadingPeriodPositionUs=rendererPositionUs - loadingPeriodHolder.rendererPositionOffsetUs + loadingPeriodHolder.startPositionUs;
    long bufferedDurationUs=nextLoadPositionUs - loadingPeriodPositionUs;
    boolean continueLoading=loadControl.shouldContinueLoading(bufferedDurationUs);
    setIsLoading(continueLoading);
    if (continueLoading) {
      loadingPeriodHolder.needsContinueLoading=false;
      loadingPeriodHolder.mediaPeriod.continueLoading(loadingPeriodPositionUs);
    }
 else {
      loadingPeriodHolder.needsContinueLoading=true;
    }
  }
 else {
    setIsLoading(false);
  }
}

Fixed version (ground truth):
private void maybeContinueLoading(){
  long nextLoadPositionUs=loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
  if (nextLoadPositionUs != C.TIME_END_OF_SOURCE) {
    long loadingPeriodPositionUs=rendererPositionUs - loadingPeriodHolder.rendererPositionOffsetUs;
    long bufferedDurationUs=nextLoadPositionUs - loadingPeriodPositionUs;
    boolean continueLoading=loadControl.shouldContinueLoading(bufferedDurationUs);
    setIsLoading(continueLoading);
    if (continueLoading) {
      loadingPeriodHolder.needsContinueLoading=false;
      loadingPeriodHolder.mediaPeriod.continueLoading(loadingPeriodPositionUs);
    }
 else {
      loadingPeriodHolder.needsContinueLoading=true;
    }
  }
 else {
    setIsLoading(false);
  }
}
Program: 110348
Project: 110348
Buggy source:
/** 
 * Parses a udta atom for metadata, including gapless playback information.
 * @param udtaAtom The udta (user data) atom to decode.
 * @param isQuickTime True for QuickTime media. False otherwise.
 * @return metadata stored in the user data, or {@code null} if not present.
 */
public static Metadata parseUdta(Atom.LeafAtom udtaAtom,boolean isQuickTime){
  if (isQuickTime) {
    return null;
  }
  ParsableByteArray udtaData=udtaAtom.data;
  udtaData.setPosition(Atom.HEADER_SIZE);
  while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) {
    int atomSize=udtaData.readInt();
    int atomType=udtaData.readInt();
    if (atomType == Atom.TYPE_meta) {
      udtaData.setPosition(udtaData.getPosition() - Atom.HEADER_SIZE);
      udtaData.setLimit(udtaData.getPosition() + atomSize);
      parseMetaAtom(udtaData);
      break;
    }
    udtaData.skipBytes(atomSize - Atom.HEADER_SIZE);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Parses a udta atom for metadata, including gapless playback information.
 * @param udtaAtom The udta (user data) atom to decode.
 * @param isQuickTime True for QuickTime media. False otherwise.
 * @return metadata stored in the user data, or {@code null} if not present.
 */
public static Metadata parseUdta(Atom.LeafAtom udtaAtom,boolean isQuickTime){
  if (isQuickTime) {
    return null;
  }
  ParsableByteArray udtaData=udtaAtom.data;
  udtaData.setPosition(Atom.HEADER_SIZE);
  while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) {
    int atomSize=udtaData.readInt();
    int atomType=udtaData.readInt();
    if (atomType == Atom.TYPE_meta) {
      udtaData.setPosition(udtaData.getPosition() - Atom.HEADER_SIZE);
      udtaData.setLimit(udtaData.getPosition() + atomSize);
      return parseMetaAtom(udtaData);
    }
    udtaData.skipBytes(atomSize - Atom.HEADER_SIZE);
  }
  return null;
}
Program: 110350
Project: 110350
Buggy source:
@Override public void onNewIntent(Intent intent){
  releasePlayer();
  playerPosition=0;
  setIntent(intent);
}

Fixed version (ground truth):
@Override public void onNewIntent(Intent intent){
  releasePlayer();
  shouldRestorePosition=false;
  setIntent(intent);
}
Program: 110351
Project: 110351
Buggy source:
private void releasePlayer(){
  if (player != null) {
    shutterView.setVisibility(View.VISIBLE);
    debugViewHelper.stop();
    debugViewHelper=null;
    playerPeriodIndex=player.getCurrentPeriodIndex();
    playerPosition=player.getCurrentPositionInPeriod();
    shouldRestorePosition=false;
    Timeline playerTimeline=player.getCurrentTimeline();
    if (playerTimeline != null) {
      Window window=playerTimeline.getWindow(playerPeriodIndex);
      if (window.isSeekable && !window.isDynamic) {
        shouldRestorePosition=true;
      }
    }
    player.release();
    player=null;
    trackSelector=null;
    trackSelectionHelper=null;
    eventLogger=null;
  }
}

Fixed version (ground truth):
private void releasePlayer(){
  if (player != null) {
    shutterView.setVisibility(View.VISIBLE);
    debugViewHelper.stop();
    debugViewHelper=null;
    shouldRestorePosition=false;
    Timeline playerTimeline=player.getCurrentTimeline();
    if (playerTimeline != null) {
      Window window=playerTimeline.getWindow(player.getCurrentWindowIndex());
      if (!window.isDynamic) {
        shouldRestorePosition=true;
        playerPeriod=player.getCurrentPeriodIndex();
        playerPosition=window.isSeekable ? player.getCurrentPositionInPeriod() : -1;
      }
    }
    player.release();
    player=null;
    trackSelector=null;
    trackSelectionHelper=null;
    eventLogger=null;
  }
}
Program: 110355
Project: 110355
Buggy source:
public boolean[] updatePeriodTrackSelection(long positionUs,LoadControl loadControl,boolean forceRecreateStreams) throws ExoPlaybackException {
  for (int i=0; i < trackSelections.length; i++) {
    mayRetainStreamFlags[i]=!forceRecreateStreams && Util.areEqual(periodTrackSelections == null ? null : periodTrackSelections.get(i),trackSelections.get(i));
  }
  boolean[] streamResetFlags=new boolean[renderers.length];
  mediaPeriod.selectTracks(trackSelections.getAll(),mayRetainStreamFlags,sampleStreams,streamResetFlags,positionUs);
  periodTrackSelections=trackSelections;
  hasEnabledTracks=false;
  for (int i=0; i < sampleStreams.length; i++) {
    if (sampleStreams[i] != null) {
      hasEnabledTracks=true;
      break;
    }
  }
  loadControl.onTrackSelections(renderers,mediaPeriod.getTrackGroups(),trackSelections);
  return streamResetFlags;
}

Fixed version (ground truth):
public long updatePeriodTrackSelection(long positionUs,LoadControl loadControl,boolean forceRecreateStreams,boolean[] streamResetFlags) throws ExoPlaybackException {
  for (int i=0; i < trackSelections.length; i++) {
    mayRetainStreamFlags[i]=!forceRecreateStreams && Util.areEqual(periodTrackSelections == null ? null : periodTrackSelections.get(i),trackSelections.get(i));
  }
  positionUs=mediaPeriod.selectTracks(trackSelections.getAll(),mayRetainStreamFlags,sampleStreams,streamResetFlags,positionUs);
  periodTrackSelections=trackSelections;
  hasEnabledTracks=false;
  for (int i=0; i < sampleStreams.length; i++) {
    if (sampleStreams[i] != null) {
      hasEnabledTracks=true;
      break;
    }
  }
  loadControl.onTrackSelections(renderers,mediaPeriod.getTrackGroups(),trackSelections);
  return positionUs;
}
Program: 110356
Project: 110356
Buggy source:
public void handlePrepared(long positionUs,LoadControl loadControl) throws ExoPlaybackException {
  prepared=true;
  selectTracks();
  updatePeriodTrackSelection(positionUs,loadControl,false);
}

Fixed version (ground truth):
public void handlePrepared(long positionUs,LoadControl loadControl) throws ExoPlaybackException {
  prepared=true;
  selectTracks();
  startPositionUs=updatePeriodTrackSelection(positionUs,loadControl,false);
}
Program: 110360
Project: 110360
Buggy source:
@Override public void selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) {
      sampleStreams.remove(streams[i]);
      streams[i]=null;
    }
    if (streams[i] == null && selections[i] != null) {
      SampleStreamImpl stream=new SampleStreamImpl();
      sampleStreams.add(stream);
      streams[i]=stream;
      streamResetFlags[i]=true;
    }
  }
}

Fixed version (ground truth):
@Override public long selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) {
      sampleStreams.remove(streams[i]);
      streams[i]=null;
    }
    if (streams[i] == null && selections[i] != null) {
      SampleStreamImpl stream=new SampleStreamImpl();
      sampleStreams.add(stream);
      streams[i]=stream;
      streamResetFlags[i]=true;
    }
  }
  return positionUs;
}
Program: 110361
Project: 110361
Buggy source:
@Override public void selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  ArrayList<ChunkSampleStream<DashChunkSource>> sampleStreamsList=new ArrayList<>();
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null) {
      @SuppressWarnings("String_Node_Str") ChunkSampleStream<DashChunkSource> stream=(ChunkSampleStream<DashChunkSource>)streams[i];
      if (selections[i] == null || !mayRetainStreamFlags[i]) {
        stream.release();
        streams[i]=null;
      }
 else {
        sampleStreamsList.add(stream);
      }
    }
    if (streams[i] == null && selections[i] != null) {
      ChunkSampleStream<DashChunkSource> stream=buildSampleStream(selections[i],positionUs);
      sampleStreamsList.add(stream);
      streams[i]=stream;
      streamResetFlags[i]=true;
    }
  }
  sampleStreams=newSampleStreamArray(sampleStreamsList.size());
  sampleStreamsList.toArray(sampleStreams);
  sequenceableLoader=new CompositeSequenceableLoader(sampleStreams);
}

Fixed version (ground truth):
@Override public long selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  ArrayList<ChunkSampleStream<DashChunkSource>> sampleStreamsList=new ArrayList<>();
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null) {
      @SuppressWarnings("String_Node_Str") ChunkSampleStream<DashChunkSource> stream=(ChunkSampleStream<DashChunkSource>)streams[i];
      if (selections[i] == null || !mayRetainStreamFlags[i]) {
        stream.release();
        streams[i]=null;
      }
 else {
        sampleStreamsList.add(stream);
      }
    }
    if (streams[i] == null && selections[i] != null) {
      ChunkSampleStream<DashChunkSource> stream=buildSampleStream(selections[i],positionUs);
      sampleStreamsList.add(stream);
      streams[i]=stream;
      streamResetFlags[i]=true;
    }
  }
  sampleStreams=newSampleStreamArray(sampleStreamsList.size());
  sampleStreamsList.toArray(sampleStreams);
  sequenceableLoader=new CompositeSequenceableLoader(sampleStreams);
  return positionUs;
}
Program: 110363
Project: 110363
Buggy source:
@Override public void selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  ArrayList<ChunkSampleStream<SsChunkSource>> sampleStreamsList=new ArrayList<>();
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null) {
      @SuppressWarnings("String_Node_Str") ChunkSampleStream<SsChunkSource> stream=(ChunkSampleStream<SsChunkSource>)streams[i];
      if (selections[i] == null || !mayRetainStreamFlags[i]) {
        stream.release();
        streams[i]=null;
      }
 else {
        sampleStreamsList.add(stream);
      }
    }
    if (streams[i] == null && selections[i] != null) {
      ChunkSampleStream<SsChunkSource> stream=buildSampleStream(selections[i],positionUs);
      sampleStreamsList.add(stream);
      streams[i]=stream;
      streamResetFlags[i]=true;
    }
  }
  sampleStreams=newSampleStreamArray(sampleStreamsList.size());
  sampleStreamsList.toArray(sampleStreams);
  sequenceableLoader=new CompositeSequenceableLoader(sampleStreams);
}

Fixed version (ground truth):
@Override public long selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  ArrayList<ChunkSampleStream<SsChunkSource>> sampleStreamsList=new ArrayList<>();
  for (int i=0; i < selections.length; i++) {
    if (streams[i] != null) {
      @SuppressWarnings("String_Node_Str") ChunkSampleStream<SsChunkSource> stream=(ChunkSampleStream<SsChunkSource>)streams[i];
      if (selections[i] == null || !mayRetainStreamFlags[i]) {
        stream.release();
        streams[i]=null;
      }
 else {
        sampleStreamsList.add(stream);
      }
    }
    if (streams[i] == null && selections[i] != null) {
      ChunkSampleStream<SsChunkSource> stream=buildSampleStream(selections[i],positionUs);
      sampleStreamsList.add(stream);
      streams[i]=stream;
      streamResetFlags[i]=true;
    }
  }
  sampleStreams=newSampleStreamArray(sampleStreamsList.size());
  sampleStreamsList.toArray(sampleStreams);
  sequenceableLoader=new CompositeSequenceableLoader(sampleStreams);
  return positionUs;
}
Program: 110364
Project: 110364
Buggy source:
private long getNowUnixTimeUs(){
  if (elapsedRealtimeOffsetMs != 0) {
    return SystemClock.elapsedRealtime() * 1000 + elapsedRealtimeOffsetMs;
  }
 else {
    return System.currentTimeMillis() * 1000;
  }
}

Fixed version (ground truth):
private long getNowUnixTimeUs(){
  if (elapsedRealtimeOffsetMs != 0) {
    return (SystemClock.elapsedRealtime() + elapsedRealtimeOffsetMs) * 1000;
  }
 else {
    return System.currentTimeMillis() * 1000;
  }
}
Program: 110366
Project: 110366
Buggy source:
private long getNowUnixTimeUs(){
  if (elapsedRealtimeOffsetUs != 0) {
    return (SystemClock.elapsedRealtime() * 1000) + elapsedRealtimeOffsetUs;
  }
 else {
    return System.currentTimeMillis() * 1000;
  }
}

Fixed version (ground truth):
private long getNowUnixTimeUs(){
  if (elapsedRealtimeOffsetMs != 0) {
    return (SystemClock.elapsedRealtime() + elapsedRealtimeOffsetMs) * 1000;
  }
 else {
    return System.currentTimeMillis() * 1000;
  }
}
Program: 110368
Project: 110368
Buggy source:
@Override public void onContinueLoadingRequested(SampleSource ignored){
  callback.onContinueLoadingRequested(this);
}

Fixed version (ground truth):
@Override public void onContinueLoadingRequested(SampleSource ignored){
  if (trackGroups == null) {
    return;
  }
  callback.onContinueLoadingRequested(this);
}
Program: 110369
Project: 110369
Buggy source:
/** 
 * @param baseUri The playlist's base uri.
 * @param variants The available variants.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param timestampAdjusterProvider A provider of {@link PtsTimestampAdjuster} instances. Ifmultiple  {@link HlsChunkSource}s are used for a single playback, they should all share the same provider.
 * @param adaptiveFormatEvaluator For adaptive tracks, selects from the available formats.
 */
public HlsChunkSource(String baseUri,Variant[] variants,DataSource dataSource,PtsTimestampAdjusterProvider timestampAdjusterProvider,FormatEvaluator adaptiveFormatEvaluator){
  this.baseUri=baseUri;
  this.variants=variants;
  this.dataSource=dataSource;
  this.adaptiveFormatEvaluator=adaptiveFormatEvaluator;
  this.timestampAdjusterProvider=timestampAdjusterProvider;
  playlistParser=new HlsPlaylistParser();
  evaluation=new Evaluation();
  variantPlaylists=new HlsMediaPlaylist[variants.length];
  variantLastPlaylistLoadTimesMs=new long[variants.length];
  int[] initialTrackSelection=new int[variants.length];
  for (int i=0; i < variants.length; i++) {
    initialTrackSelection[i]=i;
  }
  selectTracksInternal(initialTrackSelection,false);
  initialEnabledVariantIndex=getEnabledVariantIndex(variants[0].format);
}

Fixed version (ground truth):
/** 
 * @param baseUri The playlist's base uri.
 * @param variants The available variants.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param timestampAdjusterProvider A provider of {@link PtsTimestampAdjuster} instances. Ifmultiple  {@link HlsChunkSource}s are used for a single playback, they should all share the same provider.
 * @param adaptiveFormatEvaluator For adaptive tracks, selects from the available formats.
 */
public HlsChunkSource(String baseUri,Variant[] variants,DataSource dataSource,PtsTimestampAdjusterProvider timestampAdjusterProvider,FormatEvaluator adaptiveFormatEvaluator){
  this.baseUri=baseUri;
  this.variants=variants;
  this.dataSource=dataSource;
  this.adaptiveFormatEvaluator=adaptiveFormatEvaluator;
  this.timestampAdjusterProvider=timestampAdjusterProvider;
  playlistParser=new HlsPlaylistParser();
  evaluation=new Evaluation();
  variantPlaylists=new HlsMediaPlaylist[variants.length];
  variantLastPlaylistLoadTimesMs=new long[variants.length];
  int[] initialTrackSelection=new int[variants.length];
  for (int i=0; i < variants.length; i++) {
    initialTrackSelection[i]=i;
  }
  selectTracksInternal(initialTrackSelection,false);
}