Program: 30920
Project: 30920
Buggy source:
@Override public void run(){
  try {
    mVideoCodec=MediaCodec.createDecoderByType(mVideoFormat.getString(MediaFormat.KEY_MIME));
    mVideoCodec.configure(mVideoFormat,mSurface,null,0);
    mVideoCodec.start();
    mVideoCodecInputBuffers=mVideoCodec.getInputBuffers();
    mVideoCodecOutputBuffers=mVideoCodec.getOutputBuffers();
    mVideoInfo=new MediaCodec.BufferInfo();
    mVideoInputEos=false;
    mVideoOutputEos=false;
    if (mAudioFormat != null) {
      mAudioCodec=MediaCodec.createDecoderByType(mAudioFormat.getString(MediaFormat.KEY_MIME));
      mAudioCodec.configure(mAudioFormat,null,null,0);
      mAudioCodec.start();
      mAudioCodecInputBuffers=mAudioCodec.getInputBuffers();
      mAudioCodecOutputBuffers=mAudioCodec.getOutputBuffers();
      mAudioInfo=new MediaCodec.BufferInfo();
      mAudioInputEos=false;
      mAudioOutputEos=false;
      mAudioPlayback=new AudioPlayback();
      mAudioPlayback.setAudioSessionId(mAudioSessionId);
      mAudioPlayback.init(mAudioFormat);
      mAudioSessionId=mAudioPlayback.getAudioSessionId();
    }
    mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_SET_VIDEO_SIZE,getVideoWidth(),getVideoHeight()));
    mBuffering=false;
    boolean preparing=true;
    int frameSkipCount=0;
    long lastPTS=0;
    mTimeBase.startAt(mVideoMinPTS);
    while (!mVideoOutputEos) {
      if (mPaused && !mSeekPrepare && !mSeeking&& !preparing) {
        if (mAudioPlayback != null)         mAudioPlayback.pause();
synchronized (this) {
          while (mPaused && !mSeekPrepare && !mSeeking) {
            this.wait();
          }
        }
        if (mAudioPlayback != null)         mAudioPlayback.play();
        mTimeBase.startAt(mVideoInfo.presentationTimeUs);
      }
      if (mSeekPrepare) {
        Log.d(TAG,"String_Node_Str" + mSeekTargetTime);
        Log.d(TAG,"String_Node_Str" + mCurrentPosition);
        Log.d(TAG,"String_Node_Str" + mVideoExtractor.getSampleTime());
        mVideoExtractor.seekTo(mSeekTargetTime,MediaExtractor.SEEK_TO_PREVIOUS_SYNC);
        mCurrentPosition=mSeekTargetTime;
        Log.d(TAG,"String_Node_Str" + mVideoExtractor.getSampleTime());
        mVideoCodec.flush();
        if (mAudioFormat != null)         mAudioCodec.flush();
        if (mVideoExtractor.hasTrackFormatChanged()) {
          reinitCodecs();
          mRepresentationChanged=true;
        }
        mSeekPrepare=false;
        mSeeking=true;
        if (mSeekMode == SeekMode.FAST_EXACT) {
          long in;
          long out;
          do {
            in=mSeekTargetTime;
            out=fastSeek(in);
          }
 while (in != mSeekTargetTime);
          mSeekTargetTime=out;
          mSeekPrepare=false;
        }
      }
      if (!mVideoInputEos && !mRepresentationChanging) {
        queueMediaSampleToCodec(mSeeking);
      }
      lastPTS=mVideoInfo.presentationTimeUs;
      int res=mVideoCodec.dequeueOutputBuffer(mVideoInfo,mTimeOutUs);
      mVideoOutputEos=res >= 0 && (mVideoInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
      if (mVideoOutputEos && mRepresentationChanging) {
        reinitCodecs();
        mVideoOutputEos=false;
        mRepresentationChanging=false;
        mRepresentationChanged=true;
      }
 else       if (res >= 0) {
        int outputBufIndex=res;
        boolean render=true;
        if (mSeeking) {
          if (mVideoOutputEos) {
            mSeekTargetTime=mVideoInfo.presentationTimeUs;
          }
          long presentationTimeMs=mVideoInfo.presentationTimeUs / 1000;
          long seekTargetTimeMs=mSeekTargetTime / 1000;
          if ((mSeekMode == SeekMode.PRECISE || mSeekMode == SeekMode.EXACT) && presentationTimeMs < seekTargetTimeMs) {
            render=false;
            if (frameSkipCount == 0) {
              Log.d(TAG,"String_Node_Str");
            }
            frameSkipCount++;
          }
 else {
            Log.d(TAG,"String_Node_Str" + mVideoInfo.presentationTimeUs);
            Log.d(TAG,"String_Node_Str" + frameSkipCount + "String_Node_Str");
            frameSkipCount=0;
            if (mSeekMode == SeekMode.EXACT && presentationTimeMs > seekTargetTimeMs) {
              Log.d(TAG,"String_Node_Str" + lastPTS);
              render=false;
              seekTo(lastPTS);
            }
 else {
              if (presentationTimeMs == seekTargetTimeMs) {
                Log.d(TAG,"String_Node_Str");
              }
              if (mSeekMode == SeekMode.FAST_EXACT && mVideoInfo.presentationTimeUs < mSeekTargetTime) {
                Log.d(TAG,"String_Node_Str");
              }
 else {
                mTimeBase.startAt(mVideoInfo.presentationTimeUs);
                mCurrentPosition=mVideoInfo.presentationTimeUs;
                mSeeking=false;
                if (mAudioExtractor != null) {
                  mAudioExtractor.seekTo(mVideoInfo.presentationTimeUs,MediaExtractor.SEEK_TO_CLOSEST_SYNC);
                  mAudioPlayback.flush();
                }
                mEventHandler.sendEmptyMessage(MEDIA_SEEK_COMPLETE);
              }
            }
          }
        }
 else {
          mCurrentPosition=mVideoInfo.presentationTimeUs;
          long waitingTime=mTimeBase.getOffsetFrom(mVideoInfo.presentationTimeUs);
          if (mAudioFormat != null) {
            long audioOffsetUs=mAudioPlayback.getLastPresentationTimeUs() - mCurrentPosition;
            long audioOffsetCorrectionUs=10000;
            if (audioOffsetUs > audioOffsetCorrectionUs) {
              waitingTime-=audioOffsetCorrectionUs;
            }
 else             if (audioOffsetUs < -audioOffsetCorrectionUs) {
              waitingTime+=audioOffsetCorrectionUs;
            }
            mAudioPlayback.setPlaybackSpeed((float)mTimeBase.getSpeed());
          }
          long cachedDuration=mVideoExtractor.getCachedDuration();
          if (cachedDuration != -1) {
            mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_BUFFERING_UPDATE,(int)(100d / mVideoFormat.getLong(MediaFormat.KEY_DURATION) * (mCurrentPosition + cachedDuration)),0));
          }
          if (waitingTime > 5000) {
            Thread.sleep(waitingTime / 1000);
          }
 else           if (!preparing && waitingTime < 0) {
            mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_TRACK_LAGGING,0));
            mTimeBase.startAt(mVideoInfo.presentationTimeUs);
          }
        }
        if (mBuffering) {
          mBuffering=false;
          mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_BUFFERING_END,0));
        }
        if (mRepresentationChanged && render) {
          mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_SET_VIDEO_SIZE,getVideoWidth(),getVideoHeight()));
          mRepresentationChanged=false;
        }
        mVideoCodec.releaseOutputBuffer(outputBufIndex,render);
        if (mAudioFormat != null & mAudioExtractor != null && !mSeeking && !mPaused) {
          long start=SystemClock.elapsedRealtime();
          while (mAudioPlayback.getBufferTimeUs() < 100000) {
            if (queueAudioSampleToCodec(mAudioExtractor)) {
              decodeAudioSample();
            }
 else {
              break;
            }
          }
        }
        if (preparing) {
          mEventHandler.sendEmptyMessage(MEDIA_PREPARED);
          preparing=false;
          mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_RENDERING_START,0));
        }
        if (mVideoOutputEos) {
          Log.d(TAG,"String_Node_Str");
          mEventHandler.sendEmptyMessage(MEDIA_PLAYBACK_COMPLETE);
          mPaused=true;
synchronized (this) {
            if (mAudioPlayback != null)             mAudioPlayback.pause();
            while (mPaused && !mSeeking && !mSeekPrepare) {
              this.wait();
            }
            if (mAudioPlayback != null)             mAudioPlayback.play();
            mVideoInputEos=false;
            mVideoOutputEos=false;
            mAudioInputEos=false;
            mAudioOutputEos=false;
            if (!mSeeking && !mSeekPrepare) {
              seekTo(0);
            }
          }
        }
      }
 else       if (res == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
        mVideoCodecOutputBuffers=mVideoCodec.getOutputBuffers();
        Log.d(TAG,"String_Node_Str");
      }
 else       if (res == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
        MediaFormat oformat=mVideoCodec.getOutputFormat();
        Log.d(TAG,"String_Node_Str" + oformat);
      }
 else       if (res == MediaCodec.INFO_TRY_AGAIN_LATER) {
        Log.d(TAG,"String_Node_Str");
      }
    }
  }
 catch (  InterruptedException e) {
    Log.d(TAG,"String_Node_Str");
    interrupt();
    if (mIsStopping) {
      mIsStopping=false;
    }
 else {
      mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_ERROR,MEDIA_ERROR_UNKNOWN,0));
    }
  }
