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

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

Issue 2120273004: Getting rid of AudioHardwareConfig and its synchronous IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: frame id fix 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/webrtc_local_audio_source_provider.h" 5 #include "content/renderer/media/webrtc_local_audio_source_provider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/renderer/media/audio_device_factory.h"
8 #include "content/renderer/render_thread_impl.h" 9 #include "content/renderer/render_thread_impl.h"
9 #include "media/base/audio_fifo.h" 10 #include "media/base/audio_fifo.h"
10 #include "media/base/audio_hardware_config.h"
11 #include "media/base/audio_parameters.h"
12 #include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h" 11 #include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h"
13 12
14 using blink::WebVector; 13 using blink::WebVector;
15 14
16 namespace content { 15 namespace content {
17 16
18 static const size_t kMaxNumberOfBuffers = 10; 17 static const size_t kMaxNumberOfBuffers = 10;
19 18
20 // Size of the buffer that WebAudio processes each time, it is the same value 19 // Size of the buffer that WebAudio processes each time, it is the same value
21 // as AudioNode::ProcessingSizeInFrames in WebKit. 20 // as AudioNode::ProcessingSizeInFrames in WebKit.
22 // static 21 // static
23 const size_t WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize = 128; 22 const size_t WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize = 128;
24 23
25 WebRtcLocalAudioSourceProvider::WebRtcLocalAudioSourceProvider( 24 WebRtcLocalAudioSourceProvider::WebRtcLocalAudioSourceProvider(
26 const blink::WebMediaStreamTrack& track) 25 const blink::WebMediaStreamTrack& track)
27 : is_enabled_(false), 26 : is_enabled_(false),
28 track_(track), 27 track_(track),
29 track_stopped_(false) { 28 track_stopped_(false) {
30 // Get the native audio output hardware sample-rate for the sink. 29 // Get the native audio output hardware sample-rate for the sink.
31 // We need to check if RenderThreadImpl is valid here since the unittests 30 // We need to check if RenderThreadImpl is valid here since the unittests
32 // do not have one and they will inject their own |sink_params_| for testing. 31 // do not have one and they will inject their own |sink_params_| for testing.
33 if (RenderThreadImpl::current()) { 32 if (RenderThreadImpl::current()) {
34 media::AudioHardwareConfig* hardware_config = 33 int sample_rate = AudioDeviceFactory::GetOutputDeviceInfo(
35 RenderThreadImpl::current()->GetAudioHardwareConfig(); 34 AudioDeviceFactory::kUnknownFrameIdForDefaultDevice,
36 int sample_rate = hardware_config->GetOutputSampleRate(); 35 0, std::string(), url::Origin())
36 .output_params()
37 .sample_rate();
37 sink_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 38 sink_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
38 media::CHANNEL_LAYOUT_STEREO, sample_rate, 16, 39 media::CHANNEL_LAYOUT_STEREO, sample_rate, 16,
39 kWebAudioRenderBufferSize); 40 kWebAudioRenderBufferSize);
40 } 41 }
41 42
42 // Connect the source provider to the track as a sink. 43 // Connect the source provider to the track as a sink.
43 MediaStreamAudioSink::AddToAudioTrack(this, track_); 44 MediaStreamAudioSink::AddToAudioTrack(this, track_);
44 } 45 }
45 46
46 WebRtcLocalAudioSourceProvider::~WebRtcLocalAudioSourceProvider() { 47 WebRtcLocalAudioSourceProvider::~WebRtcLocalAudioSourceProvider() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 return 1.0; 145 return 1.0;
145 } 146 }
146 147
147 void WebRtcLocalAudioSourceProvider::SetSinkParamsForTesting( 148 void WebRtcLocalAudioSourceProvider::SetSinkParamsForTesting(
148 const media::AudioParameters& sink_params) { 149 const media::AudioParameters& sink_params) {
149 sink_params_ = sink_params; 150 sink_params_ = sink_params;
150 } 151 }
151 152
152 } // namespace content 153 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698