mirror of https://github.com/axmolengine/axmol.git
Merge pull request #8115 from Dhilan007/v3-audio903
New Audio Engine -MAC
This commit is contained in:
commit
fdb30f1ee7
|
@ -1275,6 +1275,14 @@
|
|||
3E2BDAE919C0329B0055CDCD /* AudioPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E2BDAE319C0329B0055CDCD /* AudioPlayer.h */; };
|
||||
3E2BDAEA19C0329B0055CDCD /* AudioPlayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAE419C0329B0055CDCD /* AudioPlayer.mm */; };
|
||||
3E2BDAEC19C0436F0055CDCD /* AudioEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAEB19C0436F0055CDCD /* AudioEngine.cpp */; };
|
||||
3E2F27A619CFBFE100E7C490 /* AudioEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAEB19C0436F0055CDCD /* AudioEngine.cpp */; };
|
||||
3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E2BDADD19C030ED0055CDCD /* AudioEngine.h */; };
|
||||
3E2F27A819CFBFE900E7C490 /* AudioCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E2BDADF19C0329B0055CDCD /* AudioCache.h */; };
|
||||
3E2F27A919CFBFEC00E7C490 /* AudioCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAE019C0329B0055CDCD /* AudioCache.mm */; };
|
||||
3E2F27AA19CFBFEE00E7C490 /* AudioEngine-inl.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E2BDAE119C0329B0055CDCD /* AudioEngine-inl.h */; };
|
||||
3E2F27AB19CFBFF100E7C490 /* AudioEngine-inl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAE219C0329B0055CDCD /* AudioEngine-inl.mm */; };
|
||||
3E2F27AC19CFBFF300E7C490 /* AudioPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E2BDAE319C0329B0055CDCD /* AudioPlayer.h */; };
|
||||
3E2F27AD19CFBFF700E7C490 /* AudioPlayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDAE419C0329B0055CDCD /* AudioPlayer.mm */; };
|
||||
3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */; };
|
||||
3E6176691960F89B00DE83F5 /* CCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176561960F89B00DE83F5 /* CCController.h */; };
|
||||
3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176611960F89B00DE83F5 /* CCEventController.cpp */; };
|
||||
|
@ -4825,6 +4833,7 @@
|
|||
15AE191419AAD35000C27E9E /* CCSGUIReader.h in Headers */,
|
||||
15AE196D19AAD35700C27E9E /* CCActionTimeline.h in Headers */,
|
||||
15AE1A6D19AAD40300C27E9E /* b2ChainAndPolygonContact.h in Headers */,
|
||||
3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */,
|
||||
15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */,
|
||||
15AE19E919AAD3A700C27E9E /* Slot.h in Headers */,
|
||||
B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */,
|
||||
|
@ -4893,6 +4902,7 @@
|
|||
46C02E0918E91123004B7456 /* xxhash.h in Headers */,
|
||||
15AE1A6B19AAD40300C27E9E /* b2ChainAndCircleContact.h in Headers */,
|
||||
1A570110180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */,
|
||||
3E2F27AC19CFBFF300E7C490 /* AudioPlayer.h in Headers */,
|
||||
B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */,
|
||||
1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */,
|
||||
15AE1A6019AAD40300C27E9E /* b2ContactManager.h in Headers */,
|
||||
|
@ -5012,6 +5022,7 @@
|
|||
50643BE219BFCF1800EF68ED /* CCPlatformConfig.h in Headers */,
|
||||
5034CA49191D591100CE6051 /* ccShader_Label_df.frag in Headers */,
|
||||
292DB14119B4574100A80320 /* UIEditBoxImpl.h in Headers */,
|
||||
3E2F27AA19CFBFEE00E7C490 /* AudioEngine-inl.h in Headers */,
|
||||
1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */,
|
||||
50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */,
|
||||
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */,
|
||||
|
@ -5117,6 +5128,7 @@
|
|||
15AE199519AAD39600C27E9E /* LayoutReader.h in Headers */,
|
||||
15AE183219AAD2F700C27E9E /* CCOBB.h in Headers */,
|
||||
15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */,
|
||||
3E2F27A819CFBFE900E7C490 /* AudioCache.h in Headers */,
|
||||
50ABC01F1926664800A911A9 /* CCThread.h in Headers */,
|
||||
1A57035A180BD0B00088DEC7 /* unzip.h in Headers */,
|
||||
15AE188B19AAD33D00C27E9E /* CCControlLoader.h in Headers */,
|
||||
|
@ -5887,6 +5899,7 @@
|
|||
15AE1A5019AAD40300C27E9E /* b2BlockAllocator.cpp in Sources */,
|
||||
15AE1A8219AAD40300C27E9E /* b2GearJoint.cpp in Sources */,
|
||||
1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */,
|
||||
3E2F27AD19CFBFF700E7C490 /* AudioPlayer.mm in Sources */,
|
||||
B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
||||
50ABBFFF1926664800A911A9 /* CCFileUtils-apple.mm in Sources */,
|
||||
1A570075180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */,
|
||||
|
@ -5943,6 +5956,7 @@
|
|||
29394CF219B01DBA00D2DE1A /* UIWebView.mm in Sources */,
|
||||
15AE1BD419AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.cpp in Sources */,
|
||||
1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */,
|
||||
3E2F27AB19CFBFF100E7C490 /* AudioEngine-inl.mm in Sources */,
|
||||
1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */,
|
||||
15AE1A8619AAD40300C27E9E /* b2MouseJoint.cpp in Sources */,
|
||||
1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */,
|
||||
|
@ -6109,6 +6123,7 @@
|
|||
15AE1B7019AADA9900C27E9E /* CocosGUI.cpp in Sources */,
|
||||
15AE19D019AAD3A700C27E9E /* AttachmentLoader.cpp in Sources */,
|
||||
15AE19DE19AAD3A700C27E9E /* RegionAttachment.cpp in Sources */,
|
||||
3E2F27A919CFBFEC00E7C490 /* AudioCache.mm in Sources */,
|
||||
15AE19C819AAD3A700C27E9E /* AnimationStateData.cpp in Sources */,
|
||||
15AE18FA19AAD35000C27E9E /* CCColliderDetector.cpp in Sources */,
|
||||
50ABBEA71925AB6F00A911A9 /* CCTouch.cpp in Sources */,
|
||||
|
@ -6157,6 +6172,7 @@
|
|||
15AE190B19AAD35000C27E9E /* CCDisplayFactory.cpp in Sources */,
|
||||
1A9DCA27180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */,
|
||||
50ABBD541925AB0000A911A9 /* TransformUtils.cpp in Sources */,
|
||||
3E2F27A619CFBFE100E7C490 /* AudioEngine.cpp in Sources */,
|
||||
15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */,
|
||||
50ABBD9B1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */,
|
||||
15AE188119AAD33D00C27E9E /* CCBReader.cpp in Sources */,
|
||||
|
|
|
@ -876,6 +876,11 @@
|
|||
3E2BDAFF19C5E5B40055CDCD /* audio in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BDAD119BEA3E20055CDCD /* audio */; };
|
||||
3E2BDB0119C5E5D40055CDCD /* background.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BDB0019C5E5D40055CDCD /* background.wav */; };
|
||||
3E2BDB0219C5E5D40055CDCD /* background.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BDB0019C5E5D40055CDCD /* background.wav */; };
|
||||
3E2F27B919CFF4AF00E7C490 /* NewAudioEngineTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BDACE19BEA3410055CDCD /* NewAudioEngineTest.cpp */; };
|
||||
3E2F27BA19CFF52300E7C490 /* audio in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BDAD119BEA3E20055CDCD /* audio */; };
|
||||
3E2F27BB19CFF52A00E7C490 /* background.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BDB0019C5E5D40055CDCD /* background.wav */; };
|
||||
3E2F27BC19D00D7200E7C490 /* audio in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BDAD119BEA3E20055CDCD /* audio */; };
|
||||
3E2F27BD19D00D7D00E7C490 /* background.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BDB0019C5E5D40055CDCD /* background.wav */; };
|
||||
3E6177221960FAED00DE83F5 /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2d iOS.a */; };
|
||||
3E6177241960FAED00DE83F5 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D60AE43317F7FFE100757E4B /* CoreMotion.framework */; };
|
||||
3E6177251960FAED00DE83F5 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; };
|
||||
|
@ -7595,6 +7600,7 @@
|
|||
15D1FD2D1998637C00302043 /* OpenglConstants.lua in Resources */,
|
||||
15D1FCF11998637C00302043 /* Cocos2d.lua in Resources */,
|
||||
15D1FD47199863E800302043 /* DeprecatedCocoStudioClass.lua in Resources */,
|
||||
3E2F27BC19D00D7200E7C490 /* audio in Resources */,
|
||||
1AC35DC318CEE65100F37B72 /* Misc in Resources */,
|
||||
1AC35DC618CEE65100F37B72 /* Shaders in Resources */,
|
||||
15D1FD141998637C00302043 /* extern.lua in Resources */,
|
||||
|
@ -7625,6 +7631,7 @@
|
|||
15C90B4918E66C2A00D69802 /* tp.lua in Resources */,
|
||||
15D1FD281998637C00302043 /* Opengl.lua in Resources */,
|
||||
1AC35DE918CEE65900F37B72 /* effect1.wav in Resources */,
|
||||
3E2F27BD19D00D7D00E7C490 /* background.wav in Resources */,
|
||||
15C90B3F18E66C0C00D69802 /* ltn12.lua in Resources */,
|
||||
15C90B4718E66C2400D69802 /* socket.lua in Resources */,
|
||||
15C90B3A18E66BE200D69802 /* ftp.lua in Resources */,
|
||||
|
@ -7777,9 +7784,11 @@
|
|||
1AC35CFA18CED84500F37B72 /* Misc in Resources */,
|
||||
38FA2E76194AECF800FF2BE4 /* ActionTimeline in Resources */,
|
||||
1AC35D0418CED84500F37B72 /* Shaders in Resources */,
|
||||
3E2F27BA19CFF52300E7C490 /* audio in Resources */,
|
||||
1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */,
|
||||
B2507B6B192589AF00FA4972 /* Shaders3D in Resources */,
|
||||
1AC35D0618CED84500F37B72 /* spine in Resources */,
|
||||
3E2F27BB19CFF52A00E7C490 /* background.wav in Resources */,
|
||||
1AC35CE818CED84500F37B72 /* extensions in Resources */,
|
||||
1AC35CDE18CED84500F37B72 /* components in Resources */,
|
||||
1AC35D0818CED84500F37B72 /* TileMaps in Resources */,
|
||||
|
@ -8131,6 +8140,7 @@
|
|||
1AC35C6518CECF0C00F37B72 /* UnitTest.cpp in Sources */,
|
||||
29080DC9191B595E0066F8DF /* UISceneManager_Editor.cpp in Sources */,
|
||||
1AC35B3F18CECF0C00F37B72 /* Bug-458.cpp in Sources */,
|
||||
3E2F27B919CFF4AF00E7C490 /* NewAudioEngineTest.cpp in Sources */,
|
||||
1AC35C3918CECF0C00F37B72 /* PerformanceTextureTest.cpp in Sources */,
|
||||
1AC35B5318CECF0C00F37B72 /* CocosDenshionTest.cpp in Sources */,
|
||||
29080DD3191B595E0066F8DF /* UITextAtlasTest.cpp in Sources */,
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#include "audio/include/AudioEngine.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
#include "android/AudioEngine-inl.h"
|
||||
#elif CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#elif CC_TARGET_PLATFORM == CC_PLATFORM_IOS|| CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#include "ios/AudioEngine-inl.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#ifndef __AUDIO_ENGINE_H_
|
||||
#define __AUDIO_ENGINE_H_
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#ifndef __AUDIO_CACHE_H_
|
||||
#define __AUDIO_CACHE_H_
|
||||
|
@ -76,6 +76,7 @@ private:
|
|||
* Streaming in openal when sizeInBytes greater then PCMDATA_CACHEMAXSIZE
|
||||
*/
|
||||
char* _queBuffers[QUEUEBUFFER_NUM];
|
||||
ALsizei _queBufferSize[QUEUEBUFFER_NUM];
|
||||
UInt32 _queBufferFrames;
|
||||
UInt32 _queBufferBytes;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#include "AudioCache.h"
|
||||
#include <thread>
|
||||
#import <OpenAL/alc.h>
|
||||
|
@ -192,17 +193,18 @@ void AudioCache::readDataTask()
|
|||
_queBufferFrames = theFileFormat.mSampleRate * QUEUEBUFFER_TIME_STEP;
|
||||
_queBufferBytes = _queBufferFrames * outputFormat.mBytesPerFrame;
|
||||
|
||||
theDataBuffer.mNumberBuffers = QUEUEBUFFER_NUM;
|
||||
theDataBuffer.mNumberBuffers = 1;
|
||||
theDataBuffer.mBuffers[0].mNumberChannels = outputFormat.mChannelsPerFrame;
|
||||
for (int index = 0; index < QUEUEBUFFER_NUM; ++index) {
|
||||
_queBuffers[index] = (char*)malloc(_queBufferBytes);
|
||||
|
||||
theDataBuffer.mBuffers[index].mDataByteSize = _queBufferBytes;
|
||||
theDataBuffer.mBuffers[index].mNumberChannels = outputFormat.mChannelsPerFrame;
|
||||
theDataBuffer.mBuffers[index].mData = _queBuffers[index];
|
||||
theDataBuffer.mBuffers[0].mDataByteSize = _queBufferBytes;
|
||||
theDataBuffer.mBuffers[0].mData = _queBuffers[index];
|
||||
frames = _queBufferFrames;
|
||||
ExtAudioFileRead(extRef, (UInt32*)&frames, &theDataBuffer);
|
||||
|
||||
_queBufferSize[index] = theDataBuffer.mBuffers[0].mDataByteSize;
|
||||
}
|
||||
|
||||
frames = _queBufferFrames * QUEUEBUFFER_NUM;
|
||||
ExtAudioFileRead(extRef, (UInt32*)&frames, &theDataBuffer);
|
||||
}
|
||||
|
||||
ExitThread:
|
||||
|
@ -238,3 +240,5 @@ void AudioCache::addCallbacks(const std::function<void ()> &callback)
|
|||
}
|
||||
_callbackMutex.unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#ifndef __AUDIO_ENGINE_INL_H_
|
||||
#define __AUDIO_ENGINE_INL_H_
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#include "AudioEngine-inl.h"
|
||||
#include "audio/include/AudioEngine.h"
|
||||
|
||||
|
@ -36,17 +37,6 @@ using namespace cocos2d::experimental;
|
|||
static ALCdevice *s_ALDevice = nullptr;
|
||||
static ALCcontext *s_ALContext = nullptr;
|
||||
|
||||
static void AudioInterrupionListenerCallback(void* user_data, UInt32 interruption_state)
|
||||
{
|
||||
if(kAudioSessionBeginInterruption == interruption_state){
|
||||
alcMakeContextCurrent(nullptr);
|
||||
}
|
||||
else if (kAudioSessionEndInterruption == interruption_state){
|
||||
AudioSessionSetActive(true);
|
||||
alcMakeContextCurrent(s_ALContext);
|
||||
}
|
||||
}
|
||||
|
||||
namespace cocos2d {
|
||||
namespace experimental {
|
||||
class AudioEngineThreadPool
|
||||
|
@ -149,6 +139,7 @@ AudioEngineImpl::~AudioEngineImpl()
|
|||
|
||||
_audioCaches.clear();
|
||||
|
||||
alcMakeContextCurrent(nullptr);
|
||||
alcDestroyContext(s_ALContext);
|
||||
}
|
||||
if (s_ALDevice) {
|
||||
|
@ -162,9 +153,6 @@ AudioEngineImpl::~AudioEngineImpl()
|
|||
|
||||
bool AudioEngineImpl::init()
|
||||
{
|
||||
//set up the audio session
|
||||
AudioSessionInitialize(nullptr, nullptr, AudioInterrupionListenerCallback, nullptr);
|
||||
|
||||
bool ret = false;
|
||||
do{
|
||||
s_ALDevice = alcOpenDevice(nullptr);
|
||||
|
@ -450,6 +438,10 @@ void AudioEngineImpl::update(float dt)
|
|||
auto playerIt = _audioPlayers.find(audioID);
|
||||
if (playerIt != _audioPlayers.end()) {
|
||||
_alSourceUsed[playerIt->second._alSource] = false;
|
||||
if(playerIt->second._finishCallbak) {
|
||||
auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID];
|
||||
playerIt->second._finishCallbak(audioID, *audioInfo.filePath);
|
||||
}
|
||||
_audioPlayers.erase(audioID);
|
||||
AudioEngine::remove(audioID);
|
||||
}
|
||||
|
@ -474,8 +466,8 @@ void AudioEngineImpl::update(float dt)
|
|||
|
||||
if (player._ready && sourceState == AL_STOPPED) {
|
||||
_alSourceUsed[player._alSource] = false;
|
||||
auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID];
|
||||
if (player._finishCallbak) {
|
||||
auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID];
|
||||
player._finishCallbak(audioID, *audioInfo.filePath);
|
||||
}
|
||||
|
||||
|
@ -506,3 +498,5 @@ void AudioEngineImpl::uncacheAll()
|
|||
{
|
||||
_audioCaches.clear();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
|
||||
#ifndef __AUDIO_PLAYER_H_
|
||||
#define __AUDIO_PLAYER_H_
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#include "AudioPlayer.h"
|
||||
#include "AudioCache.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
@ -80,14 +81,14 @@ bool AudioPlayer::play2d(AudioCache* cache)
|
|||
alGenBuffers(3, _bufferIds);
|
||||
alError = alGetError();
|
||||
if (alError == AL_NO_ERROR) {
|
||||
_rotateBufferThread = std::thread(&AudioPlayer::rotateBufferThread,this, _audioCache->_queBufferFrames * QUEUEBUFFER_NUM + 1);
|
||||
|
||||
for (int index = 0; index < QUEUEBUFFER_NUM; ++index) {
|
||||
alBufferData(_bufferIds[index], _audioCache->_format, _audioCache->_queBuffers[index], _audioCache->_queBufferBytes, _audioCache->_sampleRate);
|
||||
alBufferData(_bufferIds[index], _audioCache->_format, _audioCache->_queBuffers[index], _audioCache->_queBufferSize[index], _audioCache->_sampleRate);
|
||||
}
|
||||
alSourcei(_alSource, AL_BUFFER, NULL);
|
||||
alSourceQueueBuffers(_alSource, QUEUEBUFFER_NUM, _bufferIds);
|
||||
|
||||
_timeMtx.lock();
|
||||
_rotateBufferThread = std::thread(&AudioPlayer::rotateBufferThread,this, _audioCache->_queBufferFrames * QUEUEBUFFER_NUM + 1);
|
||||
}
|
||||
else {
|
||||
printf("%s:alGenBuffers error code:%x", __PRETTY_FUNCTION__,alError);
|
||||
|
@ -213,3 +214,5 @@ bool AudioPlayer::setTime(float time)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#include "lua_cocos2dx_audioengine_manual.h"
|
||||
#include "lua_cocos2dx_audioengine_auto.hpp"
|
||||
#include "tolua_fix.h"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_AUDIOENGINE_LUA_COCOS2DX_AUDIOENGINE_MANUAL_H__
|
||||
#define COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_AUDIOENGINE_LUA_COCOS2DX_AUDIOENGINE_MANUAL_H__
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#include "NewAudioEngineTest.h"
|
||||
#include "ui/CocosGUI.h"
|
||||
|
||||
|
@ -561,7 +561,7 @@ bool AudioProfileTest::init()
|
|||
|
||||
char text[30];
|
||||
_files[0] = "background.mp3";
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
_files[1] = "background.caf";
|
||||
#else
|
||||
_files[1] = "background.ogg";
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
#ifndef __NEWAUDIOENGINE_TEST_H_
|
||||
#define __NEWAUDIOENGINE_TEST_H_
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ Controller g_aTestNames[] = {
|
|||
{ "Actions - Ease", [](){return new ActionsEaseTestScene();} },
|
||||
{ "Actions - Progress", [](){return new ProgressActionsTestScene(); } },
|
||||
{ "Audio - CocosDenshion", []() { return new CocosDenshionTestScene(); } },
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
{ "Audio - NewAudioEngine", []() { return new AudioEngineTestScene(); } },
|
||||
#endif
|
||||
{ "Box2d - Basic", []() { return new Box2DTestScene(); } },
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "PerformanceTest/PerformanceTest.h"
|
||||
#include "ZwoptexTest/ZwoptexTest.h"
|
||||
#include "CocosDenshionTest/CocosDenshionTest.h"
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#include "NewAudioEngineTest/NewAudioEngineTest.h"
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPEN)
|
||||
|
|
|
@ -23,7 +23,7 @@ int lua_module_register(lua_State* L)
|
|||
register_network_module(L);
|
||||
register_cocosdenshion_module(L);
|
||||
register_cocos3d_module(L);
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||
register_audioengine_module(L);
|
||||
#endif
|
||||
return 1;
|
||||
|
|
|
@ -350,7 +350,7 @@ function AudioProfileTest.create()
|
|||
AudioProfileTest._files = {}
|
||||
AudioProfileTest._files[1] = "background.mp3"
|
||||
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||
if (cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_IPAD == targetPlatform) then
|
||||
if (cc.PLATFORM_OS_MAC == currPlatform or cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_IPAD == targetPlatform) then
|
||||
AudioProfileTest._files[2] = "background.caf"
|
||||
elseif (cc.PLATFORM_OS_ANDROID == targetPlatform) then
|
||||
AudioProfileTest._files[2] = "background.ogg"
|
||||
|
@ -451,7 +451,7 @@ function InvalidAudioFileTest.create()
|
|||
-- unsupported media type
|
||||
local function playUnsupportedAudio(tag, sender)
|
||||
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||
if (cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_IPAD == targetPlatform) then
|
||||
if (cc.PLATFORM_OS_MAC == currPlatform or cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_IPAD == targetPlatform) then
|
||||
ccexp.AudioEngine:play2d("background.ogg")
|
||||
end
|
||||
if (cc.PLATFORM_OS_ANDROID == targetPlatform) then
|
||||
|
|
|
@ -66,7 +66,7 @@ local BeginPos = {x = 0, y = 0}
|
|||
|
||||
local audioEndineSupported = false
|
||||
local currPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||
if (cc.PLATFORM_OS_IPHONE == currPlatform or cc.PLATFORM_OS_IPAD == currPlatform or cc.PLATFORM_OS_ANDROID == currPlatform) then
|
||||
if (cc.PLATFORM_OS_MAC == currPlatform or cc.PLATFORM_OS_IPHONE == currPlatform or cc.PLATFORM_OS_IPAD == currPlatform or cc.PLATFORM_OS_ANDROID == currPlatform) then
|
||||
audioEndineSupported = true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue