axmol/cocos/base
James Chen 15ef80e27d [big refactoring] Audio latency fix for Android. Support to preload effects on Android now. (#15875)
* Audio latency fix for Android. Support preload effects on Android now.

Squashed commits:
[b6d80fe] log fix
[a0a918e] Fixes assetFd didn't be released while PcmData is returned from cache.
[4b956ba] Potential crash fix for PcmAudioPlayer while pause / resume.
[398ab8c] Updates LOG_TAG position in AudioEngine-inl.cpp
[e3634e7] include stdlib.h for posix_memalign
[9004074] fixes setVolume logical error.
[c96df46] Don't use another thread for mixing, enqueue is in a seperated thread, therefore doing mixing in another thread will waste more time.
[0a4c1a8] Adds setLoop, setVolume, setPostion support for Track
[c35fb20] Fixed include.
[cdd9d32] Do mixing by ourself. (TO BE POLISHED)
[6447025] µ -> u since µ could not be shown on some android devices.
[97be0c6] Don't send a silence clip.
[c1607ed] Make linter.py happy.
[0898b54] Puts enqueue & SetPlayState in PcmAudioPlayer::play to thread pool.
[b79fc01] Adds getDuration, getPosition support for PcmAudioPlayer
[80fa2ab] minor fix of the code position of resetting state to State::INITIALIZED
[d9c62f1] underrun fix for PcmAudioPlayer.
[9c2212a] UrlAudioPlayer, playOverMutex should be static, and should be used in update method.
[1519d2e] static variables
[19da936] _pcmAudioPlayer Null pointer check in AudioPlayerProvider.
[e6b0d14] Updates audio performance test.
[fc01dd4] Registers foreground & background event in AudioEngine-inl.cpp(android), the callback should invoke `provider`'s pause & resume method.
[e00a886] TBD: Pause & resume support for PcmAudioPlayerPool.
Since OpenSLES audio resources are expensive and device shared, we should delete all unused PcmAudioPlayers in pool while pause and re-create them while resume.
But this commit isn't finished yet, I don't find a better way to register pause&resume event in AudioEngine module.
[9e42ea3] Interleave mono audio to stereo audio. PcmAudioPlayerPool only contains PcmAudioPlayers with 2 channels.
[3f18d05] Adds a strategy for checking small size of different file formats.
[753ff49] Adds performance test for AudioEngine.
[09d3045] Releases an extra PcmAudioPlayer for UrlAudioPlayer while allocating PcmAudioPlayer fails.
[9dd4477] Using std::move for PcmData move constructor & move assignment.
[6ca3bcb] some fixes:
1) new -> new (std::nothrow)
2) break if allocate PcmAudioPlayer fails
3) renames 'initForPlayPcmData' to 'init'
4) PcmAudioPlayer destructor deadlock if 'init' failed
[54675b6] include path fix.
[a1903ca] More refactorings.
[19b9498] Makes linter.py happy. :)
[923c530] Fixes:
1) Avoid getFileInfo to be invoked twice
2) A critical bug fix for UrlAudioPlayer and adds detailed comments
3) __clang__ compiler option fix for AudioResamplerSinc.cpp.
[5ec4faf] minor fix.
[faaa0f3] output a log in the destructor of UrlAudioPlayer.
[9c20355] NewAudioEngineTest,TestControll crash fix.
[f114464] fixes an unused import.
[1dc5dab] Better algorithm for allocating PcmAudioPlayer.
[331a213] minor fix.
[e54084a] null -> nullptr
[f9a0389] Support uncache.
[89a364f] Removes unused update, and TODO uncache functionality.
[1732bf9] Supports AudioEngineImpl::setFinishCallback for android.
[43d1596] UrlAudioPlayer::stop fix.
[e2ee941] Test case fix in NewAudioEngineTest/AudioIssue11143Test
[5c5ba01] More fixes for making cpp-tests/New Audio Engine Test happy.
[8b554a3] Adds log while remove player from map.
[ed71322] If original file is larger than 30k bytes, consider it's a large audio file.
[fb1845a] Updates project.properties
[6f3839f] minor log output fix in AudioEngine-inl.cpp
[c68bc6c] Don't resample if the sample rate of the decoded pcm data matchs the device's.
[43ca45f] PcmAudioPlayers also need to be removed while they play over, but should not be deleted since their lifecycle is managed by PcmAudioPlayerPool.
[f5e63c9] Audio latency fix for Android. Support preload effects on Android now.

