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 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 29 matching lines...) Expand all Loading... |
40 MediaLog* media_log) | 40 MediaLog* media_log) |
41 : task_runner_(task_runner), | 41 : task_runner_(task_runner), |
42 expecting_config_changes_(false), | 42 expecting_config_changes_(false), |
43 sink_(sink), | 43 sink_(sink), |
44 media_log_(media_log), | 44 media_log_(media_log), |
45 client_(nullptr), | 45 client_(nullptr), |
46 tick_clock_(new base::DefaultTickClock()), | 46 tick_clock_(new base::DefaultTickClock()), |
47 last_audio_memory_usage_(0), | 47 last_audio_memory_usage_(0), |
48 last_decoded_sample_rate_(0), | 48 last_decoded_sample_rate_(0), |
49 last_decoded_channel_layout_(CHANNEL_LAYOUT_NONE), | 49 last_decoded_channel_layout_(CHANNEL_LAYOUT_NONE), |
| 50 is_encrypted_(false), |
50 playback_rate_(0.0), | 51 playback_rate_(0.0), |
51 state_(kUninitialized), | 52 state_(kUninitialized), |
52 create_audio_decoders_cb_(create_audio_decoders_cb), | 53 create_audio_decoders_cb_(create_audio_decoders_cb), |
53 buffering_state_(BUFFERING_HAVE_NOTHING), | 54 buffering_state_(BUFFERING_HAVE_NOTHING), |
54 rendering_(false), | 55 rendering_(false), |
55 sink_playing_(false), | 56 sink_playing_(false), |
56 pending_read_(false), | 57 pending_read_(false), |
57 received_end_of_stream_(false), | 58 received_end_of_stream_(false), |
58 rendered_end_of_stream_(false), | 59 rendered_end_of_stream_(false), |
59 is_suspending_(false), | 60 is_suspending_(false), |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 448 |
448 audio_parameters_.Reset(hw_params.format(), renderer_channel_layout, | 449 audio_parameters_.Reset(hw_params.format(), renderer_channel_layout, |
449 sample_rate, hw_params.bits_per_sample(), | 450 sample_rate, hw_params.bits_per_sample(), |
450 media::AudioLatency::GetHighLatencyBufferSize( | 451 media::AudioLatency::GetHighLatencyBufferSize( |
451 sample_rate, preferred_buffer_size)); | 452 sample_rate, preferred_buffer_size)); |
452 } | 453 } |
453 | 454 |
454 last_decoded_channel_layout_ = | 455 last_decoded_channel_layout_ = |
455 stream->audio_decoder_config().channel_layout(); | 456 stream->audio_decoder_config().channel_layout(); |
456 | 457 |
| 458 is_encrypted_ = stream->audio_decoder_config().is_encrypted(); |
| 459 |
457 audio_clock_.reset( | 460 audio_clock_.reset( |
458 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); | 461 new AudioClock(base::TimeDelta(), audio_parameters_.sample_rate())); |
459 | 462 |
460 audio_buffer_stream_->Initialize( | 463 audio_buffer_stream_->Initialize( |
461 stream, base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, | 464 stream, base::Bind(&AudioRendererImpl::OnAudioBufferStreamInitialized, |
462 weak_factory_.GetWeakPtr()), | 465 weak_factory_.GetWeakPtr()), |
463 cdm_context, base::Bind(&AudioRendererImpl::OnStatisticsUpdate, | 466 cdm_context, base::Bind(&AudioRendererImpl::OnStatisticsUpdate, |
464 weak_factory_.GetWeakPtr()), | 467 weak_factory_.GetWeakPtr()), |
465 base::Bind(&AudioRendererImpl::OnWaitingForDecryptionKey, | 468 base::Bind(&AudioRendererImpl::OnWaitingForDecryptionKey, |
466 weak_factory_.GetWeakPtr())); | 469 weak_factory_.GetWeakPtr())); |
(...skipping 18 matching lines...) Expand all Loading... |
485 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_INITIALIZATION_FAILED); | 488 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_INITIALIZATION_FAILED); |
486 return; | 489 return; |
487 } | 490 } |
488 | 491 |
489 if (expecting_config_changes_) | 492 if (expecting_config_changes_) |
490 buffer_converter_.reset(new AudioBufferConverter(audio_parameters_)); | 493 buffer_converter_.reset(new AudioBufferConverter(audio_parameters_)); |
491 | 494 |
492 // We're all good! Continue initializing the rest of the audio renderer | 495 // We're all good! Continue initializing the rest of the audio renderer |
493 // based on the decoder format. | 496 // based on the decoder format. |
494 algorithm_.reset(new AudioRendererAlgorithm()); | 497 algorithm_.reset(new AudioRendererAlgorithm()); |
495 algorithm_->Initialize(audio_parameters_); | 498 algorithm_->Initialize(audio_parameters_, is_encrypted_); |
496 ConfigureChannelMask(); | 499 ConfigureChannelMask(); |
497 | 500 |
498 ChangeState_Locked(kFlushed); | 501 ChangeState_Locked(kFlushed); |
499 | 502 |
500 { | 503 { |
501 base::AutoUnlock auto_unlock(lock_); | 504 base::AutoUnlock auto_unlock(lock_); |
502 sink_->Initialize(audio_parameters_, this); | 505 sink_->Initialize(audio_parameters_, this); |
503 sink_->Start(); | 506 sink_->Start(); |
504 | 507 |
505 // Some sinks play on start... | 508 // Some sinks play on start... |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 // All channels with a zero mix are muted and can be ignored. | 1012 // All channels with a zero mix are muted and can be ignored. |
1010 std::vector<bool> channel_mask(audio_parameters_.channels(), false); | 1013 std::vector<bool> channel_mask(audio_parameters_.channels(), false); |
1011 for (size_t ch = 0; ch < matrix.size(); ++ch) { | 1014 for (size_t ch = 0; ch < matrix.size(); ++ch) { |
1012 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(), | 1015 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(), |
1013 [](float mix) { return !!mix; }); | 1016 [](float mix) { return !!mix; }); |
1014 } | 1017 } |
1015 algorithm_->SetChannelMask(std::move(channel_mask)); | 1018 algorithm_->SetChannelMask(std::move(channel_mask)); |
1016 } | 1019 } |
1017 | 1020 |
1018 } // namespace media | 1021 } // namespace media |
OLD | NEW |