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

Unified 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: small changes to fix the trybots' failure 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/capture/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/win/video_capture_device_win.cc
diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc
index 55b5a16de823698b8bfe091b7b45f45bc2735e42..05d5b4388ad6df8de2d36a35b02fc67388361627 100644
--- a/media/video/capture/win/video_capture_device_win.cc
+++ b/media/video/capture/win/video_capture_device_win.cc
@@ -180,7 +180,6 @@ static const char kGoogleCameraAdapter[] = "google camera adapter";
void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
DCHECK(device_names);
- base::win::ScopedCOMInitializer coinit;
ScopedComPtr<ICreateDevEnum> dev_enum;
HRESULT hr = dev_enum.CreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC);
@@ -255,9 +254,11 @@ VideoCaptureDeviceWin::VideoCaptureDeviceWin(const Name& device_name)
: device_name_(device_name),
state_(kIdle),
observer_(NULL) {
+ DetachFromThread();
}
VideoCaptureDeviceWin::~VideoCaptureDeviceWin() {
+ DCHECK(CalledOnValidThread());
if (media_control_)
media_control_->Stop();
@@ -276,6 +277,7 @@ VideoCaptureDeviceWin::~VideoCaptureDeviceWin() {
}
bool VideoCaptureDeviceWin::Init() {
+ DCHECK(CalledOnValidThread());
HRESULT hr = GetDeviceFilter(device_name_, capture_filter_.Receive());
if (!capture_filter_) {
DVLOG(2) << "Failed to create capture filter.";
@@ -331,6 +333,7 @@ void VideoCaptureDeviceWin::Allocate(
int height,
int frame_rate,
VideoCaptureDevice::EventHandler* observer) {
+ DCHECK(CalledOnValidThread());
if (state_ != kIdle)
return;
@@ -427,6 +430,7 @@ void VideoCaptureDeviceWin::Allocate(
}
void VideoCaptureDeviceWin::Start() {
+ DCHECK(CalledOnValidThread());
if (state_ != kAllocated)
return;
@@ -440,6 +444,7 @@ void VideoCaptureDeviceWin::Start() {
}
void VideoCaptureDeviceWin::Stop() {
+ DCHECK(CalledOnValidThread());
if (state_ != kCapturing)
return;
@@ -453,6 +458,7 @@ void VideoCaptureDeviceWin::Stop() {
}
void VideoCaptureDeviceWin::DeAllocate() {
+ DCHECK(CalledOnValidThread());
if (state_ == kIdle)
return;
@@ -475,6 +481,7 @@ void VideoCaptureDeviceWin::DeAllocate() {
}
const VideoCaptureDevice::Name& VideoCaptureDeviceWin::device_name() {
+ DCHECK(CalledOnValidThread());
return device_name_;
}
@@ -485,6 +492,7 @@ void VideoCaptureDeviceWin::FrameReceived(const uint8* buffer,
}
bool VideoCaptureDeviceWin::CreateCapabilityMap() {
+ DCHECK(CalledOnValidThread());
ScopedComPtr<IAMStreamConfig> stream_config;
HRESULT hr = output_capture_pin_.QueryInterface(stream_config.Receive());
if (FAILED(hr)) {
@@ -594,6 +602,7 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() {
int VideoCaptureDeviceWin::GetBestMatchedCapability(int requested_width,
int requested_height,
int requested_frame_rate) {
+ DCHECK(CalledOnValidThread());
std::list<ResolutionDiff> diff_list;
// Loop through the candidates to create a list of differentials between the
@@ -653,6 +662,7 @@ int VideoCaptureDeviceWin::GetBestMatchedCapability(int requested_width,
}
void VideoCaptureDeviceWin::SetErrorState(const char* reason) {
+ DCHECK(CalledOnValidThread());
DVLOG(1) << reason;
state_ = kError;
observer_->OnError();
« no previous file with comments | « media/video/capture/win/video_capture_device_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698