* Supports to loading audio files asynchronously.

* Crash fix for stop audio right after play2d.

* Minor fix for logic in AudioMixerController.cpp

* Adds missing files (CCThreadPool.h/.cpp).

* Minor fix for including.

* Minor fix for missing include <functional> in Track.h

* update license information in audio.h

* Don't use std::future/std::promise anymore since ndk counldn't support it well in armeabi arch.

* isSmallFile postion updated, fixes large audio file goto the checking logic of cache.

* std::atomic<int> isn't supported by ndk-r10e while compiling with `armeabi` arch, using a int with a mutex instead.

* fixes __isnanf & posix_memalign doesn't exist on low api (<=16) devices.

* namespace updated: cocos2d -> cocos2d::experimental

* Removes commented code in AudioMixerController.h/.cpp

* Removes unused code again, and fixes a memory leak of `Track` instance.

* Oops, namespace changed.

* Only outputs log in debug mode.

* Uses ALOGV for outputing logs in AudioEngine-inl.cpp

* const PcmData& ->  PcmData for Track

* Fixes a protential crash in NewAudioEngineTest

* Adds `COCOS` prefix in header #ifndef COCOS_BALABALA #define COCOS_BALABALA

* Uses _ prefix for cocos code style instead of `m` prefix.

* Deletes AudioResamplerSinc related files.

* Bug fix from @minggo's reply on github.

* Don't need to invoke pause after in UrlAudioPlayer::prepare.

