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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 420 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
421 DLOG(ERROR) << "Could not initialize audio decoder: " | 421 DLOG(ERROR) << "Could not initialize audio decoder: " |
422 << codec_context_->codec_id; | 422 << codec_context_->codec_id; |
423 ReleaseFFmpegResources(); | 423 ReleaseFFmpegResources(); |
424 state_ = kUninitialized; | 424 state_ = kUninitialized; |
425 return false; | 425 return false; |
426 } | 426 } |
427 | 427 |
428 // Success! | 428 // Success! |
429 av_frame_.reset(av_frame_alloc()); | 429 av_frame_.reset(av_frame_alloc()); |
430 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second())); | 430 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), |
| 431 config_.codec_delay())); |
431 av_sample_format_ = codec_context_->sample_fmt; | 432 av_sample_format_ = codec_context_->sample_fmt; |
432 | 433 |
433 if (codec_context_->channels != | 434 if (codec_context_->channels != |
434 ChannelLayoutToChannelCount(config_.channel_layout())) { | 435 ChannelLayoutToChannelCount(config_.channel_layout())) { |
435 DLOG(ERROR) << "Audio configuration specified " | 436 DLOG(ERROR) << "Audio configuration specified " |
436 << ChannelLayoutToChannelCount(config_.channel_layout()) | 437 << ChannelLayoutToChannelCount(config_.channel_layout()) |
437 << " channels, but FFmpeg thinks the file contains " | 438 << " channels, but FFmpeg thinks the file contains " |
438 << codec_context_->channels << " channels"; | 439 << codec_context_->channels << " channels"; |
439 ReleaseFFmpegResources(); | 440 ReleaseFFmpegResources(); |
440 state_ = kUninitialized; | 441 state_ = kUninitialized; |
441 return false; | 442 return false; |
442 } | 443 } |
443 | 444 |
444 ResetTimestampState(); | 445 ResetTimestampState(); |
445 return true; | 446 return true; |
446 } | 447 } |
447 | 448 |
448 void FFmpegAudioDecoder::ResetTimestampState() { | 449 void FFmpegAudioDecoder::ResetTimestampState() { |
449 discard_helper_->Reset(config_.codec_delay()); | 450 discard_helper_->Reset(config_.codec_delay()); |
450 } | 451 } |
451 | 452 |
452 } // namespace media | 453 } // namespace media |
OLD | NEW |