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

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

Issue 9320070: Re-added OnChannelClosing in MediaStreamDispatcherHost to close open media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indentation after rebase. Created 8 years, 10 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
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 0e943ff8a521838be18a19d36ae73e24b66832d4..37ec5f7e5ae335f93b17eee3e508d72e23072326 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -47,19 +47,9 @@ VideoCaptureManager::VideoCaptureManager()
}
VideoCaptureManager::~VideoCaptureManager() {
- // 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!";
- 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_.Stop();
+ DCHECK(devices_.empty());
+ DCHECK(controllers_.empty());
}
void VideoCaptureManager::Register(MediaStreamProviderListener* listener) {
@@ -199,22 +189,23 @@ void VideoCaptureManager::OnClose(int capture_session_id) {
DCHECK(IsOnCaptureDeviceThread());
media::VideoCaptureDevice* video_capture_device = NULL;
- VideoCaptureDevices::iterator it = devices_.find(capture_session_id);
- if (it != devices_.end()) {
- video_capture_device = it->second;
- devices_.erase(it);
- }
- if (video_capture_device && !DeviceInUse(video_capture_device)) {
- // Deallocate (if not done already) and delete the device.
- video_capture_device->DeAllocate();
- Controllers::iterator cit = controllers_.find(video_capture_device);
- if (cit != controllers_.end()) {
- delete cit->second;
- controllers_.erase(cit);
+ VideoCaptureDevices::iterator device_it = devices_.find(capture_session_id);
+ if (device_it != devices_.end()) {
+ video_capture_device = device_it->second;
+ devices_.erase(device_it);
+ if (!DeviceInUse(video_capture_device)) {
+ // No other users of this device, deallocate (if not done already) and
+ // delete the device. No need to take care of the controller, that is done
+ // by |OnStop|.
+ video_capture_device->DeAllocate();
+ Controllers::iterator cit = controllers_.find(video_capture_device);
+ if (cit != controllers_.end()) {
+ delete cit->second;
+ controllers_.erase(cit);
+ }
+ delete video_capture_device;
}
- delete video_capture_device;
}
-
PostOnClosed(capture_session_id);
}
@@ -509,17 +500,4 @@ media::VideoCaptureDevice* VideoCaptureManager::GetDeviceInternal(
return NULL;
}
-void VideoCaptureManager::TerminateOnDeviceThread() {
- DCHECK(IsOnCaptureDeviceThread());
-
- std::set<media::VideoCaptureDevice*> devices_to_delete;
- for (VideoCaptureDevices::iterator it = devices_.begin();
- it != devices_.end(); ++it) {
- it->second->DeAllocate();
- devices_to_delete.insert(it->second);
- }
- STLDeleteElements(&devices_to_delete);
- STLDeleteValues(&controllers_);
-}
-
} // namespace media_stream

Powered by Google App Engine
This is Rietveld 408576698