Chromium Code Reviews| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 void FFmpegAudioDecoder::Reset(const base::Closure& closure) { | 148 void FFmpegAudioDecoder::Reset(const base::Closure& closure) { |
| 149 DCHECK(task_runner_->BelongsToCurrentThread()); | 149 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 150 base::Closure reset_cb = BindToCurrentLoop(closure); | 150 base::Closure reset_cb = BindToCurrentLoop(closure); |
| 151 | 151 |
| 152 avcodec_flush_buffers(codec_context_.get()); | 152 avcodec_flush_buffers(codec_context_.get()); |
| 153 ResetTimestampState(); | 153 ResetTimestampState(); |
| 154 queued_audio_.clear(); | 154 queued_audio_.clear(); |
| 155 reset_cb.Run(); | 155 reset_cb.Run(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 FFmpegAudioDecoder::~FFmpegAudioDecoder() { | 158 void FFmpegAudioDecoder::Stop(const base::Closure& closure) { |
| 159 // TODO(scherkus): should we require Stop() to be called? this might end up | 159 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 160 // getting called on a random thread due to refcounting. | 160 base::Closure stop_cb = BindToCurrentLoop(closure); |
| 161 | |
| 162 ResetTimestampState(); | |
| 163 queued_audio_.clear(); | |
| 161 ReleaseFFmpegResources(); | 164 ReleaseFFmpegResources(); |
| 165 | |
| 166 // TODO(rileya): Properly handle the case in which we have a pending | |
|
DaleCurtis
2014/01/09 01:24:49
Hmm, I suspect you may need to handle that in this
| |
| 167 // |read_cb_| when Stop() or Reset()-ing. | |
| 168 stop_cb.Run(); | |
| 162 } | 169 } |
| 163 | 170 |
| 171 FFmpegAudioDecoder::~FFmpegAudioDecoder() {} | |
| 172 | |
| 164 int FFmpegAudioDecoder::GetAudioBuffer(AVCodecContext* codec, | 173 int FFmpegAudioDecoder::GetAudioBuffer(AVCodecContext* codec, |
| 165 AVFrame* frame, | 174 AVFrame* frame, |
| 166 int flags) { | 175 int flags) { |
| 167 // Since this routine is called by FFmpeg when a buffer is required for audio | 176 // Since this routine is called by FFmpeg when a buffer is required for audio |
| 168 // data, use the values supplied by FFmpeg (ignoring the current settings). | 177 // data, use the values supplied by FFmpeg (ignoring the current settings). |
| 169 // RunDecodeLoop() gets to determine if the buffer is useable or not. | 178 // RunDecodeLoop() gets to determine if the buffer is useable or not. |
| 170 AVSampleFormat format = static_cast<AVSampleFormat>(frame->format); | 179 AVSampleFormat format = static_cast<AVSampleFormat>(frame->format); |
| 171 SampleFormat sample_format = AVSampleFormatToSampleFormat(format); | 180 SampleFormat sample_format = AVSampleFormatToSampleFormat(format); |
| 172 int channels = DetermineChannels(frame); | 181 int channels = DetermineChannels(frame); |
| 173 if ((channels <= 0) || (channels >= limits::kMaxChannels)) { | 182 if ((channels <= 0) || (channels >= limits::kMaxChannels)) { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 // Decoding finished successfully, update statistics. | 541 // Decoding finished successfully, update statistics. |
| 533 if (result > 0) { | 542 if (result > 0) { |
| 534 PipelineStatistics statistics; | 543 PipelineStatistics statistics; |
| 535 statistics.audio_bytes_decoded = result; | 544 statistics.audio_bytes_decoded = result; |
| 536 statistics_cb_.Run(statistics); | 545 statistics_cb_.Run(statistics); |
| 537 } | 546 } |
| 538 } while (packet.size > 0); | 547 } while (packet.size > 0); |
| 539 } | 548 } |
| 540 | 549 |
| 541 } // namespace media | 550 } // namespace media |
| OLD | NEW |