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

Unified Diff: media/base/mac/avfoundation_glue.mm

Issue 1153063002: Initialize AVFoundation explicitly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add perf trace for InitializeAVFoundation and revert changes in browser_test_base.cc Created 5 years, 7 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: media/base/mac/avfoundation_glue.mm
diff --git a/media/base/mac/avfoundation_glue.mm b/media/base/mac/avfoundation_glue.mm
index 0c48e4b94ae9f3f2556bf76f00461f0453287ab3..aed571d5d4702c098c9fb1cfb7e1b944e8d7447d 100644
--- a/media/base/mac/avfoundation_glue.mm
+++ b/media/base/mac/avfoundation_glue.mm
@@ -119,7 +119,7 @@ class AVFoundationInternal {
// This contains the logic of checking whether AVFoundation is supported.
// It's called only once and the results are cached in a static bool.
-bool IsAVFoundationSupportedHelper() {
+bool LoadAVFoundationInternal() {
// AVFoundation is only available on OS Lion and above.
if (!base::mac::IsOSLionOrLater()) {
LogCaptureApi(CAPTURE_API_QTKIT_DUE_TO_OS_PREVIOUS_TO_LION);
@@ -149,11 +149,23 @@ bool IsAVFoundationSupportedHelper() {
static base::LazyInstance<AVFoundationInternal>::Leaky g_avfoundation_handle =
LAZY_INSTANCE_INITIALIZER;
+enum {
+ INITIALIZE_NOT_CALLED = 0,
+ AVFOUNDATION_IS_SUPPORTED,
+ AVFOUNDATION_NOT_SUPPORTED
+} static g_avfoundation_initialization = INITIALIZE_NOT_CALLED;
+
+void AVFoundationGlue::InitializeAVFoundation() {
+ CHECK([NSThread isMainThread]);
+ if (g_avfoundation_initialization != INITIALIZE_NOT_CALLED)
+ return;
+ g_avfoundation_initialization = LoadAVFoundationInternal() ?
+ AVFOUNDATION_IS_SUPPORTED : AVFOUNDATION_NOT_SUPPORTED;
+}
+
bool AVFoundationGlue::IsAVFoundationSupported() {
- // DeviceMonitorMac will initialize this static bool from the main UI thread
- // once, during Chrome startup so this construction is thread safe.
- static const bool is_supported = IsAVFoundationSupportedHelper();
- return is_supported;
+ CHECK_NE(g_avfoundation_initialization, INITIALIZE_NOT_CALLED);
+ return g_avfoundation_initialization == AVFOUNDATION_IS_SUPPORTED;
}
NSBundle const* AVFoundationGlue::AVFoundationBundle() {
« no previous file with comments | « media/base/mac/avfoundation_glue.h ('k') | media/video/capture/mac/video_capture_device_factory_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698