| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 DCHECK_EQ(kUninitialized, state_); | 337 DCHECK_EQ(kUninitialized, state_); |
| 338 DCHECK(sink_.get()); | 338 DCHECK(sink_.get()); |
| 339 | 339 |
| 340 state_ = kInitializing; | 340 state_ = kInitializing; |
| 341 client_ = client; | 341 client_ = client; |
| 342 | 342 |
| 343 // Always post |init_cb_| because |this| could be destroyed if initialization | 343 // Always post |init_cb_| because |this| could be destroyed if initialization |
| 344 // failed. | 344 // failed. |
| 345 init_cb_ = BindToCurrentLoop(init_cb); | 345 init_cb_ = BindToCurrentLoop(init_cb); |
| 346 | 346 |
| 347 const AudioParameters& hw_params = | 347 auto output_device_info = sink_->GetOutputDeviceInfo(); |
| 348 sink_->GetOutputDeviceInfo().output_params(); | 348 const AudioParameters& hw_params = output_device_info.output_params(); |
| 349 expecting_config_changes_ = stream->SupportsConfigChanges(); | 349 expecting_config_changes_ = stream->SupportsConfigChanges(); |
| 350 if (!expecting_config_changes_ || !hw_params.IsValid() || | 350 if (!expecting_config_changes_ || !hw_params.IsValid() || |
| 351 hw_params.format() == AudioParameters::AUDIO_FAKE) { | 351 hw_params.format() == AudioParameters::AUDIO_FAKE) { |
| 352 // The actual buffer size is controlled via the size of the AudioBus | 352 // The actual buffer size is controlled via the size of the AudioBus |
| 353 // provided to Render(), but we should choose a value here based on hardware | 353 // provided to Render(), but we should choose a value here based on hardware |
| 354 // parameters if possible since it affects the initial buffer size used by | 354 // parameters if possible since it affects the initial buffer size used by |
| 355 // the algorithm. Too little will cause underflow on Bluetooth devices. | 355 // the algorithm. Too little will cause underflow on Bluetooth devices. |
| 356 int buffer_size = | 356 int buffer_size = |
| 357 std::max(stream->audio_decoder_config().samples_per_second() / 100, | 357 std::max(stream->audio_decoder_config().samples_per_second() / 100, |
| 358 hw_params.IsValid() ? hw_params.frames_per_buffer() : 0); | 358 hw_params.IsValid() ? hw_params.frames_per_buffer() : 0); |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 // All channels with a zero mix are muted and can be ignored. | 986 // All channels with a zero mix are muted and can be ignored. |
| 987 std::vector<bool> channel_mask(audio_parameters_.channels(), false); | 987 std::vector<bool> channel_mask(audio_parameters_.channels(), false); |
| 988 for (size_t ch = 0; ch < matrix.size(); ++ch) { | 988 for (size_t ch = 0; ch < matrix.size(); ++ch) { |
| 989 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(), | 989 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(), |
| 990 [](float mix) { return !!mix; }); | 990 [](float mix) { return !!mix; }); |
| 991 } | 991 } |
| 992 algorithm_->SetChannelMask(std::move(channel_mask)); | 992 algorithm_->SetChannelMask(std::move(channel_mask)); |
| 993 } | 993 } |
| 994 | 994 |
| 995 } // namespace media | 995 } // namespace media |
| OLD | NEW |