diff options
-rw-r--r-- | media/filters/ffmpeg_audio_decoder.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc index 6f4f5e1..e103093 100644 --- a/media/filters/ffmpeg_audio_decoder.cc +++ b/media/filters/ffmpeg_audio_decoder.cc @@ -128,9 +128,16 @@ void FFmpegAudioDecoder::OnDecode(Buffer* input) { result_buffer->SetTimestamp(input->GetTimestamp()); } - // Update our estimated timestamp for the next packet. - estimated_next_timestamp_ = result_buffer->GetTimestamp() + - result_buffer->GetDuration(); + // Only use the timestamp of |result_buffer| to estimate the next timestamp + // if it is valid (i.e. greater than 0). Otherwise the error will stack + // together and we will get a series of incorrect timestamps. In this case, + // this will maintain a series of zero timestamps. + // TODO(hclam): We should use another invalid value other than 0. + if (result_buffer->GetTimestamp().InMicroseconds() > 0) { + // Update our estimated timestamp for the next packet. + estimated_next_timestamp_ = result_buffer->GetTimestamp() + + result_buffer->GetDuration(); + } EnqueueResult(result_buffer); return; |