| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/ffmpeg_audio_decoder.h" | 5 #include "media/filters/ffmpeg_audio_decoder.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "media/base/audio_buffer.h" | 9 #include "media/base/audio_buffer.h" |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Any time Reset() is called. | 242 // Any time Reset() is called. |
| 243 | 243 |
| 244 // Make sure we are notified if http://crbug.com/49709 returns. Issue also | 244 // Make sure we are notified if http://crbug.com/49709 returns. Issue also |
| 245 // occurs with some damaged files. | 245 // occurs with some damaged files. |
| 246 if (!buffer->end_of_stream() && buffer->timestamp() == kNoTimestamp()) { | 246 if (!buffer->end_of_stream() && buffer->timestamp() == kNoTimestamp()) { |
| 247 DVLOG(1) << "Received a buffer without timestamps!"; | 247 DVLOG(1) << "Received a buffer without timestamps!"; |
| 248 decode_cb.Run(kDecodeError); | 248 decode_cb.Run(kDecodeError); |
| 249 return; | 249 return; |
| 250 } | 250 } |
| 251 | 251 |
| 252 if (!buffer->end_of_stream() && !discard_helper_->initialized() && | |
| 253 codec_context_->codec_id == AV_CODEC_ID_VORBIS && | |
| 254 buffer->timestamp() < base::TimeDelta()) { | |
| 255 // Dropping frames for negative timestamps as outlined in section A.2 | |
| 256 // in the Vorbis spec. http://xiph.org/vorbis/doc/Vorbis_I_spec.html | |
| 257 const int discard_frames = | |
| 258 discard_helper_->TimeDeltaToFrames(-buffer->timestamp()); | |
| 259 discard_helper_->Reset(discard_frames); | |
| 260 } | |
| 261 | |
| 262 if (!FFmpegDecode(buffer)) { | 252 if (!FFmpegDecode(buffer)) { |
| 263 state_ = kError; | 253 state_ = kError; |
| 264 decode_cb.Run(kDecodeError); | 254 decode_cb.Run(kDecodeError); |
| 265 return; | 255 return; |
| 266 } | 256 } |
| 267 | 257 |
| 268 if (buffer->end_of_stream()) { | 258 if (buffer->end_of_stream()) { |
| 269 state_ = kDecodeFinished; | 259 state_ = kDecodeFinished; |
| 270 output_cb_.Run(AudioBuffer::CreateEOSBuffer()); | 260 output_cb_.Run(AudioBuffer::CreateEOSBuffer()); |
| 271 } | 261 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 415 |
| 426 ResetTimestampState(); | 416 ResetTimestampState(); |
| 427 return true; | 417 return true; |
| 428 } | 418 } |
| 429 | 419 |
| 430 void FFmpegAudioDecoder::ResetTimestampState() { | 420 void FFmpegAudioDecoder::ResetTimestampState() { |
| 431 discard_helper_->Reset(config_.codec_delay()); | 421 discard_helper_->Reset(config_.codec_delay()); |
| 432 } | 422 } |
| 433 | 423 |
| 434 } // namespace media | 424 } // namespace media |
| OLD | NEW |