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/renderers/audio_renderer_impl.h" | 5 #include "media/renderers/audio_renderer_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_to_current_loop.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
17 #include "media/base/audio_buffer.h" | 18 #include "media/base/audio_buffer.h" |
18 #include "media/base/audio_buffer_converter.h" | 19 #include "media/base/audio_buffer_converter.h" |
19 #include "media/base/audio_hardware_config.h" | 20 #include "media/base/audio_hardware_config.h" |
20 #include "media/base/audio_splicer.h" | 21 #include "media/base/audio_splicer.h" |
21 #include "media/base/bind_to_current_loop.h" | |
22 #include "media/base/demuxer_stream.h" | 22 #include "media/base/demuxer_stream.h" |
23 #include "media/filters/audio_clock.h" | 23 #include "media/filters/audio_clock.h" |
24 #include "media/filters/decrypting_demuxer_stream.h" | 24 #include "media/filters/decrypting_demuxer_stream.h" |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 enum AudioRendererEvent { | 30 enum AudioRendererEvent { |
31 INITIALIZED, | 31 INITIALIZED, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 DCHECK(!buffering_state_cb.is_null()); | 280 DCHECK(!buffering_state_cb.is_null()); |
281 DCHECK(!ended_cb.is_null()); | 281 DCHECK(!ended_cb.is_null()); |
282 DCHECK(!error_cb.is_null()); | 282 DCHECK(!error_cb.is_null()); |
283 DCHECK_EQ(kUninitialized, state_); | 283 DCHECK_EQ(kUninitialized, state_); |
284 DCHECK(sink_.get()); | 284 DCHECK(sink_.get()); |
285 | 285 |
286 state_ = kInitializing; | 286 state_ = kInitializing; |
287 | 287 |
288 // Always post |init_cb_| because |this| could be destroyed if initialization | 288 // Always post |init_cb_| because |this| could be destroyed if initialization |
289 // failed. | 289 // failed. |
290 init_cb_ = BindToCurrentLoop(init_cb); | 290 init_cb_ = base::BindToCurrentLoop(init_cb); |
291 | 291 |
292 buffering_state_cb_ = buffering_state_cb; | 292 buffering_state_cb_ = buffering_state_cb; |
293 ended_cb_ = ended_cb; | 293 ended_cb_ = ended_cb; |
294 error_cb_ = error_cb; | 294 error_cb_ = error_cb; |
295 | 295 |
296 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); | 296 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); |
297 expecting_config_changes_ = stream->SupportsConfigChanges(); | 297 expecting_config_changes_ = stream->SupportsConfigChanges(); |
298 if (!expecting_config_changes_ || !hw_params.IsValid()) { | 298 if (!expecting_config_changes_ || !hw_params.IsValid()) { |
299 // The actual buffer size is controlled via the size of the AudioBus | 299 // The actual buffer size is controlled via the size of the AudioBus |
300 // provided to Render(), so just choose something reasonable here for looks. | 300 // provided to Render(), so just choose something reasonable here for looks. |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 << buffering_state; | 750 << buffering_state; |
751 DCHECK_NE(buffering_state_, buffering_state); | 751 DCHECK_NE(buffering_state_, buffering_state); |
752 lock_.AssertAcquired(); | 752 lock_.AssertAcquired(); |
753 buffering_state_ = buffering_state; | 753 buffering_state_ = buffering_state; |
754 | 754 |
755 task_runner_->PostTask(FROM_HERE, | 755 task_runner_->PostTask(FROM_HERE, |
756 base::Bind(buffering_state_cb_, buffering_state_)); | 756 base::Bind(buffering_state_cb_, buffering_state_)); |
757 } | 757 } |
758 | 758 |
759 } // namespace media | 759 } // namespace media |
OLD | NEW |