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/audio_renderer_impl.h" | 5 #include "media/filters/audio_renderer_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 DCHECK(!statistics_cb.is_null()); | 251 DCHECK(!statistics_cb.is_null()); |
252 DCHECK(!time_cb.is_null()); | 252 DCHECK(!time_cb.is_null()); |
253 DCHECK(!buffering_state_cb.is_null()); | 253 DCHECK(!buffering_state_cb.is_null()); |
254 DCHECK(!ended_cb.is_null()); | 254 DCHECK(!ended_cb.is_null()); |
255 DCHECK(!error_cb.is_null()); | 255 DCHECK(!error_cb.is_null()); |
256 DCHECK_EQ(kUninitialized, state_); | 256 DCHECK_EQ(kUninitialized, state_); |
257 DCHECK(sink_); | 257 DCHECK(sink_); |
258 | 258 |
259 state_ = kInitializing; | 259 state_ = kInitializing; |
260 | 260 |
261 init_cb_ = init_cb; | 261 // Always post |init_cb_| because |this| could be destroyed if initialization |
| 262 // failed. |
| 263 init_cb_ = BindToCurrentLoop(init_cb); |
| 264 |
262 time_cb_ = time_cb; | 265 time_cb_ = time_cb; |
263 buffering_state_cb_ = buffering_state_cb; | 266 buffering_state_cb_ = buffering_state_cb; |
264 ended_cb_ = ended_cb; | 267 ended_cb_ = ended_cb; |
265 error_cb_ = error_cb; | 268 error_cb_ = error_cb; |
266 | 269 |
267 expecting_config_changes_ = stream->SupportsConfigChanges(); | 270 expecting_config_changes_ = stream->SupportsConfigChanges(); |
268 if (!expecting_config_changes_) { | 271 if (!expecting_config_changes_) { |
269 // The actual buffer size is controlled via the size of the AudioBus | 272 // The actual buffer size is controlled via the size of the AudioBus |
270 // provided to Render(), so just choose something reasonable here for looks. | 273 // provided to Render(), so just choose something reasonable here for looks. |
271 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; | 274 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 { | 344 { |
342 base::AutoUnlock auto_unlock(lock_); | 345 base::AutoUnlock auto_unlock(lock_); |
343 sink_->Initialize(audio_parameters_, this); | 346 sink_->Initialize(audio_parameters_, this); |
344 sink_->Start(); | 347 sink_->Start(); |
345 | 348 |
346 // Some sinks play on start... | 349 // Some sinks play on start... |
347 sink_->Pause(); | 350 sink_->Pause(); |
348 } | 351 } |
349 | 352 |
350 DCHECK(!sink_playing_); | 353 DCHECK(!sink_playing_); |
351 | |
352 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 354 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
353 } | 355 } |
354 | 356 |
355 void AudioRendererImpl::SetVolume(float volume) { | 357 void AudioRendererImpl::SetVolume(float volume) { |
356 DCHECK(task_runner_->BelongsToCurrentThread()); | 358 DCHECK(task_runner_->BelongsToCurrentThread()); |
357 DCHECK(sink_); | 359 DCHECK(sink_); |
358 sink_->SetVolume(volume); | 360 sink_->SetVolume(volume); |
359 } | 361 } |
360 | 362 |
361 void AudioRendererImpl::DecodedAudioReady( | 363 void AudioRendererImpl::DecodedAudioReady( |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 << buffering_state; | 701 << buffering_state; |
700 DCHECK_NE(buffering_state_, buffering_state); | 702 DCHECK_NE(buffering_state_, buffering_state); |
701 lock_.AssertAcquired(); | 703 lock_.AssertAcquired(); |
702 buffering_state_ = buffering_state; | 704 buffering_state_ = buffering_state; |
703 | 705 |
704 task_runner_->PostTask(FROM_HERE, | 706 task_runner_->PostTask(FROM_HERE, |
705 base::Bind(buffering_state_cb_, buffering_state_)); | 707 base::Bind(buffering_state_cb_, buffering_state_)); |
706 } | 708 } |
707 | 709 |
708 } // namespace media | 710 } // namespace media |
OLD | NEW |