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

Side by Side Diff: content/renderer/media/track_audio_renderer.cc

Issue 2067863003: Mixing audio with different latency requirements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing bot redness Created 4 years, 5 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 "content/renderer/media/track_audio_renderer.h" 5 #include "content/renderer/media/track_audio_renderer.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "content/renderer/media/audio_device_factory.h" 13 #include "content/renderer/media/audio_device_factory.h"
14 #include "content/renderer/media/media_stream_audio_track.h" 14 #include "content/renderer/media/media_stream_audio_track.h"
15 #include "content/renderer/media/webrtc_audio_renderer.h"
16 #include "media/base/audio_bus.h" 15 #include "media/base/audio_bus.h"
16 #include "media/base/audio_latency.h"
17 #include "media/base/audio_shifter.h" 17 #include "media/base/audio_shifter.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 namespace { 21 namespace {
22 22
23 enum LocalRendererSinkStates { 23 enum LocalRendererSinkStates {
24 kSinkStarted = 0, 24 kSinkStarted = 0,
25 kSinkNeverStarted, 25 kSinkNeverStarted,
26 kSinkStatesMax // Must always be last! 26 kSinkStatesMax // Must always be last!
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const media::OutputDeviceInfo& device_info = sink_->GetOutputDeviceInfo(); 304 const media::OutputDeviceInfo& device_info = sink_->GetOutputDeviceInfo();
305 if (device_info.device_status() != media::OUTPUT_DEVICE_STATUS_OK) 305 if (device_info.device_status() != media::OUTPUT_DEVICE_STATUS_OK)
306 return; 306 return;
307 307
308 // Output parameters consist of the same channel layout and sample rate as the 308 // Output parameters consist of the same channel layout and sample rate as the
309 // source, but having the buffer duration preferred by the hardware. 309 // source, but having the buffer duration preferred by the hardware.
310 const media::AudioParameters& hardware_params = device_info.output_params(); 310 const media::AudioParameters& hardware_params = device_info.output_params();
311 media::AudioParameters sink_params( 311 media::AudioParameters sink_params(
312 hardware_params.format(), source_params_.channel_layout(), 312 hardware_params.format(), source_params_.channel_layout(),
313 source_params_.sample_rate(), source_params_.bits_per_sample(), 313 source_params_.sample_rate(), source_params_.bits_per_sample(),
314 WebRtcAudioRenderer::GetOptimalBufferSize( 314 media::AudioLatency::GetRtcBufferSize(
315 source_params_.sample_rate(), hardware_params.frames_per_buffer())); 315 source_params_.sample_rate(), hardware_params.frames_per_buffer()));
316 DVLOG(1) << ("TrackAudioRenderer::MaybeStartSink() -- Starting sink. " 316 DVLOG(1) << ("TrackAudioRenderer::MaybeStartSink() -- Starting sink. "
317 "source_params_={") 317 "source_params_={")
318 << source_params_.AsHumanReadableString() << "}, hardware_params_={" 318 << source_params_.AsHumanReadableString() << "}, hardware_params_={"
319 << hardware_params.AsHumanReadableString() << "}, sink parameters={" 319 << hardware_params.AsHumanReadableString() << "}, sink parameters={"
320 << sink_params.AsHumanReadableString() << '}'; 320 << sink_params.AsHumanReadableString() << '}';
321 sink_->Initialize(sink_params, this); 321 sink_->Initialize(sink_params, this);
322 sink_->Start(); 322 sink_->Start();
323 sink_->SetVolume(volume_); 323 sink_->SetVolume(volume_);
324 sink_->Play(); // Not all the sinks play on start. 324 sink_->Play(); // Not all the sinks play on start.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 if (source_params_.IsValid()) { 381 if (source_params_.IsValid()) {
382 prior_elapsed_render_time_ = 382 prior_elapsed_render_time_ =
383 ComputeTotalElapsedRenderTime(prior_elapsed_render_time_, 383 ComputeTotalElapsedRenderTime(prior_elapsed_render_time_,
384 num_samples_rendered_, 384 num_samples_rendered_,
385 source_params_.sample_rate()); 385 source_params_.sample_rate());
386 num_samples_rendered_ = 0; 386 num_samples_rendered_ = 0;
387 } 387 }
388 } 388 }
389 389
390 } // namespace content 390 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698