Program: 35732
Project: 35732
Buggy source:
private boolean audioEncodeStep(boolean isEnd){
  if (isRecordAudioStarted) {
    int inputIndex=mAudioEncoder.dequeueInputBuffer(TIME_OUT);
    if (inputIndex >= 0) {
      ByteBuffer buffer=getInputBuffer(mAudioEncoder,inputIndex);
      buffer.clear();
      long time=(System.currentTimeMillis() - BASE_TIME) * 1000;
      int length=mAudioRecord.read(buffer,mRecordBufferSize);
      if (length >= 0) {
        mAudioEncoder.queueInputBuffer(inputIndex,0,length,time,isEnd ? MediaCodec.BUFFER_FLAG_END_OF_STREAM : 0);
      }
    }
    while (true) {
      int outputIndex=mAudioEncoder.dequeueOutputBuffer(mAudioEncodeBufferInfo,TIME_OUT);
      if (outputIndex >= 0) {
        if (isMuxStarted && mAudioEncodeBufferInfo.size > 0 && mAudioEncodeBufferInfo.presentationTimeUs > 0) {
          mMuxer.writeSampleData(mAudioTrack,getOutputBuffer(mAudioEncoder,outputIndex),mAudioEncodeBufferInfo);
        }
        mAudioEncoder.releaseOutputBuffer(outputIndex,false);
        if (mAudioEncodeBufferInfo.flags == MediaCodec.BUFFER_FLAG_END_OF_STREAM) {
          Log.d(Aavt.debugTag,"String_Node_Str");
          isTryStopAudio=false;
          isRecordAudioStarted=false;
          return true;
        }
      }
 else       if (outputIndex == MediaCodec.INFO_TRY_AGAIN_LATER) {
        break;
      }
 else       if (outputIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
        Log.e(Aavt.debugTag,"String_Node_Str" + mAudioEncoder.getOutputFormat().toString());
synchronized (VIDEO_LOCK) {
          mAudioTrack=mMuxer.addTrack(mAudioEncoder.getOutputFormat());
          isRecordVideoStarted=true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean audioEncodeStep(boolean isEnd){
  if (isRecordAudioStarted) {
    int inputIndex=mAudioEncoder.dequeueInputBuffer(TIME_OUT);
    if (inputIndex >= 0) {
      ByteBuffer buffer=getInputBuffer(mAudioEncoder,inputIndex);
      buffer.clear();
      long time=(System.currentTimeMillis() - BASE_TIME) * 1000;
      int length=mAudioRecord.read(buffer,mRecordBufferSize);
      if (length >= 0) {
        mAudioEncoder.queueInputBuffer(inputIndex,0,length,time,isEnd ? MediaCodec.BUFFER_FLAG_END_OF_STREAM : 0);
      }
    }
    while (true) {
      int outputIndex=mAudioEncoder.dequeueOutputBuffer(mAudioEncodeBufferInfo,TIME_OUT);
      if (outputIndex >= 0) {
        if (isMuxStarted && mAudioEncodeBufferInfo.size > 0 && mAudioEncodeBufferInfo.presentationTimeUs > 0) {
          mMuxer.writeSampleData(mAudioTrack,getOutputBuffer(mAudioEncoder,outputIndex),mAudioEncodeBufferInfo);
        }
        mAudioEncoder.releaseOutputBuffer(outputIndex,false);
        if (mAudioEncodeBufferInfo.flags == MediaCodec.BUFFER_FLAG_END_OF_STREAM) {
          AvLog.d("String_Node_Str");
          isTryStopAudio=false;
          isRecordAudioStarted=false;
          return true;
        }
      }
 else       if (outputIndex == MediaCodec.INFO_TRY_AGAIN_LATER) {
        break;
      }
 else       if (outputIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
        AvLog.d("String_Node_Str" + mAudioEncoder.getOutputFormat().toString());
synchronized (VIDEO_LOCK) {
          mAudioTrack=mMuxer.addTrack(mAudioEncoder.getOutputFormat());
          isRecordVideoStarted=true;
        }
      }
    }
  }
  return false;
}