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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 8589018: Close video capture devices on the device thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « content/browser/renderer_host/media/video_capture_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/video_capture_manager.cc
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index ce686e60e4dcd3113d870d11cc68f1625e54394b..8d6547fdebb545837ba32e9f2d3c4afc359ad44f 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -45,19 +45,21 @@ VideoCaptureManager::VideoCaptureManager()
}
VideoCaptureManager::~VideoCaptureManager() {
- vc_device_thread_.Stop();
// TODO(mflodman) Remove this temporary solution when shut-down issue is
// resolved, i.e. all code below this comment.
// Temporary solution: close all open devices and delete them, after the
// thread is stopped.
DLOG_IF(ERROR, !devices_.empty()) << "VideoCaptureManager: Open devices!";
- for (VideoCaptureDevices::iterator it = devices_.begin();
- it != devices_.end();
- ++it) {
- it->second->DeAllocate();
- delete it->second;
- }
- STLDeleteValues(&controllers_);
+ listener_ = NULL;
+ // The devices must be stopped on the device thread to avoid threading issues
+ // in native device code.
+ vc_device_thread_.message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&VideoCaptureManager::TerminateOnDeviceThread,
+ base::Unretained(this)));
+ vc_device_thread_.message_loop()->PostTask(FROM_HERE,
+ new MessageLoop::QuitTask);
wjia(left Chromium) 2011/11/17 19:06:30 QuitTask is not needed. vc_device_thread_.Stop() w
mflodman_chromium_OOO 2011/11/18 08:22:45 Done.
+ vc_device_thread_.Stop();
}
void VideoCaptureManager::Register(MediaStreamProviderListener* listener) {
@@ -502,4 +504,15 @@ media::VideoCaptureDevice* VideoCaptureManager::GetDeviceInternal(
return NULL;
}
+void VideoCaptureManager::TerminateOnDeviceThread() {
+ DCHECK(IsOnCaptureDeviceThread());
+
+ for (VideoCaptureDevices::iterator it = devices_.begin();
+ it != devices_.end(); ++it) {
+ it->second->DeAllocate();
+ delete it->second;
wjia(left Chromium) 2011/11/17 19:06:30 There was a bug here since multiple capture_sessio
mflodman_chromium_OOO 2011/11/18 08:22:45 Done.
+ }
+ STLDeleteValues(&controllers_);
+}
+
} // namespace media_stream
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698