Chromium Code Reviews| 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 |