catch (  IllegalStateException e) {
    Log.e(TAG,"String_Node_Str",e);
    mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_ERROR,MEDIA_ERROR_UNKNOWN,0));
  }
catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
    mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_ERROR,MEDIA_ERROR_UNKNOWN,MEDIA_ERROR_IO));
  }
  if (mAudioPlayback != null)   mAudioPlayback.stopAndRelease();
  mVideoCodec.stop();
  mVideoCodec.release();
  if (mAudioFormat != null) {
    mAudioCodec.stop();
    mAudioCodec.release();
  }
  mVideoExtractor.release();
  Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void run(){
  try {
    mVideoCodec=MediaCodec.createDecoderByType(mVideoFormat.getString(MediaFormat.KEY_MIME));
    mVideoCodec.configure(mVideoFormat,mSurface,null,0);
    mVideoCodec.start();
    mVideoCodecInputBuffers=mVideoCodec.getInputBuffers();
    mVideoCodecOutputBuffers=mVideoCodec.getOutputBuffers();
    mVideoInfo=new MediaCodec.BufferInfo();
    mVideoInputEos=false;
    mVideoOutputEos=false;
    if (mAudioFormat != null) {
      mAudioCodec=MediaCodec.createDecoderByType(mAudioFormat.getString(MediaFormat.KEY_MIME));
      mAudioCodec.configure(mAudioFormat,null,null,0);
      mAudioCodec.start();
      mAudioCodecInputBuffers=mAudioCodec.getInputBuffers();
      mAudioCodecOutputBuffers=mAudioCodec.getOutputBuffers();
      mAudioInfo=new MediaCodec.BufferInfo();
      mAudioInputEos=false;
      mAudioOutputEos=false;
      mAudioPlayback=new AudioPlayback();
      mAudioPlayback.setAudioSessionId(mAudioSessionId);
      mAudioPlayback.init(mAudioFormat);
      mAudioSessionId=mAudioPlayback.getAudioSessionId();
    }
    mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_SET_VIDEO_SIZE,getVideoWidth(),getVideoHeight()));
    mBuffering=false;
    boolean preparing=true;
    int frameSkipCount=0;
    long lastPTS=0;
    mTimeBase.startAt(mVideoMinPTS);
    while (!mVideoOutputEos) {
      if (mPaused && !mSeekPrepare && !mSeeking&& !preparing) {
        if (mAudioPlayback != null)         mAudioPlayback.pause();
synchronized (this) {
          while (mPaused && !mSeekPrepare && !mSeeking) {
            this.wait();
          }
        }
        if (mAudioPlayback != null)         mAudioPlayback.play();
        mTimeBase.startAt(mVideoInfo.presentationTimeUs);
      }
      while (mSeekPrepare) {
        mSeekPrepare=false;
        mSeeking=true;
        Log.d(TAG,"String_Node_Str" + mSeekTargetTime);
        Log.d(TAG,"String_Node_Str" + mCurrentPosition);
        Log.d(TAG,"String_Node_Str" + mVideoExtractor.getSampleTime());
        mVideoExtractor.seekTo(mSeekTargetTime,MediaExtractor.SEEK_TO_PREVIOUS_SYNC);
        mCurrentPosition=mSeekTargetTime;
        Log.d(TAG,"String_Node_Str" + mVideoExtractor.getSampleTime());
        if (mSeekPrepare) {
          continue;
        }
        mVideoCodec.flush();
        if (mAudioFormat != null)         mAudioCodec.flush();
        if (mVideoExtractor.hasTrackFormatChanged()) {
          reinitCodecs();
          mRepresentationChanged=true;
        }
        if (mSeekMode == SeekMode.FAST_EXACT) {
          long in;
          long out;
          do {
            in=mSeekTargetTime;
            out=fastSeek(in);
          }
 while (in != mSeekTargetTime);
          mSeekTargetTime=out;
          mSeekPrepare=false;
        }
      }
      if (!mVideoInputEos && !mRepresentationChanging) {
        queueMediaSampleToCodec(mSeeking);
      }
      lastPTS=mVideoInfo.presentationTimeUs;
      int res=mVideoCodec.dequeueOutputBuffer(mVideoInfo,mTimeOutUs);
      mVideoOutputEos=res >= 0 && (mVideoInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
      if (mVideoOutputEos && mRepresentationChanging) {
        reinitCodecs();
        mVideoOutputEos=false;
        mRepresentationChanging=false;
        mRepresentationChanged=true;
      }
 else       if (res >= 0) {
        int outputBufIndex=res;
        boolean render=true;
        if (mSeeking) {
          if (mVideoOutputEos) {
            mSeekTargetTime=mVideoInfo.presentationTimeUs;
          }
          long presentationTimeMs=mVideoInfo.presentationTimeUs / 1000;
          long seekTargetTimeMs=mSeekTargetTime / 1000;
          if ((mSeekMode == SeekMode.PRECISE || mSeekMode == SeekMode.EXACT) && presentationTimeMs < seekTargetTimeMs) {
            render=false;
            if (frameSkipCount == 0) {
              Log.d(TAG,"String_Node_Str");
            }
            frameSkipCount++;
          }
 else {
            Log.d(TAG,"String_Node_Str" + mVideoInfo.presentationTimeUs);
            Log.d(TAG,"String_Node_Str" + frameSkipCount + "String_Node_Str");
            frameSkipCount=0;
            if (mSeekMode == SeekMode.EXACT && presentationTimeMs > seekTargetTimeMs) {
              Log.d(TAG,"String_Node_Str" + lastPTS);
              render=false;
              seekTo(lastPTS);
            }
 else {
              if (presentationTimeMs == seekTargetTimeMs) {
                Log.d(TAG,"String_Node_Str");
              }
              if (mSeekMode == SeekMode.FAST_EXACT && mVideoInfo.presentationTimeUs < mSeekTargetTime) {
                Log.d(TAG,"String_Node_Str");
              }
 else {
                mTimeBase.startAt(mVideoInfo.presentationTimeUs);
                mCurrentPosition=mVideoInfo.presentationTimeUs;
                mSeeking=false;
                if (mAudioExtractor != null) {
                  mAudioExtractor.seekTo(mVideoInfo.presentationTimeUs,MediaExtractor.SEEK_TO_CLOSEST_SYNC);
                  mAudioPlayback.flush();
                }
                mEventHandler.sendEmptyMessage(MEDIA_SEEK_COMPLETE);
              }
            }
          }
        }
 else {
          mCurrentPosition=mVideoInfo.presentationTimeUs;
          long waitingTime=mTimeBase.getOffsetFrom(mVideoInfo.presentationTimeUs);
          if (mAudioFormat != null) {
            long audioOffsetUs=mAudioPlayback.getLastPresentationTimeUs() - mCurrentPosition;
            long audioOffsetCorrectionUs=10000;
            if (audioOffsetUs > audioOffsetCorrectionUs) {
              waitingTime-=audioOffsetCorrectionUs;
            }
 else             if (audioOffsetUs < -audioOffsetCorrectionUs) {
              waitingTime+=audioOffsetCorrectionUs;
            }
            mAudioPlayback.setPlaybackSpeed((float)mTimeBase.getSpeed());
          }
          long cachedDuration=mVideoExtractor.getCachedDuration();
          if (cachedDuration != -1) {
            mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_BUFFERING_UPDATE,(int)(100d / mVideoFormat.getLong(MediaFormat.KEY_DURATION) * (mCurrentPosition + cachedDuration)),0));
          }
          if (waitingTime > 5000) {
            Thread.sleep(waitingTime / 1000);
          }
 else           if (!preparing && waitingTime < 0) {
            mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_TRACK_LAGGING,0));
            mTimeBase.startAt(mVideoInfo.presentationTimeUs);
          }
        }
        if (mBuffering) {
          mBuffering=false;
          mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_BUFFERING_END,0));
        }
        if (mRepresentationChanged && render) {
          mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_SET_VIDEO_SIZE,getVideoWidth(),getVideoHeight()));
          mRepresentationChanged=false;
        }
        mVideoCodec.releaseOutputBuffer(outputBufIndex,render);
        if (mAudioFormat != null & mAudioExtractor != null && !mSeeking && !mPaused) {
          long start=SystemClock.elapsedRealtime();
          while (mAudioPlayback.getBufferTimeUs() < 100000) {
            if (queueAudioSampleToCodec(mAudioExtractor)) {
              decodeAudioSample();
            }
 else {
              break;
            }
          }
        }
        if (preparing) {
          mEventHandler.sendEmptyMessage(MEDIA_PREPARED);
          preparing=false;
          mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_RENDERING_START,0));
        }
        if (mVideoOutputEos) {
          Log.d(TAG,"String_Node_Str");
          mEventHandler.sendEmptyMessage(MEDIA_PLAYBACK_COMPLETE);
          mPaused=true;
synchronized (this) {
            if (mAudioPlayback != null)             mAudioPlayback.pause();
            while (mPaused && !mSeeking && !mSeekPrepare) {
              this.wait();
            }
            if (mAudioPlayback != null)             mAudioPlayback.play();
            mVideoInputEos=false;
            mVideoOutputEos=false;
            mAudioInputEos=false;
            mAudioOutputEos=false;
            if (!mSeeking && !mSeekPrepare) {
              seekTo(0);
            }
          }
        }
      }
 else       if (res == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
        mVideoCodecOutputBuffers=mVideoCodec.getOutputBuffers();
        Log.d(TAG,"String_Node_Str");
      }
 else       if (res == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
        MediaFormat oformat=mVideoCodec.getOutputFormat();
        Log.d(TAG,"String_Node_Str" + oformat);
      }
 else       if (res == MediaCodec.INFO_TRY_AGAIN_LATER) {
        Log.d(TAG,"String_Node_Str");
      }
    }
  }
 catch (  InterruptedException e) {
    Log.d(TAG,"String_Node_Str");
    interrupt();
    if (mIsStopping) {
      mIsStopping=false;
    }
 else {
      mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_ERROR,MEDIA_ERROR_UNKNOWN,0));
    }
  }
catch (  IllegalStateException e) {
    Log.e(TAG,"String_Node_Str",e);
    mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_ERROR,MEDIA_ERROR_UNKNOWN,0));
  }
catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
    mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_ERROR,MEDIA_ERROR_UNKNOWN,MEDIA_ERROR_IO));
  }
  if (mAudioPlayback != null)   mAudioPlayback.stopAndRelease();
  mVideoCodec.stop();
  mVideoCodec.release();
  if (mAudioFormat != null) {
    mAudioCodec.stop();
    mAudioCodec.release();
  }
  mVideoExtractor.release();
  Log.d(TAG,"String_Node_Str");
}