title: Presentation time of samples quickly grows larger than total duration
body: <p>I'm using MediaCodec to decode audio tracks. My decoding class works fine for playing the audio. I'm trying to show the progress of the track in a SeekBar, using the total track duration and the total played time. I have two longs, one which records the total duration of the track in microseconds, and another which records the total played time of the track in microseconds. </p>
  
  <p>The problem I am having is the played duration quickly becomes larger than the total duration of the track. I don't understand where I'm going wrong.</p>
  
  <p>long declarations in decoding class:</p>
  
  <pre><code>private long durationUs; //track duration in us
  private volatile long currentTimeUs; //total played duration thus far
  </code></pre>
  
  <p>Determining the total duration in ctor:</p>
  
  <pre><code>extractor = new MediaExtractor();
  extractor.setDataSource(fullPath);
  
  format = extractor.getTrackFormat(0);
  String mime = format.getString(MediaFormat.KEY_MIME);
  durationUs = format.getLong(MediaFormat.KEY_DURATION);
  </code></pre>
  
  <p>Method where I add the time of the input sample to currentTimeUs:</p>
  
  <pre><code>private void advanceInput()
  {
      boolean sawInputEOS = false;
  
      int inputBufIndex = codec.dequeueInputBuffer(TIMEOUT_US);
      if (inputBufIndex &gt;= 0)
      {
          ByteBuffer dstBuf = codecInputBuffers[inputBufIndex];
  
          int sampleSize = extractor.readSampleData(dstBuf, 0);
          long presentationTimeUs = 0;
  
          if (sampleSize &lt; 0)
          {
              sawInputEOS = true;
              sampleSize = 0;
          }
          else
          {
              presentationTimeUs = extractor.getSampleTime();
              currentTimeUs += presentationTimeUs;
          }
  
          codec.queueInputBuffer(inputBufIndex,
                  0,
                  sampleSize,
                  presentationTimeUs,
                  sawInputEOS ? MediaCodec.BUFFER_FLAG_END_OF_STREAM : 0);
          if (!sawInputEOS)
          {
              extractor.advance();
          }
      }
  }
  </code></pre>