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

Side by Side Diff: media/video/capture/win/video_capture_device_win.cc

Issue 10662049: Move the device enumerate/open/close work to device thread from IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Magnus' comments. Created 8 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 | Annotate | Revision Log
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 "media/video/capture/win/video_capture_device_win.h" 5 #include "media/video/capture/win/video_capture_device_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 9
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 } // namespace 171 } // namespace
172 172
173 namespace media { 173 namespace media {
174 174
175 // Name of a fake DirectShow filter that exist on computers with 175 // Name of a fake DirectShow filter that exist on computers with
176 // GTalk installed. 176 // GTalk installed.
177 static const char kGoogleCameraAdapter[] = "google camera adapter"; 177 static const char kGoogleCameraAdapter[] = "google camera adapter";
178 178
179 // Gets the names of all video capture devices connected to this computer. 179 // Gets the names of all video capture devices connected to this computer.
180 // This API can only be run on a COM initialized thread.
180 void VideoCaptureDevice::GetDeviceNames(Names* device_names) { 181 void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
181 DCHECK(device_names); 182 DCHECK(device_names);
182 183
183 base::win::ScopedCOMInitializer coinit;
184 ScopedComPtr<ICreateDevEnum> dev_enum; 184 ScopedComPtr<ICreateDevEnum> dev_enum;
tommi (sloooow) - chröme 2012/07/02 13:36:36 DCHECK(CalledOnValidThread()) first
185 HRESULT hr = dev_enum.CreateInstance(CLSID_SystemDeviceEnum, NULL, 185 HRESULT hr = dev_enum.CreateInstance(CLSID_SystemDeviceEnum, NULL,
186 CLSCTX_INPROC); 186 CLSCTX_INPROC);
187 if (FAILED(hr)) 187 if (FAILED(hr))
188 return; 188 return;
189 189
190 ScopedComPtr<IEnumMoniker> enum_moniker; 190 ScopedComPtr<IEnumMoniker> enum_moniker;
191 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, 191 hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
192 enum_moniker.Receive(), 0); 192 enum_moniker.Receive(), 0);
193 // CreateClassEnumerator returns S_FALSE on some Windows OS 193 // CreateClassEnumerator returns S_FALSE on some Windows OS
194 // when no camera exist. Therefore the FAILED macro can't be used. 194 // when no camera exist. Therefore the FAILED macro can't be used.
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 return diff_list.front().capability_index; 652 return diff_list.front().capability_index;
653 } 653 }
654 654
655 void VideoCaptureDeviceWin::SetErrorState(const char* reason) { 655 void VideoCaptureDeviceWin::SetErrorState(const char* reason) {
656 DVLOG(1) << reason; 656 DVLOG(1) << reason;
657 state_ = kError; 657 state_ = kError;
658 observer_->OnError(); 658 observer_->OnError();
659 } 659 }
660 660
661 } // namespace media 661 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698