modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java
Print this page
rev 7587 : RT-38074: [macosx] Separate QTKit platform code from core media code so it can be removed for MAS
Reviewed-by:
*** 1,7 ****
/*
! * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 23,38 ****
--- 23,41 ----
* questions.
*/
package com.sun.media.jfxmediaimpl.platform.osx;
+ import com.sun.glass.utils.NativeLibLoader;
import com.sun.media.jfxmedia.Media;
import com.sun.media.jfxmedia.MediaPlayer;
import com.sun.media.jfxmedia.locator.Locator;
import com.sun.media.jfxmedia.logging.Logger;
import com.sun.media.jfxmediaimpl.HostUtils;
import com.sun.media.jfxmediaimpl.platform.Platform;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
/**
* Mac OS X Platform implementation.
*/
public final class OSXPlatform extends Platform {
*** 46,82 ****
"application/vnd.apple.mpegurl",
"audio/mpegurl"
};
private static final class OSXPlatformInitializer {
! private static final OSXPlatform globalInstance = new OSXPlatform();
}
public static Platform getPlatformInstance() {
return OSXPlatformInitializer.globalInstance;
}
private OSXPlatform() {
}
- @Override
- public void preloadPlatform() {}
-
/**
* @return false if the platform cannot be loaded
*/
@Override
public boolean loadPlatform() {
if (!HostUtils.isMacOSX()) {
return false;
}
try {
osxPlatformInit();
} catch (UnsatisfiedLinkError ule) {
if (Logger.canLog(Logger.DEBUG)) {
! Logger.logMsg(Logger.DEBUG, "Unable to load OSX platform.");
}
// MediaUtils.nativeError(OSXPlatform.class, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL);
return false;
}
return true;
--- 49,106 ----
"application/vnd.apple.mpegurl",
"audio/mpegurl"
};
private static final class OSXPlatformInitializer {
! private static final OSXPlatform globalInstance;
! static {
! // Platform is only available if we can load it's native lib
! // Do this early so we can report the correct content types
! boolean isLoaded = false;
! try {
! isLoaded = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
! try {
! NativeLibLoader.loadLibrary("jfxmedia_qtkit");
! } catch (UnsatisfiedLinkError ule) {
! // non-fatal condition, keep quiet about it
! return Boolean.FALSE;
! }
! return Boolean.TRUE;
! });
! } catch (Exception e) {
! // Ignore
! }
! if (isLoaded) {
! globalInstance = new OSXPlatform();
! } else {
! globalInstance = null;
! }
! }
}
public static Platform getPlatformInstance() {
return OSXPlatformInitializer.globalInstance;
}
private OSXPlatform() {
}
/**
* @return false if the platform cannot be loaded
*/
@Override
public boolean loadPlatform() {
if (!HostUtils.isMacOSX()) {
return false;
}
+ // ULE should not happen here, but just in case
try {
osxPlatformInit();
} catch (UnsatisfiedLinkError ule) {
if (Logger.canLog(Logger.DEBUG)) {
! Logger.logMsg(Logger.DEBUG, "QTKit platform lib is not available.");
}
// MediaUtils.nativeError(OSXPlatform.class, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL);
return false;
}
return true;