diff --git a/cmake/Modules/CocosConfigDepend.cmake b/cmake/Modules/CocosConfigDepend.cmake index 8919459869..e13e30ac93 100644 --- a/cmake/Modules/CocosConfigDepend.cmake +++ b/cmake/Modules/CocosConfigDepend.cmake @@ -26,18 +26,25 @@ macro(cocos2dx_depend) include_directories(/System/Library/Frameworks) find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox) find_library(FOUNDATION_LIBRARY Foundation) - find_library(OPENAL_LIBRARY OpenAL) find_library(QUARTZCORE_LIBRARY QuartzCore) find_library(GAMECONTROLLER_LIBRARY GameController) find_library(METAL_LIBRARY Metal) set(COCOS_APPLE_LIBS - ${OPENAL_LIBRARY} ${AUDIOTOOLBOX_LIBRARY} ${QUARTZCORE_LIBRARY} ${FOUNDATION_LIBRARY} ${GAMECONTROLLER_LIBRARY} ${METAL_LIBRARY} ) + + message(STATUS "[AudioBackend] CC_USE_ALSOFT_ON_APPLE=${CC_USE_ALSOFT_ON_APPLE}") + if(NOT CC_USE_ALSOFT_ON_APPLE) + find_library(OPENAL_LIBRARY OpenAL) + set(COCOS_APPLE_LIBS + ${OPENAL_LIBRARY} + ${COCOS_APPLE_LIBS} + ) + endif() if(MACOSX) list(APPEND PREBUILT_SPECIFIC_LIBS GLFW3) diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index de65aa8811..7511a70c46 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -51,6 +51,13 @@ include(audio/CMakeLists.txt) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) option(BUILD_EXTENSIONS "Build extension library" ON) +option(CC_USE_ALSOFT_ON_APPLE "Use openal-soft on apple platform" OFF) + +set(CC_USE_ALSOFT_ON_APPLE ${CC_USE_ALSOFT_ON_APPLE} CACHE BOOL "Use openal-soft on apple platform" FORCE) + +if(CC_USE_ALSOFT_ON_APPLE) + add_definitions(-DCC_USE_ALSOFT_ON_APPLE=1) +endif() if(BUILD_EDITOR_COCOSTUDIO) include(editor-support/cocostudio/CMakeLists.txt) diff --git a/cocos/audio/AudioEngine.cpp b/cocos/audio/AudioEngine.cpp index 5b4ae0244d..0a2837af3a 100644 --- a/cocos/audio/AudioEngine.cpp +++ b/cocos/audio/AudioEngine.cpp @@ -32,7 +32,7 @@ #include "platform/CCFileUtils.h" #include "base/ccUtils.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && !CC_USE_ALSOFT_ON_APPLE #include "audio/apple/AudioEngineImpl.h" #else #include "audio/include/AudioEngineImpl.h" diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index f8ab51ea50..297a287b2b 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -76,26 +76,46 @@ elseif(LINUX) elseif(APPLE) # common + message(STATUS "[AudioEngine] CC_USE_ALSOFT_ON_APPLE=${CC_USE_ALSOFT_ON_APPLE}") + set(COCOS_AUDIO_PLATFORM_HEADER audio/include/AudioDecoderManager.h audio/include/AudioDecoder.h audio/include/AudioDecoderOgg.h audio/include/AudioDecoderWav.h audio/include/AudioCache.h - audio/apple/AudioPlayer.h audio/apple/AudioDecoderEXT.h - audio/apple/AudioEngineImpl.h ) + set(COCOS_AUDIO_PLATFORM_SRC audio/AudioDecoderManager.cpp audio/AudioDecoder.cpp audio/AudioDecoderOgg.cpp audio/AudioDecoderWav.cpp audio/apple/AudioDecoderEXT.mm - audio/apple/AudioCache.mm - audio/apple/AudioEngineImpl.mm - audio/apple/AudioPlayer.mm ) + + if(CC_USE_ALSOFT_ON_APPLE) + set(COCOS_AUDIO_PLATFORM_HEADER ${COCOS_AUDIO_PLATFORM_HEADER} + audio/include/AudioPlayer.h + audio/include/AudioEngineImpl.h + ) + set(COCOS_AUDIO_PLATFORM_SRC ${COCOS_AUDIO_PLATFORM_SRC} + audio/AudioCache.cpp + audio/AudioPlayer.cpp + audio/AudioEngineImpl.cpp + ) + else() + set(COCOS_AUDIO_PLATFORM_HEADER ${COCOS_AUDIO_PLATFORM_HEADER} + audio/apple/AudioPlayer.h + audio/apple/AudioEngineImpl.h + ) + set(COCOS_AUDIO_PLATFORM_SRC ${COCOS_AUDIO_PLATFORM_SRC} + audio/apple/AudioCache.mm + audio/apple/AudioPlayer.mm + audio/apple/AudioEngineImpl.mm + ) + endif() endif() set(COCOS_AUDIO_HEADER diff --git a/cocos/audio/include/AudioCache.h b/cocos/audio/include/AudioCache.h index d5f54aab5e..842226e1ab 100644 --- a/cocos/audio/include/AudioCache.h +++ b/cocos/audio/include/AudioCache.h @@ -33,7 +33,7 @@ #include #include -#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && !CC_USE_ALSOFT_ON_APPLE #import #else #ifdef OPENAL_PLAIN_INCLUDES diff --git a/cocos/platform/CCPlatformConfig.h b/cocos/platform/CCPlatformConfig.h index 432d6e7f76..81f8980638 100644 --- a/cocos/platform/CCPlatformConfig.h +++ b/cocos/platform/CCPlatformConfig.h @@ -117,7 +117,16 @@ THE SOFTWARE. #define CC_USE_GL #endif +// whether use google angleproject GLES on desktop +// https://github.com/google/angle +#ifndef CC_USE_GLES_ON_DESKTOP #define CC_USE_GLES_ON_DESKTOP 1 +#endif + +// whether use https://github.com/kcat/openal-soft on apple platform +#ifndef CC_USE_ALSOFT_ON_APPLE +#define CC_USE_ALSOFT_ON_APPLE 0 +#endif /// @endcond #endif // __BASE_CC_PLATFORM_CONFIG_H__ diff --git a/external/config.json b/external/config.json index cd6301c376..7a5a2574b2 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version": "v51", + "version": "v52", "zip_file_size": "107642814", "repo_name": "engine-x-3rd", "repo_parent": "https://github.com/c4games/",