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