Commit 90ec5d34 authored by mcasas's avatar mcasas Committed by Commit bot

Win Video Capture: Create an STA |video_capture_thread_| from MediaStreamManager.

YCWebCameraSource.ax causes a huge amount of Chrome crashes. This CL
changes the initialization model of the Device Thread, a.k.a Audio
Thread, from Multiple Thread appartment model to Single Thread model,
MTA -> STA.

We'll monitor the crash rate in the Canaries to see if it has the
desired effect.

BUG=427192, 421991

Adding this since the android_dbg_tests_recipe bot seems stalled.
NOTRY=true

Review URL: https://codereview.chromium.org/700503002

Cr-Commit-Position: refs/heads/master@{#302596}
parent 131b320f
......@@ -234,6 +234,13 @@ class MediaStreamDispatcherHostTest : public testing::Test {
media_stream_manager_->video_capture_manager()
->video_capture_device_factory());
DCHECK(video_capture_device_factory_);
#if defined(OS_WIN)
// Override the Video Capture Thread that MediaStreamManager constructs.
media_stream_manager_->video_capture_manager()->Unregister();
media_stream_manager_->video_capture_manager()->Register(
media_stream_manager_.get(),
base::MessageLoopProxy::current());
#endif
MockResourceContext* mock_resource_context =
static_cast<MockResourceContext*>(
......
......@@ -360,6 +360,9 @@ MediaStreamManager::EnumerationCache::~EnumerationCache() {
MediaStreamManager::MediaStreamManager()
: audio_manager_(NULL),
#if defined(OS_WIN)
video_capture_thread_("VideoCaptureThread"),
#endif
monitoring_started_(false),
#if defined(OS_CHROMEOS)
has_checked_keyboard_mic_(false),
......@@ -369,6 +372,9 @@ MediaStreamManager::MediaStreamManager()
MediaStreamManager::MediaStreamManager(media::AudioManager* audio_manager)
: audio_manager_(audio_manager),
#if defined(OS_WIN)
video_capture_thread_("VideoCaptureThread"),
#endif
monitoring_started_(false),
#if defined(OS_CHROMEOS)
has_checked_keyboard_mic_(false),
......@@ -1595,7 +1601,16 @@ void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
video_capture_manager_ =
new VideoCaptureManager(media::VideoCaptureDeviceFactory::CreateFactory(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)));
#if defined(OS_WIN)
// Use an STA Video Capture Thread to try to avoid crashes on enumeration of
// buggy third party Direct Show modules, http://crbug.com/428958.
video_capture_thread_.init_com_with_mta(false);
CHECK(video_capture_thread_.Start());
video_capture_manager_->Register(this,
video_capture_thread_.message_loop_proxy());
#else
video_capture_manager_->Register(this, device_task_runner_);
#endif
}
void MediaStreamManager::Opened(MediaStreamType stream_type,
......
......@@ -37,6 +37,7 @@
#include "base/message_loop/message_loop.h"
#include "base/power_monitor/power_observer.h"
#include "base/system_monitor/system_monitor.h"
#include "base/threading/thread.h"
#include "content/browser/renderer_host/media/media_stream_provider.h"
#include "content/common/content_export.h"
#include "content/common/media/media_stream_options.h"
......@@ -382,6 +383,9 @@ class CONTENT_EXPORT MediaStreamManager
media::AudioManager* const audio_manager_; // not owned
scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_;
scoped_refptr<VideoCaptureManager> video_capture_manager_;
#if defined(OS_WIN)
base::Thread video_capture_thread_;
#endif
// Indicator of device monitoring state.
bool monitoring_started_;
......
......@@ -132,7 +132,9 @@ void VideoCaptureManager::Register(
void VideoCaptureManager::Unregister() {
DCHECK(listener_);
DCHECK(device_task_runner_.get());
listener_ = NULL;
device_task_runner_ = NULL;
}
void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment