Skip to content

Commit

Permalink
Mac: Avoid [AVFoundationBundle load] every time that IsAVFoundationSu…
Browse files Browse the repository at this point in the history
…pported() is called

Change the result of AVFoundationGlue::IsAVFoundationSupported() to
be evaluated only once, and return the static bool every time.

The order of the flag evaluation changes subtly:
- First we check for OS version: there's no AVFoundation
in Mac OS X < 10.7.
- Second comes the check for command line flag for explicit
AVFoundation disabling (hence using QTKit).
- Third and final, the library tries to be loaded

BUG=288562, 342790

Review URL: https://codereview.chromium.org/185233003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254845 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mcasas@chromium.org committed Mar 4, 2014
1 parent f43d93c commit e3549aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions media/video/capture/mac/avfoundation_glue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@
LAZY_INSTANCE_INITIALIZER;

bool AVFoundationGlue::IsAVFoundationSupported() {
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
return (!cmd_line->HasSwitch(switches::kDisableAVFoundation) &&
base::mac::IsOSLionOrLater() && [AVFoundationBundle() load]);
// DeviceMonitorMac will initialize this static bool from the main UI thread
// once, during Chrome startup so this construction is thread safe.
static bool is_av_foundation_supported = base::mac::IsOSLionOrLater() &&
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAVFoundation) && [AVFoundationBundle() load];
return is_av_foundation_supported;
}

NSBundle const* AVFoundationGlue::AVFoundationBundle() {
Expand Down

0 comments on commit e3549aa

Please sign in to comment.