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 avcodec_flush_buffers(codec_context_.get()); | |
|
DaleCurtis
2014/01/08 00:30:54
What made you add this? We don't make a similar c
rileya (GONE FROM CHROMIUM)
2014/01/08 21:05:50
I'm not sure actually I think I saw it done in Res
| |
| 163 ResetTimestampState(); | |
| 164 queued_audio_.clear(); | |
| 161 ReleaseFFmpegResources(); | 165 ReleaseFFmpegResources(); |
| 166 | |
| 167 stop_cb.Run(); | |
|
xhwang
2014/01/08 01:33:37
Here and in Reset(), what if we have |read_cb_| pe
rileya (GONE FROM CHROMIUM)
2014/01/08 21:05:50
I'd wondered about this, added a TODO.
| |
| 162 } | 168 } |
| 163 | 169 |
| 170 FFmpegAudioDecoder::~FFmpegAudioDecoder() {} | |
| 171 | |
| 164 int FFmpegAudioDecoder::GetAudioBuffer(AVCodecContext* codec, | 172 int FFmpegAudioDecoder::GetAudioBuffer(AVCodecContext* codec, |
| 165 AVFrame* frame, | 173 AVFrame* frame, |
| 166 int flags) { | 174 int flags) { |
| 167 // Since this routine is called by FFmpeg when a buffer is required for audio | 175 // 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). | 176 // data, use the values supplied by FFmpeg (ignoring the current settings). |
| 169 // RunDecodeLoop() gets to determine if the buffer is useable or not. | 177 // RunDecodeLoop() gets to determine if the buffer is useable or not. |
| 170 AVSampleFormat format = static_cast<AVSampleFormat>(frame->format); | 178 AVSampleFormat format = static_cast<AVSampleFormat>(frame->format); |
| 171 SampleFormat sample_format = AVSampleFormatToSampleFormat(format); | 179 SampleFormat sample_format = AVSampleFormatToSampleFormat(format); |
| 172 int channels = DetermineChannels(frame); | 180 int channels = DetermineChannels(frame); |
| 173 if ((channels <= 0) || (channels >= limits::kMaxChannels)) { | 181 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. | 540 // Decoding finished successfully, update statistics. |
| 533 if (result > 0) { | 541 if (result > 0) { |
| 534 PipelineStatistics statistics; | 542 PipelineStatistics statistics; |
| 535 statistics.audio_bytes_decoded = result; | 543 statistics.audio_bytes_decoded = result; |
| 536 statistics_cb_.Run(statistics); | 544 statistics_cb_.Run(statistics); |
| 537 } | 545 } |
| 538 } while (packet.size > 0); | 546 } while (packet.size > 0); |
| 539 } | 547 } |
| 540 | 548 |
| 541 } // namespace media | 549 } // namespace media |
| OLD | NEW |