* Updates ThreadPool class, uses enum class and adds const keyword.
2016-07-18 10:22:40 +08:00
..
allocator Fix -Wsometimes-uninitialized warning in release build 2016-06-16 14:27:52 +09:00
CCAsyncTaskPool.cpp Fix typo of function name in AsyncTaskPool 2016-02-26 00:22:46 +09:00
CCAsyncTaskPool.h Fix typo of function name in AsyncTaskPool 2016-02-26 00:22:46 +09:00
CCAutoreleasePool.cpp fix issue autorelease will not release trigger by autorelease. 2015-03-11 15:31:06 +08:00
CCAutoreleasePool.h Fix typos in documentation 2015-12-03 21:03:00 +09:00
CCConfiguration.cpp Merge pull request #14709 from kcisoul/v3 2016-01-12 11:35:00 +08:00
CCConfiguration.h Windows/osx/linux build fail bug fixed 2015-12-17 15:40:16 +09:00
CCConsole.cpp use std::srand() instead 2016-07-11 11:17:28 +08:00
CCConsole.h Use const references whenever possible 2016-05-17 13:17:56 +09:00
CCController-android.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
CCController-iOS.mm Merge pull request #14426 from pyrosphere/fix-controller-ios6 2016-04-20 11:45:13 +08:00
CCController.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
CCController.h Add enum value for no key 2015-12-01 03:01:42 +02:00
CCData.cpp Merge pull request #16091 from mtak-/data_clear_on_move 2016-07-14 11:40:19 +08:00
CCData.h Fix documentation when compile with -Wdocumentation and Clang 2016-07-10 17:38:32 +09:00
CCDataVisitor.cpp Squashed commit of the following: 2014-04-26 10:11:22 -07:00
CCDataVisitor.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
CCDirector.cpp Add missing float suffix to avoid -Wdouble-promotion 2016-07-04 23:12:45 +09:00
CCDirector.h Closes websocket connection by dispatching a 'resetDirector' event. 2016-02-29 18:55:51 +08:00
CCEvent.cpp Improved directory structure 2014-04-29 17:37:36 -07:00
CCEvent.h fix typos and syntax error. A thorough check by tool VSSpellChecker. 2015-09-22 16:08:23 +08:00
CCEventAcceleration.cpp Improved directory structure 2014-04-29 17:37:36 -07:00
CCEventAcceleration.h update comments. 2015-03-27 12:07:19 +08:00
CCEventController.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
CCEventController.h Fix typos in documentation 2015-12-03 21:03:00 +09:00
CCEventCustom.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
CCEventCustom.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventDispatcher.cpp fix: reverse iterator on events + doesn't use additionalTransform 2016-06-22 11:28:58 -07:00
CCEventDispatcher.h Pass native references to script scope 2015-12-21 00:16:16 +08:00
CCEventFocus.cpp Cleanup order of fields initialization. 2014-10-30 17:28:41 +03:00
CCEventFocus.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventKeyboard.cpp Improved directory structure 2014-04-29 17:37:36 -07:00
CCEventKeyboard.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventListener.cpp issue #10323: Fix the compile error when COCOS2D_DEBUG>=2. 2015-06-04 11:58:22 +08:00
CCEventListener.h fix typos and syntax error. A thorough check by tool VSSpellChecker. 2015-09-22 16:08:23 +08:00
CCEventListenerAcceleration.cpp add more descriptive message to ASSET macro. 2015-07-14 15:28:36 +08:00
CCEventListenerAcceleration.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventListenerController.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
CCEventListenerController.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventListenerCustom.cpp Adds `std::nothrow` to `new` 2014-08-27 16:31:57 -07:00
CCEventListenerCustom.h fix typos and syntax error. A thorough check by tool VSSpellChecker. 2015-09-22 16:08:23 +08:00
CCEventListenerFocus.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
CCEventListenerFocus.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventListenerKeyboard.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
CCEventListenerKeyboard.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventListenerMouse.cpp EventListenerMouse will dispatch EventMouse events 2015-09-07 20:05:51 +02:00
CCEventListenerMouse.h EventListenerMouse will dispatch EventMouse events 2015-09-07 20:05:51 +02:00
CCEventListenerTouch.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
CCEventListenerTouch.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventMouse.cpp initialize _startPointCaptured. 2014-12-15 19:42:25 +08:00
CCEventMouse.h Fixed missing const-correctness 2015-05-20 17:19:42 +02:00
CCEventTouch.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
CCEventTouch.h Merge pull request #11120 from fusijie/cocosapi 2015-03-25 09:49:52 +08:00
CCEventType.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
CCGameController.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
CCIMEDelegate.h Revert "UIEditBox attachWithIME, detachWithIME make working" 2016-03-22 14:18:39 +08:00
CCIMEDispatcher.cpp Use nullptr instead of 0 or NULL 2016-05-25 03:09:11 +09:00
CCIMEDispatcher.h Revert "UIEditBox attachWithIME, detachWithIME make working" 2016-03-22 14:18:39 +08:00
CCMap.h Fix implicit conversion issues with Xcode 7.3 2016-04-07 17:01:17 +09:00
CCNS.cpp Avoid creating temporary string objects 2016-02-03 23:12:37 +08:00
CCNS.h [ci skip]Update comments 2015-03-27 15:31:42 +08:00
CCNinePatchImageParser.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
CCNinePatchImageParser.h Fix documentation when compile with -Wdocumentation and Clang 2016-07-10 17:38:32 +09:00
CCProfiling.cpp [big refactoring] Audio latency fix for Android. Support to preload effects on Android now. (#15875) 2016-07-18 10:22:40 +08:00
CCProfiling.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
CCProperties.cpp Use nullptr instead of 0 or NULL 2016-06-23 12:39:23 +09:00
CCProperties.h fix: removes `friend class Game` 2016-04-27 18:57:41 -07:00
CCProtocols.h add PlayableFrame 2016-01-12 17:21:01 +08:00
CCRef.cpp Fix lua engine crashes caused by CC_ENABLE_GC_FOR_NATIVE_OBJECTS 2016-02-21 20:20:32 +08:00
CCRef.h more js fixes 2015-12-11 15:18:09 -08:00
CCRefPtr.h Improve RefPtr to avoid casting when possible 2016-06-26 21:39:43 +09:00
CCScheduler.cpp Adds `std::nothrow` to the `new` statements 2015-12-16 14:02:55 +08:00
CCScheduler.h Fix typos in documentation 2015-12-03 21:03:00 +09:00
CCScriptSupport.cpp support custom action, and rewrite update function 2015-09-09 10:08:07 +08:00
CCScriptSupport.h Some lua bindings fixes: 2016-06-22 17:48:17 +08:00
CCStencilStateManager.cpp Fix unused variable warning when building with Xcode 2016-04-22 20:25:32 +09:00
CCStencilStateManager.hpp rename CCStencilBitsManager to StencilStateManager 2015-11-25 14:24:27 +08:00
CCTouch.cpp Remove default arguments 2015-12-02 11:02:27 +08:00
CCTouch.h Remove default arguments 2015-12-02 11:02:27 +08:00
CCUserDefault-android.cpp Avoid creating temporary string objects 2016-02-03 23:12:37 +08:00
CCUserDefault-apple.mm Fixes import path for m and mm files. 2016-03-21 20:12:58 +08:00
CCUserDefault-winrt.cpp Use nullptr instead of 0 or NULL 2016-06-23 12:39:23 +09:00
CCUserDefault.cpp Use nullptr instead of 0 or NULL 2016-05-25 03:09:11 +09:00
CCUserDefault.h Fix typos and other mistakes in docs 2016-07-04 00:42:10 +09:00
CCValue.cpp Use std::abs to avoid overhead of casting float to double 2016-07-13 00:55:11 +09:00
CCValue.h Add support for Unsigned with CCValue (#13785) 2016-04-22 13:49:20 +08:00
CCVector.h Fix implicit conversion issues with Xcode 7.3 2016-04-07 17:01:17 +09:00
CMakeLists.txt Squashed commit of the following: 2016-03-02 16:51:54 -08:00
ObjectFactory.cpp fix 2014-09-02 10:51:17 +08:00
ObjectFactory.h Moved base/CCPlatform* -> platform/CCPlatform* 2014-09-09 17:17:07 -07:00
TGAlib.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
TGAlib.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
ZipUtils.cpp Fix various typos 2016-07-06 08:27:39 +09:00
ZipUtils.h Fix various typos 2016-07-06 08:27:39 +09:00
atitc.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
atitc.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
base64.cpp Fix calculation of outLength 2016-03-12 15:42:52 +08:00
base64.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
ccCArray.cpp remove unneeded includes 2014-08-29 15:39:52 +08:00
ccCArray.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
ccConfig.h Add a config option to enable or disable the premultiplied alpha code. 2016-06-20 18:05:11 +02:00
ccFPSImages.c fix libpng warning 2014-12-27 20:47:59 +08:00
ccFPSImages.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
ccMacros.h animate3d callback and test 2015-07-17 11:08:27 +08:00
ccRandom.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
ccRandom.h fix extra @ symbol in Base group 2015-03-27 12:01:20 +08:00
ccTypes.cpp Add optional alpha parameter to Color4B and Color4F constructors 2016-03-16 16:08:49 -06:00
ccTypes.h Fix documentation when compile with -Wdocumentation and Clang 2016-07-10 17:38:32 +09:00
ccUTF8.cpp Move StringUtils functions from deprecated header file to ccUTF8.h (#15835) 2016-06-15 15:01:26 +08:00
ccUTF8.h Move StringUtils functions from deprecated header file to ccUTF8.h (#15835) 2016-06-15 15:01:26 +08:00
ccUtils.cpp #Use std::string reference instead of char* for utils::findChild (#16117) 2016-07-14 13:52:30 +08:00
ccUtils.h #Use std::string reference instead of char* for utils::findChild (#16117) 2016-07-14 13:52:30 +08:00
etc1.cpp Squashed commit of the following: 2014-04-30 19:09:13 -07:00
etc1.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
firePngData.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
pvr.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
pvr.h Copyright & small fixes 2014-07-22 15:49:38 +04:00
s3tc.cpp Fixes 1605 include path in 541 files 2016-03-20 21:53:44 +08:00
s3tc.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
uthash.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00
utlist.h [ci skip]Update comments 2015-03-24 20:23:51 +08:00