Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 1083883003: Move BindToCurrentLoop from media/base/ to base/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix media/base/callback_holder.h compile Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/fake_video_decoder.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_to_current_loop.h"
7 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
8 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
9 #include "media/base/audio_buffer.h" 10 #include "media/base/audio_buffer.h"
10 #include "media/base/audio_bus.h" 11 #include "media/base/audio_bus.h"
11 #include "media/base/audio_decoder_config.h" 12 #include "media/base/audio_decoder_config.h"
12 #include "media/base/audio_discard_helper.h" 13 #include "media/base/audio_discard_helper.h"
13 #include "media/base/bind_to_current_loop.h"
14 #include "media/base/decoder_buffer.h" 14 #include "media/base/decoder_buffer.h"
15 #include "media/base/limits.h" 15 #include "media/base/limits.h"
16 #include "media/base/sample_format.h" 16 #include "media/base/sample_format.h"
17 #include "media/ffmpeg/ffmpeg_common.h" 17 #include "media/ffmpeg/ffmpeg_common.h"
18 #include "media/filters/ffmpeg_glue.h" 18 #include "media/filters/ffmpeg_glue.h"
19 19
20 namespace media { 20 namespace media {
21 21
22 // Returns true if the decode result was end of stream. 22 // Returns true if the decode result was end of stream.
23 static inline bool IsEndOfStream(int result, 23 static inline bool IsEndOfStream(int result,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, 150 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config,
151 const PipelineStatusCB& status_cb, 151 const PipelineStatusCB& status_cb,
152 const OutputCB& output_cb) { 152 const OutputCB& output_cb) {
153 DCHECK(task_runner_->BelongsToCurrentThread()); 153 DCHECK(task_runner_->BelongsToCurrentThread());
154 DCHECK(!config.is_encrypted()); 154 DCHECK(!config.is_encrypted());
155 155
156 FFmpegGlue::InitializeFFmpeg(); 156 FFmpegGlue::InitializeFFmpeg();
157 157
158 config_ = config; 158 config_ = config;
159 PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); 159 PipelineStatusCB initialize_cb = base::BindToCurrentLoop(status_cb);
160 160
161 if (!config.IsValidConfig() || !ConfigureDecoder()) { 161 if (!config.IsValidConfig() || !ConfigureDecoder()) {
162 initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); 162 initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED);
163 return; 163 return;
164 } 164 }
165 165
166 // Success! 166 // Success!
167 output_cb_ = BindToCurrentLoop(output_cb); 167 output_cb_ = base::BindToCurrentLoop(output_cb);
168 state_ = kNormal; 168 state_ = kNormal;
169 initialize_cb.Run(PIPELINE_OK); 169 initialize_cb.Run(PIPELINE_OK);
170 } 170 }
171 171
172 void FFmpegAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, 172 void FFmpegAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
173 const DecodeCB& decode_cb) { 173 const DecodeCB& decode_cb) {
174 DCHECK(task_runner_->BelongsToCurrentThread()); 174 DCHECK(task_runner_->BelongsToCurrentThread());
175 DCHECK(!decode_cb.is_null()); 175 DCHECK(!decode_cb.is_null());
176 CHECK_NE(state_, kUninitialized); 176 CHECK_NE(state_, kUninitialized);
177 DecodeCB decode_cb_bound = BindToCurrentLoop(decode_cb); 177 DecodeCB decode_cb_bound = base::BindToCurrentLoop(decode_cb);
178 178
179 if (state_ == kError) { 179 if (state_ == kError) {
180 decode_cb_bound.Run(kDecodeError); 180 decode_cb_bound.Run(kDecodeError);
181 return; 181 return;
182 } 182 }
183 183
184 // Do nothing if decoding has finished. 184 // Do nothing if decoding has finished.
185 if (state_ == kDecodeFinished) { 185 if (state_ == kDecodeFinished) {
186 decode_cb_bound.Run(kOk); 186 decode_cb_bound.Run(kOk);
187 return; 187 return;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 388
389 ResetTimestampState(); 389 ResetTimestampState();
390 return true; 390 return true;
391 } 391 }
392 392
393 void FFmpegAudioDecoder::ResetTimestampState() { 393 void FFmpegAudioDecoder::ResetTimestampState() {
394 discard_helper_->Reset(config_.codec_delay()); 394 discard_helper_->Reset(config_.codec_delay());
395 } 395 }
396 396
397 } // namespace media 397 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/fake_video_decoder.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698