Add CMAKE option CC_USE_ALSOFT_ON_APPLE to use kcat openal-soft on apple platform, by default currently OFF

This commit is contained in:
halx99 2020-07-31 00:06:59 +08:00
parent 6512aa5a74
commit 594767290d
7 changed files with 53 additions and 10 deletions

View File

@ -26,12 +26,10 @@ macro(cocos2dx_depend)
include_directories(/System/Library/Frameworks) include_directories(/System/Library/Frameworks)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox) find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_library(FOUNDATION_LIBRARY Foundation) find_library(FOUNDATION_LIBRARY Foundation)
find_library(OPENAL_LIBRARY OpenAL)
find_library(QUARTZCORE_LIBRARY QuartzCore) find_library(QUARTZCORE_LIBRARY QuartzCore)
find_library(GAMECONTROLLER_LIBRARY GameController) find_library(GAMECONTROLLER_LIBRARY GameController)
find_library(METAL_LIBRARY Metal) find_library(METAL_LIBRARY Metal)
set(COCOS_APPLE_LIBS set(COCOS_APPLE_LIBS
${OPENAL_LIBRARY}
${AUDIOTOOLBOX_LIBRARY} ${AUDIOTOOLBOX_LIBRARY}
${QUARTZCORE_LIBRARY} ${QUARTZCORE_LIBRARY}
${FOUNDATION_LIBRARY} ${FOUNDATION_LIBRARY}
@ -39,6 +37,15 @@ macro(cocos2dx_depend)
${METAL_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) if(MACOSX)
list(APPEND PREBUILT_SPECIFIC_LIBS GLFW3) list(APPEND PREBUILT_SPECIFIC_LIBS GLFW3)

View File

@ -51,6 +51,13 @@ include(audio/CMakeLists.txt)
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
option(BUILD_EXTENSIONS "Build extension library" 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) if(BUILD_EDITOR_COCOSTUDIO)
include(editor-support/cocostudio/CMakeLists.txt) include(editor-support/cocostudio/CMakeLists.txt)

View File

@ -32,7 +32,7 @@
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"
#include "base/ccUtils.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" #include "audio/apple/AudioEngineImpl.h"
#else #else
#include "audio/include/AudioEngineImpl.h" #include "audio/include/AudioEngineImpl.h"

View File

@ -76,26 +76,46 @@ elseif(LINUX)
elseif(APPLE) elseif(APPLE)
# common # common
message(STATUS "[AudioEngine] CC_USE_ALSOFT_ON_APPLE=${CC_USE_ALSOFT_ON_APPLE}")
set(COCOS_AUDIO_PLATFORM_HEADER set(COCOS_AUDIO_PLATFORM_HEADER
audio/include/AudioDecoderManager.h audio/include/AudioDecoderManager.h
audio/include/AudioDecoder.h audio/include/AudioDecoder.h
audio/include/AudioDecoderOgg.h audio/include/AudioDecoderOgg.h
audio/include/AudioDecoderWav.h audio/include/AudioDecoderWav.h
audio/include/AudioCache.h audio/include/AudioCache.h
audio/apple/AudioPlayer.h
audio/apple/AudioDecoderEXT.h audio/apple/AudioDecoderEXT.h
audio/apple/AudioEngineImpl.h
) )
set(COCOS_AUDIO_PLATFORM_SRC set(COCOS_AUDIO_PLATFORM_SRC
audio/AudioDecoderManager.cpp audio/AudioDecoderManager.cpp
audio/AudioDecoder.cpp audio/AudioDecoder.cpp
audio/AudioDecoderOgg.cpp audio/AudioDecoderOgg.cpp
audio/AudioDecoderWav.cpp audio/AudioDecoderWav.cpp
audio/apple/AudioDecoderEXT.mm 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() endif()
set(COCOS_AUDIO_HEADER set(COCOS_AUDIO_HEADER

View File

@ -33,7 +33,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#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 <OpenAL/al.h> #import <OpenAL/al.h>
#else #else
#ifdef OPENAL_PLAIN_INCLUDES #ifdef OPENAL_PLAIN_INCLUDES

View File

@ -117,7 +117,16 @@ THE SOFTWARE.
#define CC_USE_GL #define CC_USE_GL
#endif #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 #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 /// @endcond
#endif // __BASE_CC_PLATFORM_CONFIG_H__ #endif // __BASE_CC_PLATFORM_CONFIG_H__

View File

@ -1,5 +1,5 @@
{ {
"version": "v51", "version": "v52",
"zip_file_size": "107642814", "zip_file_size": "107642814",
"repo_name": "engine-x-3rd", "repo_name": "engine-x-3rd",
"repo_parent": "https://github.com/c4games/", "repo_parent": "https://github.com/c4games/",