From 2f2633ec91bc110aa92f704c5cf9141402101a7b Mon Sep 17 00:00:00 2001 From: HALX99 Date: Tue, 26 Nov 2019 03:07:55 +0800 Subject: [PATCH 1/3] fix typo, GLenum to ALenum --- cocos/audio/include/AudioMacros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/audio/include/AudioMacros.h b/cocos/audio/include/AudioMacros.h index 46f6d2f078..61b020f42b 100644 --- a/cocos/audio/include/AudioMacros.h +++ b/cocos/audio/include/AudioMacros.h @@ -62,7 +62,7 @@ #if defined(COCOS2D_DEBUG) && COCOS2D_DEBUG > 0 #define CHECK_AL_ERROR_DEBUG() \ do { \ - GLenum __error = alGetError(); \ + ALenum __error = alGetError(); \ if (__error) { \ ALOGE("OpenAL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \ } \ From 8546d4d7e1e9df4728e7be96f2c988f9b93217a6 Mon Sep 17 00:00:00 2001 From: HALX99 Date: Tue, 26 Nov 2019 09:54:25 +0800 Subject: [PATCH 2/3] Update AudioEngineImpl.mm --- cocos/audio/apple/AudioEngineImpl.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/audio/apple/AudioEngineImpl.mm b/cocos/audio/apple/AudioEngineImpl.mm index 832e0ab41d..7fca17d9d3 100644 --- a/cocos/audio/apple/AudioEngineImpl.mm +++ b/cocos/audio/apple/AudioEngineImpl.mm @@ -716,7 +716,7 @@ void AudioEngineImpl::update(float dt) std::string filePath; if (player->_finishCallbak) { auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID]; - filePath = *audioInfo.filePath; + filePath = audioInfo.filePath; } AudioEngine::remove(audioID); From bf807f896933341d1f203c3a00693fc76e3a2c35 Mon Sep 17 00:00:00 2001 From: halx99 Date: Tue, 26 Nov 2019 10:21:21 +0800 Subject: [PATCH 3/3] fix prid --- cocos/audio/AudioEngineImpl.cpp | 14 +++++++------- cocos/audio/apple/AudioEngineImpl.mm | 14 +++++++------- cocos/audio/include/AudioEngine.h | 5 +---- cocos/audio/include/AudioMacros.h | 3 +-- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/cocos/audio/AudioEngineImpl.cpp b/cocos/audio/AudioEngineImpl.cpp index eed6d5ee07..f019638a9a 100644 --- a/cocos/audio/AudioEngineImpl.cpp +++ b/cocos/audio/AudioEngineImpl.cpp @@ -233,7 +233,7 @@ void AudioEngineImpl::setVolume(AUDIO_ID audioID,float volume) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s: audio id = %d, error = %x", __FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __FUNCTION__,audioID,error); } } } @@ -254,7 +254,7 @@ void AudioEngineImpl::setLoop(AUDIO_ID audioID, bool loop) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s: audio id = %d, error = %x", __FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __FUNCTION__,audioID,error); } } } @@ -271,7 +271,7 @@ bool AudioEngineImpl::pause(AUDIO_ID audioID) auto error = alGetError(); if (error != AL_NO_ERROR) { ret = false; - ALOGE("%s: audio id = %d, error = %x\n", __FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x\n", __FUNCTION__,audioID,error); } return ret; @@ -285,7 +285,7 @@ bool AudioEngineImpl::resume(AUDIO_ID audioID) auto error = alGetError(); if (error != AL_NO_ERROR) { ret = false; - ALOGE("%s: audio id = %d, error = %x\n", __FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x\n", __FUNCTION__,audioID,error); } return ret; @@ -342,7 +342,7 @@ float AudioEngineImpl::getCurrentTime(AUDIO_ID audioID) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s, audio id:%d,error code:%x", __FUNCTION__,audioID,error); + ALOGE("%s, audio id:" AUDIO_ID_PRID ",error code:%x", __FUNCTION__,audioID,error); } } } @@ -367,7 +367,7 @@ bool AudioEngineImpl::setCurrentTime(AUDIO_ID audioID, float time) else { if (player->_audioCache->_framesRead != player->_audioCache->_totalFrames && (time * player->_audioCache->_sampleRate) > player->_audioCache->_framesRead) { - ALOGE("%s: audio id = %d", __FUNCTION__,audioID); + ALOGE("%s: audio id = " AUDIO_ID_PRID, __FUNCTION__,audioID); break; } @@ -375,7 +375,7 @@ bool AudioEngineImpl::setCurrentTime(AUDIO_ID audioID, float time) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s: audio id = %d, error = %x", __FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __FUNCTION__,audioID,error); } ret = true; } diff --git a/cocos/audio/apple/AudioEngineImpl.mm b/cocos/audio/apple/AudioEngineImpl.mm index 7fca17d9d3..cd1765e0a9 100644 --- a/cocos/audio/apple/AudioEngineImpl.mm +++ b/cocos/audio/apple/AudioEngineImpl.mm @@ -503,7 +503,7 @@ void AudioEngineImpl::setVolume(AUDIO_ID audioID,float volume) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s: audio id = %zu, error = %x", __PRETTY_FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __PRETTY_FUNCTION__,audioID,error); } } } @@ -531,7 +531,7 @@ void AudioEngineImpl::setLoop(AUDIO_ID audioID, bool loop) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s: audio id = %zu, error = %x", __PRETTY_FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __PRETTY_FUNCTION__,audioID,error); } } } @@ -557,7 +557,7 @@ bool AudioEngineImpl::pause(AUDIO_ID audioID) auto error = alGetError(); if (error != AL_NO_ERROR) { ret = false; - ALOGE("%s: audio id = %zu, error = %x", __PRETTY_FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __PRETTY_FUNCTION__,audioID,error); } return ret; @@ -579,7 +579,7 @@ bool AudioEngineImpl::resume(AUDIO_ID audioID) auto error = alGetError(); if (error != AL_NO_ERROR) { ret = false; - ALOGE("%s: audio id = %zu, error = %x", __PRETTY_FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __PRETTY_FUNCTION__,audioID,error); } return ret; @@ -634,7 +634,7 @@ float AudioEngineImpl::getCurrentTime(AUDIO_ID audioID) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s, audio id:%zu,error code:%x", __PRETTY_FUNCTION__,audioID,error); + ALOGE("%s, audio id:" AUDIO_ID_PRID ",error code:%x", __PRETTY_FUNCTION__,audioID,error); } } } @@ -659,7 +659,7 @@ bool AudioEngineImpl::setCurrentTime(AUDIO_ID audioID, float time) else { if (player->_audioCache->_framesRead != player->_audioCache->_totalFrames && (time * player->_audioCache->_sampleRate) > player->_audioCache->_framesRead) { - ALOGE("%s: audio id = %zu", __PRETTY_FUNCTION__,audioID); + ALOGE("%s: audio id = " AUDIO_ID_PRID, __PRETTY_FUNCTION__,audioID); break; } @@ -667,7 +667,7 @@ bool AudioEngineImpl::setCurrentTime(AUDIO_ID audioID, float time) auto error = alGetError(); if (error != AL_NO_ERROR) { - ALOGE("%s: audio id = %zu, error = %x", __PRETTY_FUNCTION__,audioID,error); + ALOGE("%s: audio id = " AUDIO_ID_PRID ", error = %x", __PRETTY_FUNCTION__,audioID,error); } ret = true; } diff --git a/cocos/audio/include/AudioEngine.h b/cocos/audio/include/AudioEngine.h index dcf2c9fbfe..510306dd9d 100644 --- a/cocos/audio/include/AudioEngine.h +++ b/cocos/audio/include/AudioEngine.h @@ -27,6 +27,7 @@ #include "platform/CCPlatformConfig.h" #include "platform/CCPlatformMacros.h" +#include "audio/include/AudioMacros.h" #include "audio/include/Export.h" #include #include @@ -37,10 +38,6 @@ #undef ERROR #endif // ERROR -#if !defined(AUDIO_ID) -#define AUDIO_ID int -#endif - /** * @addtogroup audio * @{ diff --git a/cocos/audio/include/AudioMacros.h b/cocos/audio/include/AudioMacros.h index 61b020f42b..f455587f46 100644 --- a/cocos/audio/include/AudioMacros.h +++ b/cocos/audio/include/AudioMacros.h @@ -82,6 +82,5 @@ do { \ break; \ } -#if !defined(AUDIO_ID) #define AUDIO_ID int -#endif +#define AUDIO_ID_PRID "%d"