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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 1097553003: Switch to STA mode for audio thread and WASAPI I/O streams. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 8 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/browser/renderer_host/media/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 23 matching lines...) Expand all
34 #include "content/public/common/content_client.h" 34 #include "content/public/common/content_client.h"
35 #include "content/public/common/content_switches.h" 35 #include "content/public/common/content_switches.h"
36 #include "content/public/common/media_stream_request.h" 36 #include "content/public/common/media_stream_request.h"
37 #include "media/audio/audio_manager_base.h" 37 #include "media/audio/audio_manager_base.h"
38 #include "media/audio/audio_parameters.h" 38 #include "media/audio/audio_parameters.h"
39 #include "media/base/channel_layout.h" 39 #include "media/base/channel_layout.h"
40 #include "media/base/media_switches.h" 40 #include "media/base/media_switches.h"
41 #include "media/video/capture/video_capture_device_factory.h" 41 #include "media/video/capture/video_capture_device_factory.h"
42 #include "url/gurl.h" 42 #include "url/gurl.h"
43 43
44 #if defined(OS_WIN)
45 #include "base/win/scoped_com_initializer.h"
46 #endif
47
48 #if defined(OS_CHROMEOS) 44 #if defined(OS_CHROMEOS)
49 #include "chromeos/audio/cras_audio_handler.h" 45 #include "chromeos/audio/cras_audio_handler.h"
50 #endif 46 #endif
51 47
52 namespace content { 48 namespace content {
53 49
54 // Forward declaration of DeviceMonitorMac and its only useable method. 50 // Forward declaration of DeviceMonitorMac and its only useable method.
55 class DeviceMonitorMac { 51 class DeviceMonitorMac {
56 public: 52 public:
57 void StartMonitoring( 53 void StartMonitoring(
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 376
381 MediaStreamManager::EnumerationCache::EnumerationCache() 377 MediaStreamManager::EnumerationCache::EnumerationCache()
382 : valid(false) { 378 : valid(false) {
383 } 379 }
384 380
385 MediaStreamManager::EnumerationCache::~EnumerationCache() { 381 MediaStreamManager::EnumerationCache::~EnumerationCache() {
386 } 382 }
387 383
388 MediaStreamManager::MediaStreamManager() 384 MediaStreamManager::MediaStreamManager()
389 : audio_manager_(NULL), 385 : audio_manager_(NULL),
390 #if defined(OS_WIN)
391 video_capture_thread_("VideoCaptureThread"),
392 #endif
393 monitoring_started_(false), 386 monitoring_started_(false),
394 #if defined(OS_CHROMEOS) 387 #if defined(OS_CHROMEOS)
395 has_checked_keyboard_mic_(false), 388 has_checked_keyboard_mic_(false),
396 #endif 389 #endif
397 io_loop_(NULL), 390 io_loop_(NULL),
398 use_fake_ui_(false) {} 391 use_fake_ui_(false) {}
399 392
400 MediaStreamManager::MediaStreamManager(media::AudioManager* audio_manager) 393 MediaStreamManager::MediaStreamManager(media::AudioManager* audio_manager)
401 : audio_manager_(audio_manager), 394 : audio_manager_(audio_manager),
402 #if defined(OS_WIN)
403 video_capture_thread_("VideoCaptureThread"),
404 #endif
405 monitoring_started_(false), 395 monitoring_started_(false),
406 #if defined(OS_CHROMEOS) 396 #if defined(OS_CHROMEOS)
407 has_checked_keyboard_mic_(false), 397 has_checked_keyboard_mic_(false),
408 #endif 398 #endif
409 io_loop_(NULL), 399 io_loop_(NULL),
410 use_fake_ui_(false) { 400 use_fake_ui_(false) {
411 DCHECK(audio_manager_); 401 DCHECK(audio_manager_);
412 memset(active_enumeration_ref_count_, 0, 402 memset(active_enumeration_ref_count_, 0,
413 sizeof(active_enumeration_ref_count_)); 403 sizeof(active_enumeration_ref_count_));
414 404
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 1615 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
1626 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is 1616 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is
1627 // fixed. 1617 // fixed.
1628 tracked_objects::ScopedTracker tracking_profile1( 1618 tracked_objects::ScopedTracker tracking_profile1(
1629 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1619 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1630 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 1")); 1620 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 1"));
1631 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1621 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1632 if (device_task_runner_.get()) 1622 if (device_task_runner_.get())
1633 return; 1623 return;
1634 1624
1625 // On Windows this must be a COM STA thread to avoid crashes on enumeration of
1626 // buggy third party Direct Show modules, http://crbug.com/428958.
1635 device_task_runner_ = audio_manager_->GetWorkerTaskRunner(); 1627 device_task_runner_ = audio_manager_->GetWorkerTaskRunner();
1636 1628
1637 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is 1629 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is
1638 // fixed. 1630 // fixed.
1639 tracked_objects::ScopedTracker tracking_profile2( 1631 tracked_objects::ScopedTracker tracking_profile2(
1640 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1632 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1641 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 2")); 1633 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 2"));
1642 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_); 1634 audio_input_device_manager_ = new AudioInputDeviceManager(audio_manager_);
1643 audio_input_device_manager_->Register(this, device_task_runner_); 1635 audio_input_device_manager_->Register(this, device_task_runner_);
1644 1636
(...skipping 13 matching lines...) Expand all
1658 } 1650 }
1659 1651
1660 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is 1652 // TODO(dalecurtis): Remove ScopedTracker below once crbug.com/457525 is
1661 // fixed. 1653 // fixed.
1662 tracked_objects::ScopedTracker tracking_profile4( 1654 tracked_objects::ScopedTracker tracking_profile4(
1663 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1655 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1664 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 4")); 1656 "457525 MediaStreamManager::InitializeDeviceManagersOnIOThread 4"));
1665 video_capture_manager_ = 1657 video_capture_manager_ =
1666 new VideoCaptureManager(media::VideoCaptureDeviceFactory::CreateFactory( 1658 new VideoCaptureManager(media::VideoCaptureDeviceFactory::CreateFactory(
1667 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); 1659 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)));
1668 #if defined(OS_WIN)
1669 // Use an STA Video Capture Thread to try to avoid crashes on enumeration of
1670 // buggy third party Direct Show modules, http://crbug.com/428958.
1671 video_capture_thread_.init_com_with_mta(false);
1672 CHECK(video_capture_thread_.Start());
1673 video_capture_manager_->Register(this,
1674 video_capture_thread_.message_loop_proxy());
1675 #else
1676 video_capture_manager_->Register(this, device_task_runner_); 1660 video_capture_manager_->Register(this, device_task_runner_);
1677 #endif
1678 } 1661 }
1679 1662
1680 void MediaStreamManager::Opened(MediaStreamType stream_type, 1663 void MediaStreamManager::Opened(MediaStreamType stream_type,
1681 int capture_session_id) { 1664 int capture_session_id) {
1682 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1665 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1683 DVLOG(1) << "Opened({stream_type = " << stream_type << "} " 1666 DVLOG(1) << "Opened({stream_type = " << stream_type << "} "
1684 << "{capture_session_id = " << capture_session_id << "})"; 1667 << "{capture_session_id = " << capture_session_id << "})";
1685 // Find the request(s) containing this device and mark it as used. 1668 // Find the request(s) containing this device and mark it as used.
1686 // It can be used in several requests since the same device can be 1669 // It can be used in several requests since the same device can be
1687 // requested from the same web page. 1670 // requested from the same web page.
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 } 2180 }
2198 } 2181 }
2199 2182
2200 void MediaStreamManager::SetKeyboardMicOnDeviceThread() { 2183 void MediaStreamManager::SetKeyboardMicOnDeviceThread() {
2201 DCHECK(device_task_runner_->BelongsToCurrentThread()); 2184 DCHECK(device_task_runner_->BelongsToCurrentThread());
2202 audio_manager_->SetHasKeyboardMic(); 2185 audio_manager_->SetHasKeyboardMic();
2203 } 2186 }
2204 #endif 2187 #endif
2205 2188
2206 } // namespace content 2189 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698