Program: 30918
Project: 30918
Buggy source:
@Override public void run(){
  try {
    Decoder.VideoFrameInfo videoFrameInfo;
    if (mAudioPlayback != null)     mAudioPlayback.play();
    while ((videoFrameInfo=mDecoder.decodeFrame(false)) != null) {
      if (mPaused && !mSeekPrepare) {
        if (mAudioPlayback != null)         mAudioPlayback.pause();
synchronized (this) {
          while (mPaused && !mSeekPrepare) {
            this.wait();
          }
        }
        if (mAudioPlayback != null)         mAudioPlayback.play();
        mTimeBase.startAt(videoFrameInfo.presentationTimeUs);
      }
      if (mBuffering) {
        mBuffering=false;
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_BUFFERING_END,0));
      }
      while (mSeekPrepare) {
        mSeekPrepare=false;
        mCurrentPosition=mSeekTargetTime;
        mDecoder.releaseFrame(videoFrameInfo,false);
        if (mAudioPlayback != null)         mAudioPlayback.flush();
        videoFrameInfo=mDecoder.seekTo(mSeekMode,mSeekTargetTime);
        mTimeBase.startAt(videoFrameInfo.presentationTimeUs);
        mCurrentPosition=videoFrameInfo.presentationTimeUs;
        if (!mSeekPrepare) {
          mEventHandler.sendEmptyMessage(MEDIA_SEEK_COMPLETE);
        }
      }
      mCurrentPosition=videoFrameInfo.presentationTimeUs;
      long waitingTime=mTimeBase.getOffsetFrom(videoFrameInfo.presentationTimeUs);
      if (mAudioPlayback != 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 (waitingTime < 0) {
        Log.d(TAG,"String_Node_Str" + waitingTime);
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_TRACK_LAGGING,0));
        mTimeBase.startAt(videoFrameInfo.presentationTimeUs);
      }
      if (videoFrameInfo.representationChanged) {
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_SET_VIDEO_SIZE,videoFrameInfo.width,videoFrameInfo.height));
      }
      boolean videoOutputEos=videoFrameInfo.endOfStream;
      mDecoder.releaseFrame(videoFrameInfo,true);
      if (mRenderingStarted) {
        mRenderingStarted=false;
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_RENDERING_START,0));
      }
      if (videoOutputEos) {
        mEventHandler.sendEmptyMessage(MEDIA_PLAYBACK_COMPLETE);
        mPaused=!mLooping;
synchronized (this) {
          if (mAudioPlayback != null)           mAudioPlayback.pause();
          while (mPaused) {
            this.wait();
          }
          if (mAudioPlayback != null)           mAudioPlayback.play();
          if (!mSeekPrepare) {
            videoFrameInfo=mDecoder.seekTo(SeekMode.FAST,0);
            mDecoder.releaseFrame(videoFrameInfo,true);
          }
        }
      }
    }
  }
 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 (mDecoder != null)   mDecoder.release();
  if (mAudioPlayback != null)   mAudioPlayback.stopAndRelease();
  if (mAudioExtractor != null & mAudioExtractor != mVideoExtractor) {
    mAudioExtractor.release();
  }
  mVideoExtractor.release();
  Log.d(TAG,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void run(){
  try {
    Decoder.VideoFrameInfo videoFrameInfo;
    while ((videoFrameInfo=mDecoder.decodeFrame(false)) != null) {
      if (mPaused && !mSeekPrepare) {
        if (mAudioPlayback != null)         mAudioPlayback.pause();
synchronized (this) {
          while (mPaused && !mSeekPrepare) {
            this.wait();
          }
        }
        mTimeBase.startAt(videoFrameInfo.presentationTimeUs);
      }
      if (mAudioPlayback != null && !mAudioPlayback.isPlaying() && !mPaused && !mSeekPrepare) {
        mAudioPlayback.play();
      }
      if (mBuffering) {
        mBuffering=false;
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_BUFFERING_END,0));
      }
      while (mSeekPrepare) {
        mSeekPrepare=false;
        mCurrentPosition=mSeekTargetTime;
        mDecoder.releaseFrame(videoFrameInfo,false);
        if (mAudioPlayback != null)         mAudioPlayback.pause(true);
        videoFrameInfo=mDecoder.seekTo(mSeekMode,mSeekTargetTime);
        mTimeBase.startAt(videoFrameInfo.presentationTimeUs);
        mCurrentPosition=videoFrameInfo.presentationTimeUs;
        if (!mSeekPrepare) {
          mEventHandler.sendEmptyMessage(MEDIA_SEEK_COMPLETE);
        }
      }
      mCurrentPosition=videoFrameInfo.presentationTimeUs;
      long waitingTime=mTimeBase.getOffsetFrom(videoFrameInfo.presentationTimeUs);
      if (mAudioPlayback != 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 (waitingTime < 0) {
        Log.d(TAG,"String_Node_Str" + waitingTime);
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_TRACK_LAGGING,0));
        mTimeBase.startAt(videoFrameInfo.presentationTimeUs);
      }
      if (videoFrameInfo.representationChanged) {
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_SET_VIDEO_SIZE,videoFrameInfo.width,videoFrameInfo.height));
      }
      boolean videoOutputEos=videoFrameInfo.endOfStream;
      mDecoder.releaseFrame(videoFrameInfo,true);
      if (mRenderingStarted) {
        mRenderingStarted=false;
        mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_INFO,MEDIA_INFO_VIDEO_RENDERING_START,0));
      }
      if (videoOutputEos) {
        mEventHandler.sendEmptyMessage(MEDIA_PLAYBACK_COMPLETE);
        mPaused=!mLooping;
synchronized (this) {
          if (mAudioPlayback != null)           mAudioPlayback.pause();
          while (mPaused) {
            this.wait();
          }
          if (mAudioPlayback != null)           mAudioPlayback.play();
          if (!mSeekPrepare) {
            videoFrameInfo=mDecoder.seekTo(SeekMode.FAST,0);
            mDecoder.releaseFrame(videoFrameInfo,true);
          }
        }
      }
    }
  }
 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 (mDecoder != null)   mDecoder.release();
  if (mAudioPlayback != null)   mAudioPlayback.stopAndRelease();
  if (mAudioExtractor != null & mAudioExtractor != mVideoExtractor) {
    mAudioExtractor.release();
  }
  mVideoExtractor.release();
  Log.d(TAG,"String_Node_Str");
}