diff --git a/cocos/audio/include/AudioCache.h b/cocos/audio/include/AudioCache.h index af3a636182..2fe82cd3f8 100644 --- a/cocos/audio/include/AudioCache.h +++ b/cocos/audio/include/AudioCache.h @@ -35,6 +35,7 @@ #include "platform/CCPlatformMacros.h" #include "audio/include/AudioMacros.h" +#include "audio/include/alconfig.h" NS_CC_BEGIN diff --git a/cocos/audio/include/AudioEngineImpl.h b/cocos/audio/include/AudioEngineImpl.h index 19df448899..c6013e8b90 100644 --- a/cocos/audio/include/AudioEngineImpl.h +++ b/cocos/audio/include/AudioEngineImpl.h @@ -68,7 +68,7 @@ private: void _updateLocked(float dt); void _play2d(AudioCache *cache, AUDIO_ID audioID); ALuint findValidSource(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && !CC_USE_ALSOFT_ON_APPLE +#if !CC_USE_ALSOFT static ALvoid myAlSourceNotificationCallback(ALuint sid, ALuint notificationID, ALvoid* userData); #endif ALuint _alSources[MAX_AUDIOINSTANCES]; diff --git a/cocos/audio/include/AudioMacros.h b/cocos/audio/include/AudioMacros.h index 13fe262180..bdcbd40054 100644 --- a/cocos/audio/include/AudioMacros.h +++ b/cocos/audio/include/AudioMacros.h @@ -84,17 +84,3 @@ do { \ #define AUDIO_ID int #define AUDIO_ID_PRID "%d" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && !CC_USE_ALSOFT_ON_APPLE -#import -#define MAX_AUDIOINSTANCES 24 -#else -#ifdef OPENAL_PLAIN_INCLUDES -#include -#include -#else -#include -#include -#endif -#define MAX_AUDIOINSTANCES 32 -#endif diff --git a/cocos/audio/include/AudioPlayer.h b/cocos/audio/include/AudioPlayer.h index df3df26d4f..8154739fcc 100644 --- a/cocos/audio/include/AudioPlayer.h +++ b/cocos/audio/include/AudioPlayer.h @@ -34,6 +34,7 @@ #include "audio/include/AudioMacros.h" #include "platform/CCPlatformMacros.h" +#include "audio/include/alconfig.h" NS_CC_BEGIN @@ -60,7 +61,7 @@ protected: void setCache(AudioCache* cache); void rotateBufferThread(int offsetFrame); bool play2d(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && !CC_USE_ALSOFT_ON_APPLE +#if !CC_USE_ALSOFT void wakeupRotateThread(); #endif @@ -84,7 +85,7 @@ protected: std::mutex _sleepMutex; bool _timeDirty; bool _isRotateThreadExited; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && !CC_USE_ALSOFT_ON_APPLE +#if !CC_USE_ALSOFT std::atomic_bool _needWakeupRotateThread; #endif diff --git a/cocos/audio/include/alconfig.h b/cocos/audio/include/alconfig.h new file mode 100644 index 0000000000..a5edc6e567 --- /dev/null +++ b/cocos/audio/include/alconfig.h @@ -0,0 +1,46 @@ +/**************************************************************************** + Copyright (c) 2014-2016 Chukong Technologies Inc. + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2020 c4games.com. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#pragma once + +#ifndef CC_USE_ALSOFT_ON_APPLE +#define CC_USE_ALSOFT_ON_APPLE 0 +#endif + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && !CC_USE_ALSOFT_ON_APPLE +#import +#define MAX_AUDIOINSTANCES 24 +#define CC_USE_ALSOFT 0 +#else +#ifdef OPENAL_PLAIN_INCLUDES +#include +#include +#else +#include +#include +#endif +#define MAX_AUDIOINSTANCES 32 +#define CC_USE_ALSOFT 1 +#endif diff --git a/cocos/platform/CCPlatformConfig.h b/cocos/platform/CCPlatformConfig.h index 81f8980638..8b97c334c1 100644 --- a/cocos/platform/CCPlatformConfig.h +++ b/cocos/platform/CCPlatformConfig.h @@ -123,10 +123,5 @@ THE SOFTWARE. #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__