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/opus_audio_decoder.h" | 5 #include "media/filters/opus_audio_decoder.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | 247 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) |
248 : task_runner_(task_runner), | 248 : task_runner_(task_runner), |
249 opus_decoder_(NULL), | 249 opus_decoder_(NULL), |
250 start_input_timestamp_(kNoTimestamp()) {} | 250 start_input_timestamp_(kNoTimestamp()) {} |
251 | 251 |
252 std::string OpusAudioDecoder::GetDisplayName() const { | 252 std::string OpusAudioDecoder::GetDisplayName() const { |
253 return "OpusAudioDecoder"; | 253 return "OpusAudioDecoder"; |
254 } | 254 } |
255 | 255 |
256 void OpusAudioDecoder::Initialize(const AudioDecoderConfig& config, | 256 void OpusAudioDecoder::Initialize(const AudioDecoderConfig& config, |
257 const PipelineStatusCB& status_cb, | 257 const InitCB& init_cb, |
258 const OutputCB& output_cb) { | 258 const OutputCB& output_cb) { |
259 DCHECK(task_runner_->BelongsToCurrentThread()); | 259 DCHECK(task_runner_->BelongsToCurrentThread()); |
260 PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); | 260 InitCB bound_init_cb = BindToCurrentLoop(init_cb); |
261 | 261 |
262 config_ = config; | 262 config_ = config; |
263 output_cb_ = BindToCurrentLoop(output_cb); | 263 output_cb_ = BindToCurrentLoop(output_cb); |
264 | 264 |
265 if (!ConfigureDecoder()) { | 265 if (!ConfigureDecoder()) { |
266 initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 266 bound_init_cb.Run(false); |
267 return; | 267 return; |
268 } | 268 } |
269 | 269 |
270 initialize_cb.Run(PIPELINE_OK); | 270 bound_init_cb.Run(true); |
271 } | 271 } |
272 | 272 |
273 void OpusAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, | 273 void OpusAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer, |
274 const DecodeCB& decode_cb) { | 274 const DecodeCB& decode_cb) { |
275 DCHECK(task_runner_->BelongsToCurrentThread()); | 275 DCHECK(task_runner_->BelongsToCurrentThread()); |
276 DCHECK(!decode_cb.is_null()); | 276 DCHECK(!decode_cb.is_null()); |
277 | 277 |
278 DecodeBuffer(buffer, BindToCurrentLoop(decode_cb)); | 278 DecodeBuffer(buffer, BindToCurrentLoop(decode_cb)); |
279 } | 279 } |
280 | 280 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 output_buffer->get()->TrimEnd(trim_frames); | 478 output_buffer->get()->TrimEnd(trim_frames); |
479 | 479 |
480 // Handles discards and timestamping. Discard the buffer if more data needed. | 480 // Handles discards and timestamping. Discard the buffer if more data needed. |
481 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) | 481 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) |
482 *output_buffer = NULL; | 482 *output_buffer = NULL; |
483 | 483 |
484 return true; | 484 return true; |
485 } | 485 } |
486 | 486 |
487 } // namespace media | 487 } // namespace media |
OLD | NEW |