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

Unified Diff: content/renderer/media/webrtc_local_audio_source_provider.cc

Issue 2131563002: Stop using GetAudioHardwareConfig to get audio parameters in WebRtcLocalAudioSourceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor formatting change 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_local_audio_source_provider.cc
diff --git a/content/renderer/media/webrtc_local_audio_source_provider.cc b/content/renderer/media/webrtc_local_audio_source_provider.cc
index af465017c68505506889e35b02d40c8e642af44d..72166ddbf75d51f54959366e5785af11b35d7558 100644
--- a/content/renderer/media/webrtc_local_audio_source_provider.cc
+++ b/content/renderer/media/webrtc_local_audio_source_provider.cc
@@ -5,11 +5,13 @@
#include "content/renderer/media/webrtc_local_audio_source_provider.h"
#include "base/logging.h"
-#include "content/renderer/render_thread_impl.h"
+#include "content/public/renderer/render_frame.h"
+#include "content/renderer/media/audio_device_factory.h"
#include "media/base/audio_fifo.h"
-#include "media/base/audio_hardware_config.h"
#include "media/base/audio_parameters.h"
#include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h"
+#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
using blink::WebVector;
@@ -28,17 +30,21 @@ WebRtcLocalAudioSourceProvider::WebRtcLocalAudioSourceProvider(
track_(track),
track_stopped_(false) {
// Get the native audio output hardware sample-rate for the sink.
- // We need to check if RenderThreadImpl is valid here since the unittests
+ // We need to check if there is a valid frame since the unittests
// do not have one and they will inject their own |sink_params_| for testing.
- if (RenderThreadImpl::current()) {
- media::AudioHardwareConfig* hardware_config =
- RenderThreadImpl::current()->GetAudioHardwareConfig();
- int sample_rate = hardware_config->GetOutputSampleRate();
+ blink::WebLocalFrame* const web_frame =
+ blink::WebLocalFrame::frameForCurrentContext();
+ RenderFrame* const render_frame = RenderFrame::FromWebFrame(web_frame);
+ if (render_frame) {
+ int sample_rate = AudioDeviceFactory::GetOutputDeviceInfo(
+ render_frame->GetRoutingID(), 0, std::string(),
+ web_frame->getSecurityOrigin())
+ .output_params()
+ .sample_rate();
sink_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
media::CHANNEL_LAYOUT_STEREO, sample_rate, 16,
kWebAudioRenderBufferSize);
}
-
// Connect the source provider to the track as a sink.
MediaStreamAudioSink::AddToAudioTrack(this, track_);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698