Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: media/renderers/audio_renderer_impl.cc

Issue 2836293002: Introduce AudioRendererSink::IsOptimizedForHardwareParameters (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 audio_buffer_stream_ = base::MakeUnique<AudioBufferStream>( 358 audio_buffer_stream_ = base::MakeUnique<AudioBufferStream>(
359 task_runner_, create_audio_decoders_cb_.Run(), media_log_); 359 task_runner_, create_audio_decoders_cb_.Run(), media_log_);
360 360
361 audio_buffer_stream_->set_config_change_observer(base::Bind( 361 audio_buffer_stream_->set_config_change_observer(base::Bind(
362 &AudioRendererImpl::OnConfigChange, weak_factory_.GetWeakPtr())); 362 &AudioRendererImpl::OnConfigChange, weak_factory_.GetWeakPtr()));
363 363
364 // Always post |init_cb_| because |this| could be destroyed if initialization 364 // Always post |init_cb_| because |this| could be destroyed if initialization
365 // failed. 365 // failed.
366 init_cb_ = BindToCurrentLoop(init_cb); 366 init_cb_ = BindToCurrentLoop(init_cb);
367 367
368 auto output_device_info = sink_->GetOutputDeviceInfo(); 368 AudioParameters preferred_params(
369 AudioParameters::AUDIO_PCM_LOW_LATENCY,
370 stream->audio_decoder_config().channel_layout(),
371 stream->audio_decoder_config().samples_per_second(),
372 stream->audio_decoder_config().bits_per_channel(),
373 stream->audio_decoder_config().samples_per_second() / 100);
374 auto output_device_info = sink_->GetOutputDeviceInfo(preferred_params);
369 const AudioParameters& hw_params = output_device_info.output_params(); 375 const AudioParameters& hw_params = output_device_info.output_params();
370 expecting_config_changes_ = stream->SupportsConfigChanges(); 376 expecting_config_changes_ = stream->SupportsConfigChanges();
371 if (!expecting_config_changes_ || !hw_params.IsValid() || 377 if (!expecting_config_changes_ || !hw_params.IsValid() ||
372 hw_params.format() == AudioParameters::AUDIO_FAKE) { 378 hw_params.format() == AudioParameters::AUDIO_FAKE) {
373 // The actual buffer size is controlled via the size of the AudioBus 379 // The actual buffer size is controlled via the size of the AudioBus
374 // provided to Render(), but we should choose a value here based on hardware 380 // provided to Render(), but we should choose a value here based on hardware
375 // parameters if possible since it affects the initial buffer size used by 381 // parameters if possible since it affects the initial buffer size used by
376 // the algorithm. Too little will cause underflow on Bluetooth devices. 382 // the algorithm. Too little will cause underflow on Bluetooth devices.
377 int buffer_size = 383 int buffer_size =
378 std::max(stream->audio_decoder_config().samples_per_second() / 100, 384 std::max(stream->audio_decoder_config().samples_per_second() / 100,
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // All channels with a zero mix are muted and can be ignored. 1015 // All channels with a zero mix are muted and can be ignored.
1010 std::vector<bool> channel_mask(audio_parameters_.channels(), false); 1016 std::vector<bool> channel_mask(audio_parameters_.channels(), false);
1011 for (size_t ch = 0; ch < matrix.size(); ++ch) { 1017 for (size_t ch = 0; ch < matrix.size(); ++ch) {
1012 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(), 1018 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(),
1013 [](float mix) { return !!mix; }); 1019 [](float mix) { return !!mix; });
1014 } 1020 }
1015 algorithm_->SetChannelMask(std::move(channel_mask)); 1021 algorithm_->SetChannelMask(std::move(channel_mask));
1016 } 1022 }
1017 1023
1018 } // namespace media 1024 } // namespace media
OLDNEW
« media/blink/webaudiosourceprovider_impl.cc ('K') | « media/blink/webaudiosourceprovider_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698