summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-07 21:50:01 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-07 21:50:01 +0000
commite0d5743b33a15ad5ea9fa5a63e71c4feb07783d5 (patch)
tree857fc450f16ba87e1ce8cd83057c1a1a999b1281
parentf69f9528e227f48ce7c5bef6d482ff85316b6c2a (diff)
downloadchromium_src-e0d5743b33a15ad5ea9fa5a63e71c4feb07783d5.zip
chromium_src-e0d5743b33a15ad5ea9fa5a63e71c4feb07783d5.tar.gz
chromium_src-e0d5743b33a15ad5ea9fa5a63e71c4feb07783d5.tar.bz2
Ensure the WebRtcAudioDeviceImpl before audio capturer and track are created.
The fact is that WebRtcAudioDeviceImpl is a necessary dependency to the audio capturer and track, so we have to ensure the object exists. BUG=341715 TEST=content_unittests Review URL: https://codereview.chromium.org/157603003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249800 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/media/media_stream_dependency_factory.cc18
-rw-r--r--content/renderer/media/media_stream_dependency_factory.h3
2 files changed, 16 insertions, 5 deletions
diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc
index d07457f..012c343 100644
--- a/content/renderer/media/media_stream_dependency_factory.cc
+++ b/content/renderer/media/media_stream_dependency_factory.cc
@@ -453,7 +453,6 @@ MediaStreamDependencyFactory::GetPcFactory() {
void MediaStreamDependencyFactory::CreatePeerConnectionFactory() {
DCHECK(!pc_factory_.get());
- DCHECK(!audio_device_.get());
DCHECK(!signaling_thread_);
DCHECK(!worker_thread_);
DCHECK(!network_manager_);
@@ -523,18 +522,16 @@ void MediaStreamDependencyFactory::CreatePeerConnectionFactory() {
}
#endif
- scoped_refptr<WebRtcAudioDeviceImpl> audio_device(
- new WebRtcAudioDeviceImpl());
+ EnsureWebRtcAudioDeviceImpl();
scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory(
webrtc::CreatePeerConnectionFactory(worker_thread_,
signaling_thread_,
- audio_device.get(),
+ audio_device_.get(),
encoder_factory.release(),
decoder_factory.release()));
CHECK(factory);
- audio_device_ = audio_device;
pc_factory_ = factory;
webrtc::PeerConnectionFactoryInterface::Options factory_options;
factory_options.disable_sctp_data_channels =
@@ -648,6 +645,8 @@ MediaStreamDependencyFactory::CreateLocalAudioTrack(
const scoped_refptr<WebRtcAudioCapturer>& capturer,
WebAudioCapturerSource* webaudio_source,
webrtc::AudioSourceInterface* source) {
+ DCHECK(GetWebRtcAudioDevice());
+
// Creates an adapter to hold all the libjingle objects.
scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
WebRtcLocalAudioTrackAdapter::Create(blink_track.id().utf8(), source));
@@ -749,6 +748,8 @@ MediaStreamDependencyFactory::CreateAudioCapturer(
// view, for example, by an extension.
DCHECK_GE(render_view_id, 0);
+ EnsureWebRtcAudioDeviceImpl();
+ DCHECK(GetWebRtcAudioDevice());
return WebRtcAudioCapturer::CreateCapturer(render_view_id, device_info,
constraints,
GetWebRtcAudioDevice());
@@ -830,4 +831,11 @@ void MediaStreamDependencyFactory::StartAecDump(
VLOG(1) << "Could not start AEC dump.";
}
+void MediaStreamDependencyFactory::EnsureWebRtcAudioDeviceImpl() {
+ if (audio_device_)
+ return;
+
+ audio_device_ = new WebRtcAudioDeviceImpl();
+}
+
} // namespace content
diff --git a/content/renderer/media/media_stream_dependency_factory.h b/content/renderer/media/media_stream_dependency_factory.h
index f41c31a..fa06815 100644
--- a/content/renderer/media/media_stream_dependency_factory.h
+++ b/content/renderer/media/media_stream_dependency_factory.h
@@ -233,6 +233,9 @@ class CONTENT_EXPORT MediaStreamDependencyFactory
void StartAecDump(const base::PlatformFile& aec_dump_file);
+ // Helper method to create a WebRtcAudioDeviceImpl.
+ void EnsureWebRtcAudioDeviceImpl();
+
// We own network_manager_, must be deleted on the worker thread.
// The network manager uses |p2p_socket_dispatcher_|.
IpcNetworkManager* network_manager_;