Merge pull request #124 from halx99/alsoft

Add CMAKE option CC_USE_ALSOFT_ON_APPLE to use kcat openal-soft
This commit is contained in:
HALX99 2020-07-30 20:49:08 -07:00 committed by GitHub
commit 908ad3ff04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 23 deletions

View File

@ -26,12 +26,10 @@ 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}
@ -39,6 +37,14 @@ macro(cocos2dx_depend)
${METAL_LIBRARY}
)
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)

View File

@ -34,6 +34,18 @@ set(COCOS2D_X_VERSION 4.0)
set(COCOS_CORE_LIB cocos2d)
project(cocos2d_libs)
# default value for cocos2dx extensions modules build
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()
include(2d/CMakeLists.txt)
include(3d/CMakeLists.txt)
include(platform/CMakeLists.txt)
@ -47,11 +59,6 @@ include(ui/CMakeLists.txt)
include(network/CMakeLists.txt)
include(audio/CMakeLists.txt)
# default value for cocos2dx extensions modules build
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)
if(BUILD_EDITOR_COCOSTUDIO)
include(editor-support/cocostudio/CMakeLists.txt)
set(COCOS_EDITOR_SUPPORT_SRC ${COCOS_EDITOR_SUPPORT_SRC} ${COCOS_CS_SRC} ${COCOS_CS_HEADER})

View File

@ -62,21 +62,19 @@ AudioDecoder* AudioDecoderManager::createDecoder(const std::string& path)
{
return new (std::nothrow) AudioDecoderOgg();
}
#if CC_TARGET_PLATFORM != CC_PLATFORM_IOS
else if (cxx20::ic::ends_with(svPath, ".mp3"))
{
#if CC_TARGET_PLATFORM != CC_PLATFORM_IOS
return new (std::nothrow) AudioDecoderMp3();
#else
return new (std::nothrow) AudioDecoderEXT();
#endif
}
else if (cxx20::ic::ends_with(svPath, ".wav")) {
#if CC_TARGET_PLATFORM != CC_PLATFORM_IOS
return new (std::nothrow) AudioDecoderWav();
#else
return new (std::nothrow) AudioDecoderEXT();
#endif
}
#else
else {
return new (std::nothrow) AudioDecoderEXT();
}
#endif
return nullptr;
}

View File

@ -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"

View File

@ -3,6 +3,8 @@ set(COCOS_AUDIO_SRC
audio/AudioEngine.cpp
)
message(STATUS "CC_USE_ALSOFT_ON_APPLE:${CC_USE_ALSOFT_ON_APPLE}")
if(WINDOWS)
set(COCOS_AUDIO_PLATFORM_HEADER
@ -82,20 +84,38 @@ elseif(APPLE)
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

View File

@ -33,7 +33,7 @@
#include <vector>
#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>
#else
#ifdef OPENAL_PLAIN_INCLUDES

View File

@ -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__

View File

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