summaryrefslogtreecommitdiffstats
path: root/media/video
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 02:45:25 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 02:45:25 +0000
commit4bc041dcff941529426dd849ebde305e59c494bd (patch)
tree82d3cfb86cdde607235990e929686043eae9c08a /media/video
parent84013309208f9297266ace608783502ab7d02a23 (diff)
downloadchromium_src-4bc041dcff941529426dd849ebde305e59c494bd.zip
chromium_src-4bc041dcff941529426dd849ebde305e59c494bd.tar.gz
chromium_src-4bc041dcff941529426dd849ebde305e59c494bd.tar.bz2
[Mac] Enumerate webcam devices on the main thread.
The associated bug is about a crash in code which is only loaded due to +deviceNames, though the crash does not have any such code on the stack. If that call were not thread-safe, then possibly using it on a different thread breaks assumptions about where things are allocated and released. BUG=139164 Review URL: https://chromiumcodereview.appspot.com/11017045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161024 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r--media/video/capture/mac/video_capture_device_qtkit_mac.mm22
1 files changed, 15 insertions, 7 deletions
diff --git a/media/video/capture/mac/video_capture_device_qtkit_mac.mm b/media/video/capture/mac/video_capture_device_qtkit_mac.mm
index 6427f18..fc65d2e 100644
--- a/media/video/capture/mac/video_capture_device_qtkit_mac.mm
+++ b/media/video/capture/mac/video_capture_device_qtkit_mac.mm
@@ -15,17 +15,25 @@
#pragma mark Class methods
-+ (NSDictionary *)deviceNames {
- NSArray *captureDevices =
++ (void)getDeviceNames:(NSMutableDictionary*)deviceNames {
+ NSArray* captureDevices =
[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo];
- NSMutableDictionary *deviceNames =
- [[[NSMutableDictionary alloc] init] autorelease];
for (QTCaptureDevice* device in captureDevices) {
- NSString* qtDeviceName = [device localizedDisplayName];
- NSString* qtUniqueId = [device uniqueID];
- [deviceNames setObject:qtDeviceName forKey:qtUniqueId];
+ [deviceNames setObject:[device localizedDisplayName]
+ forKey:[device uniqueID]];
}
+}
+
++ (NSDictionary*)deviceNames {
+ NSMutableDictionary* deviceNames =
+ [[[NSMutableDictionary alloc] init] autorelease];
+
+ // TODO(shess): Post to the main thread to see if that helps
+ // http://crbug.com/139164
+ [self performSelectorOnMainThread:@selector(getDeviceNames:)
+ withObject:deviceNames
+ waitUntilDone:YES];
return deviceNames;
}