From 49b9c9bde0005a109a0be2e65e852e2ad818b912 Mon Sep 17 00:00:00 2001 From: kenshin <420373550@qq.com> Date: Thu, 18 Oct 2018 10:37:29 +0800 Subject: [PATCH 1/6] remove the size reset, prevent the sprite size change after set a null spriteFrame. (#1398) remove the size reset, prevent the sprite size change after set a null spriteFrame. --- native/cocos/editor-support/creator/CCScale9Sprite.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/native/cocos/editor-support/creator/CCScale9Sprite.cpp b/native/cocos/editor-support/creator/CCScale9Sprite.cpp index 2f46d5fdc6..56e5ee3a29 100755 --- a/native/cocos/editor-support/creator/CCScale9Sprite.cpp +++ b/native/cocos/editor-support/creator/CCScale9Sprite.cpp @@ -930,8 +930,7 @@ bool Scale9SpriteV2::setSpriteFrame(cocos2d::SpriteFrame* spriteFrame) if(!spriteFrame) { - this->setContentSize(cocos2d::Size::ZERO); - return true; + return true; } CC_SAFE_RETAIN(spriteFrame); From 643972616e2e3e89bfde5e5ed2193f86612f2b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=BA=E6=98=8E?= Date: Tue, 24 Jul 2018 00:38:35 -0500 Subject: [PATCH 2/6] cherry pick: add some support for facebook --- .../runtime-src/proj.android-studio/app/build.gradle | 2 +- .../runtime-src/proj.android-studio/build.gradle | 3 +++ .../runtime-src/proj.android-studio/gradle.properties | 3 +++ .../HelloJavascript.xcodeproj/project.pbxproj | 10 ++++++++-- .../runtime-src/proj.android-studio/app/build.gradle | 2 +- .../runtime-src/proj.android-studio/build.gradle | 3 +++ .../runtime-src/proj.android-studio/gradle.properties | 3 +++ .../HelloJavascript.xcodeproj/project.pbxproj | 10 ++++++++-- 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle index 54747452aa..49f049836c 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle @@ -119,7 +119,7 @@ android.applicationVariants.all { variant -> } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: 'libs', include: ['*.jar','*.aar']) implementation fileTree(dir: "../../../cocos2d-x/cocos/platform/android/java/libs", include: ['*.jar']) implementation project(':libcocos2dx') } diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle index 2b56747de5..bed518f5fc 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/build.gradle @@ -19,6 +19,9 @@ allprojects { repositories { google() jcenter() + flatDir { + dirs 'libs' + } } } diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/gradle.properties b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/gradle.properties index 42616f98de..e9e1642ecc 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/gradle.properties +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/gradle.properties @@ -40,3 +40,6 @@ RELEASE_STORE_FILE= RELEASE_STORE_PASSWORD= RELEASE_KEY_ALIAS= RELEASE_KEY_PASSWORD= + +#facebook sdk +FACEBOOK_APP_ID= \ No newline at end of file diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index fe84b1da44..a88a4b6def 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -674,7 +674,10 @@ "$(SRCROOT)/../../cocos2d-x/external/ios/libs", "$(SRCROOT)/ios/anysdk", ); - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "$(inherited)", + ); SDKROOT = iphoneos; STRIP_PNG_TEXT = NO; TARGETED_DEVICE_FAMILY = "1,2"; @@ -707,7 +710,10 @@ "$(SRCROOT)/../../cocos2d-x/external/ios/libs", "$(SRCROOT)/ios/anysdk", ); - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "$(inherited)", + ); SDKROOT = iphoneos; STRIP_PNG_TEXT = NO; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle index c819017b02..3fc0bf929f 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle @@ -119,7 +119,7 @@ android.applicationVariants.all { variant -> } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: 'libs', include: ['*.jar','*.aar']) implementation fileTree(dir: "${COCOS_X_ROOT}/cocos/platform/android/java/libs", include: ['*.jar']) implementation project(':libcocos2dx') } diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/build.gradle b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/build.gradle index 2b56747de5..4ef4803d61 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/build.gradle +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/build.gradle @@ -19,6 +19,9 @@ allprojects { repositories { google() jcenter() + flatDir { + dirs 'libs' + } } } diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/gradle.properties b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/gradle.properties index 42616f98de..e9e1642ecc 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/gradle.properties +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/gradle.properties @@ -40,3 +40,6 @@ RELEASE_STORE_FILE= RELEASE_STORE_PASSWORD= RELEASE_KEY_ALIAS= RELEASE_KEY_PASSWORD= + +#facebook sdk +FACEBOOK_APP_ID= \ No newline at end of file diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index ca2066435a..cbfadde4b7 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -657,7 +657,10 @@ "/Applications/CocosCreator.app/Contents/Resources/cocos2d-x/external/ios/libs", "$(SRCROOT)/ios/anysdk", ); - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "$(inherited)", + ); SDKROOT = iphoneos; STRIP_PNG_TEXT = NO; TARGETED_DEVICE_FAMILY = "1,2"; @@ -690,7 +693,10 @@ "/Applications/CocosCreator.app/Contents/Resources/cocos2d-x/external/ios/libs", "$(SRCROOT)/ios/anysdk", ); - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "$(inherited)", + ); SDKROOT = iphoneos; STRIP_PNG_TEXT = NO; TARGETED_DEVICE_FAMILY = "1,2"; From f92d9f196dcc36fd0bb8fce4560411d601019039 Mon Sep 17 00:00:00 2001 From: owen <1053210246@qq.com> Date: Mon, 8 Apr 2019 11:51:44 +0800 Subject: [PATCH 3/6] modify SkeletonDataMgr license (#1710) --- .../spine-creator-support/SkeletonDataMgr.cpp | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp index a635c0c983..a6e3f4381e 100644 --- a/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp +++ b/native/cocos/editor-support/spine-creator-support/SkeletonDataMgr.cpp @@ -1,26 +1,32 @@ -/**************************************************************************** - Copyright (c) 2019 Xiamen Yaji Software Co., Ltd. - - 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. - ****************************************************************************/ +/****************************************************************************** + * Spine Runtimes Software License v2.5 + * + * Copyright (c) 2013-2016, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable, and + * non-transferable license to use, install, execute, and perform the Spine + * Runtimes software and derivative works solely for personal or internal + * use. Without the written permission of Esoteric Software (see Section 2 of + * the Spine Software License Agreement), you may not (a) modify, translate, + * adapt, or develop new applications using the Spine Runtimes or otherwise + * create derivative works or improvements of the Spine Runtimes or (b) remove, + * delete, alter, or obscure any trademarks or any copyright, trademark, patent, + * or other intellectual property or proprietary rights notices on or in the + * Software, including any copy thereof. Redistributions in binary or source + * form must include this license and terms. + * + * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF + * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ #include "SkeletonDataMgr.h" #include From d124f167bf5c0799edb884ae03a0ca27057838dc Mon Sep 17 00:00:00 2001 From: owen <1053210246@qq.com> Date: Mon, 8 Apr 2019 15:30:57 +0800 Subject: [PATCH 4/6] Fix if spine has not loaded normaly, then will trigger crash (#1711) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix if spine has not loaded normaly,then will trigger destructor,so state may empty * fix if spine has not loaded normaly,then will trigger destructor,so state may empty --- .../editor-support/spine-creator-support/SpineAnimation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/cocos/editor-support/spine-creator-support/SpineAnimation.cpp b/native/cocos/editor-support/spine-creator-support/SpineAnimation.cpp index 783f1f4105..6b5a61564f 100644 --- a/native/cocos/editor-support/spine-creator-support/SpineAnimation.cpp +++ b/native/cocos/editor-support/spine-creator-support/SpineAnimation.cpp @@ -161,7 +161,6 @@ SpineAnimation::SpineAnimation (const std::string& skeletonDataFile, const std:: SpineAnimation::~SpineAnimation () { - clearTracks(); _startListener = nullptr; _interruptListener = nullptr; _endListener = nullptr; @@ -171,6 +170,7 @@ SpineAnimation::~SpineAnimation () if (_state) { + clearTracks(); if (_ownsAnimationStateData) spAnimationStateData_dispose(_state->data); spAnimationState_dispose(_state); } From 6b1942922866879498141344e3fca1fe68aba198 Mon Sep 17 00:00:00 2001 From: santy-wang Date: Mon, 8 Apr 2019 16:21:10 +0800 Subject: [PATCH 5/6] fix loading subpackages's file failed(#1285) --- .../runtime-src/proj.android-studio/app/build.gradle | 5 +++++ .../runtime-src/proj.android-studio/app/build.gradle | 5 +++++ .../proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj | 4 ++++ .../frameworks/runtime-src/proj.win32/build-cfg.json | 4 ++++ .../runtime-src/proj.android-studio/app/build.gradle | 5 +++++ .../proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj | 4 ++++ .../frameworks/runtime-src/proj.win32/build-cfg.json | 4 ++++ 7 files changed, 31 insertions(+) diff --git a/native/templates/js-template-android-instant/frameworks/runtime-src/proj.android-studio/app/build.gradle b/native/templates/js-template-android-instant/frameworks/runtime-src/proj.android-studio/app/build.gradle index f3e14e5a07..c0283acac4 100755 --- a/native/templates/js-template-android-instant/frameworks/runtime-src/proj.android-studio/app/build.gradle +++ b/native/templates/js-template-android-instant/frameworks/runtime-src/proj.android-studio/app/build.gradle @@ -109,6 +109,11 @@ android.applicationVariants.all { variant -> into "${outputDir}/res" } + copy { + from "${sourceDir}/subpackages" + into "${outputDir}/subpackages" + } + copy { from "${sourceDir}/src" into "${outputDir}/src" diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle index cbb8f0b115..4d59633bf5 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/build.gradle @@ -109,6 +109,11 @@ android.applicationVariants.all { variant -> into "${outputDir}/res" } + copy { + from "${sourceDir}/subpackages" + into "${outputDir}/subpackages" + } + copy { from "${sourceDir}/src" into "${outputDir}/src" diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index 9c8226fd22..a9996cbd30 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 1AFFCD851F7A5DCF00628F2C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1AFFCD841F7A5DCD00628F2C /* Images.xcassets */; }; 1AFFCD871F7A5DCF00628F2C /* LaunchScreenBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFFCD831F7A5DCD00628F2C /* LaunchScreenBackground.png */; }; 22CC756521BA528000FBF2F7 /* SDKWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 22CC756121BA527F00FBF2F7 /* SDKWrapper.m */; }; + 288D4373225B43BE0075FBAB /* subpackages in Resources */ = {isa = PBXBuildFile; fileRef = 288D4372225B43BE0075FBAB /* subpackages */; }; 294D7D7C1D0D667B002CE7B7 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294D7D7B1D0D667B002CE7B7 /* CoreText.framework */; }; 4033CDC020E493CF00DAA37B /* jsb-adapter in Resources */ = {isa = PBXBuildFile; fileRef = 4033CDBF20E493CF00DAA37B /* jsb-adapter */; }; 4033CDC120E493CF00DAA37B /* jsb-adapter in Resources */ = {isa = PBXBuildFile; fileRef = 4033CDBF20E493CF00DAA37B /* jsb-adapter */; }; @@ -130,6 +131,7 @@ 22CC756121BA527F00FBF2F7 /* SDKWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDKWrapper.m; path = ios/SDKWrapper.m; sourceTree = ""; }; 22CC756221BA527F00FBF2F7 /* SDKWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDKWrapper.h; path = ios/SDKWrapper.h; sourceTree = ""; }; 22CC756421BA527F00FBF2F7 /* SDKDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDKDelegate.h; sourceTree = ""; }; + 288D4372225B43BE0075FBAB /* subpackages */ = {isa = PBXFileReference; lastKnownFileType = folder; name = subpackages; path = ../../../subpackages; sourceTree = ""; }; 294D7D7B1D0D667B002CE7B7 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/CoreText.framework; sourceTree = DEVELOPER_DIR; }; 4033CDBF20E493CF00DAA37B /* jsb-adapter */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "jsb-adapter"; path = "../../../jsb-adapter"; sourceTree = ""; }; 40CEC425212BDAC1004BCE66 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -291,6 +293,7 @@ A92275321517C094001B78AA = { isa = PBXGroup; children = ( + 288D4372225B43BE0075FBAB /* subpackages */, 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */, D4545214156E28EF00887EB5 /* Classes */, A92275401517C094001B78AA /* Frameworks */, @@ -495,6 +498,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 288D4373225B43BE0075FBAB /* subpackages in Resources */, 4033CDC020E493CF00DAA37B /* jsb-adapter in Resources */, 1AFFCD871F7A5DCF00628F2C /* LaunchScreenBackground.png in Resources */, 1AE159EC18C9DF3600FCA372 /* project.json in Resources */, diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.win32/build-cfg.json b/native/templates/js-template-default/frameworks/runtime-src/proj.win32/build-cfg.json index 1ffaf79488..d854c66e89 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.win32/build-cfg.json +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.win32/build-cfg.json @@ -8,6 +8,10 @@ "from": "../../../res", "to": "res" }, + { + "from": "../../../subpackages", + "to": "subpackages" + }, { "from": "../../../main.js", "to": "" diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle index 7c2f6a379b..73801544ba 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/build.gradle @@ -109,6 +109,11 @@ android.applicationVariants.all { variant -> into "${outputDir}/res" } + copy { + from "${sourceDir}/subpackages" + into "${outputDir}/subpackages" + } + copy { from "${sourceDir}/src" into "${outputDir}/src" diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index 1e21119822..09938f6fac 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 1AFFCD7E1F7A5D5400628F2C /* LaunchScreenBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFFCD7B1F7A5D4F00628F2C /* LaunchScreenBackground.png */; }; 1AFFCD7F1F7A5D5400628F2C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1ABC56911F7A005D00826282 /* Images.xcassets */; }; 22CC757121BA5B5C00FBF2F7 /* SDKWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 22CC756D21BA5B5C00FBF2F7 /* SDKWrapper.m */; }; + 28A34C10225B462E00926306 /* subpackages in Resources */ = {isa = PBXBuildFile; fileRef = 28A34C0F225B462E00926306 /* subpackages */; }; 294D7D801D0D668F002CE7B7 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294D7D7F1D0D668F002CE7B7 /* CoreText.framework */; }; 4011F9CF212BD6750091CC5B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4011F9D1212BD6750091CC5B /* LaunchScreen.storyboard */; }; 4011F9D5212BD7050091CC5B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4011F9D7212BD7050091CC5B /* Localizable.strings */; }; @@ -125,6 +126,7 @@ 22CC756D21BA5B5C00FBF2F7 /* SDKWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDKWrapper.m; path = ios/SDKWrapper.m; sourceTree = ""; }; 22CC756F21BA5B5C00FBF2F7 /* SDKDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDKDelegate.h; sourceTree = ""; }; 22CC757021BA5B5C00FBF2F7 /* SDKWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDKWrapper.h; path = ios/SDKWrapper.h; sourceTree = ""; }; + 28A34C0F225B462E00926306 /* subpackages */ = {isa = PBXFileReference; lastKnownFileType = folder; name = subpackages; path = ../../../subpackages; sourceTree = ""; }; 294D7D7F1D0D668F002CE7B7 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/CoreText.framework; sourceTree = DEVELOPER_DIR; }; 4011F9D2212BD6810091CC5B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 4011F9D8212BD7150091CC5B /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; @@ -283,6 +285,7 @@ A92275321517C094001B78AA = { isa = PBXGroup; children = ( + 28A34C0F225B462E00926306 /* subpackages */, 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */, D4545214156E28EF00887EB5 /* Classes */, A92275401517C094001B78AA /* Frameworks */, @@ -485,6 +488,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 28A34C10225B462E00926306 /* subpackages in Resources */, 4033CDBC20E4935100DAA37B /* jsb-adapter in Resources */, 1AFFCD7F1F7A5D5400628F2C /* Images.xcassets in Resources */, 1AFFCD7E1F7A5D5400628F2C /* LaunchScreenBackground.png in Resources */, diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.win32/build-cfg.json b/native/templates/js-template-link/frameworks/runtime-src/proj.win32/build-cfg.json index 1ffaf79488..d854c66e89 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.win32/build-cfg.json +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.win32/build-cfg.json @@ -8,6 +8,10 @@ "from": "../../../res", "to": "res" }, + { + "from": "../../../subpackages", + "to": "subpackages" + }, { "from": "../../../main.js", "to": "" From 49373f1b6a25c01fd0610397f0927d108927acd3 Mon Sep 17 00:00:00 2001 From: knox Date: Tue, 9 Apr 2019 18:05:27 +0800 Subject: [PATCH 6/6] alBufferData instead of alBufferDataStatic for small audio file on Apple --- native/cocos/audio/apple/AudioCache.mm | 91 +++++++++----------------- 1 file changed, 30 insertions(+), 61 deletions(-) diff --git a/native/cocos/audio/apple/AudioCache.mm b/native/cocos/audio/apple/AudioCache.mm index 49a88daf85..883b4b91cc 100644 --- a/native/cocos/audio/apple/AudioCache.mm +++ b/native/cocos/audio/apple/AudioCache.mm @@ -51,22 +51,6 @@ unsigned int __idIndex = 0; #define INVALID_AL_BUFFER_ID 0xFFFFFFFF #define PCMDATA_CACHEMAXSIZE 1048576 -typedef ALvoid AL_APIENTRY (*alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq); -static ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* data, ALsizei size, ALsizei freq) -{ - static alBufferDataStaticProcPtr proc = nullptr; - - if (proc == nullptr) { - proc = (alBufferDataStaticProcPtr) alcGetProcAddress(nullptr, (const ALCchar*) "alBufferDataStatic"); - } - - if (proc){ - proc(bid, format, data, size, freq); - } - - return; -} - @interface NSTimerWrapper : NSObject { std::function _timeoutCallback; @@ -104,11 +88,6 @@ static ALvoid alBufferDataStaticProc(const ALint bid, ALenum format, ALvoid* da @end -static void setTimeout(double seconds, const std::function& cb) -{ - [[[NSTimerWrapper alloc] initWithTimeInterval:seconds callback:cb] autorelease]; -} - using namespace cocos2d; AudioCache::AudioCache() @@ -149,35 +128,19 @@ AudioCache::~AudioCache() } //wait for the 'readDataTask' task to exit _readDataTaskMutex.lock(); - _readDataTaskMutex.unlock(); - if (_pcmData) + if (_state == State::READY) { - if (_state == State::READY) + if (_alBufferId != INVALID_AL_BUFFER_ID && alIsBuffer(_alBufferId)) { - if (_alBufferId != INVALID_AL_BUFFER_ID && alIsBuffer(_alBufferId)) - { - ALOGV("~AudioCache(id=%u), delete buffer: %u", _id, _alBufferId); - alDeleteBuffers(1, &_alBufferId); - _alBufferId = INVALID_AL_BUFFER_ID; - } + ALOGV("~AudioCache(id=%u), delete buffer: %u", _id, _alBufferId); + alDeleteBuffers(1, &_alBufferId); + _alBufferId = INVALID_AL_BUFFER_ID; } - else - { - ALOGW("AudioCache (%p), id=%u, buffer isn't ready, state=%d", this, _id, _state); - } - - // fixed #17494: CrashIfClientProvidedBogusAudioBufferList - // We're using 'alBufferDataStaticProc' for speeding up - // the performance of playing audio without preload, but we need to manage the memory by ourself carefully. - // It's probably that '_pcmData' is freed before OpenAL finishes the audio render task, - // then 'CrashIfClientProvidedBogusAudioBufferList' may be triggered. - // 'cpp-tests/NewAudioEngineTest/AudioSwitchStateTest' can reproduce this issue without the following fix. - // The workaround is delaying 200ms to free pcm data. - char* data = _pcmData; - setTimeout(0.2, [data](){ - free(data); - }); + } + else + { + ALOGW("AudioCache (%p), id=%u, buffer isn't ready, state=%d", this, _id, _state); } if (_queBufferFrames > 0) @@ -188,6 +151,7 @@ AudioCache::~AudioCache() } } ALOGVV("~AudioCache() %p, id=%u, end", this, _id); + _readDataTaskMutex.unlock(); } void AudioCache::readDataTask(unsigned int selfId) @@ -260,24 +224,16 @@ void AudioCache::readDataTask(unsigned int selfId) _pcmData = (char*)malloc(dataSize); memset(_pcmData, 0x00, dataSize); + ALOGV(" id=%u _pcmData alloc: %p", selfId, _pcmData); if (adjustFrames > 0) { memcpy(_pcmData + (dataSize - adjustFrameBuf.size()), adjustFrameBuf.data(), adjustFrameBuf.size()); } - alGenBuffers(1, &_alBufferId); - auto alError = alGetError(); - if (alError != AL_NO_ERROR) { - ALOGE("%s: attaching audio to buffer fail: %x", __PRETTY_FUNCTION__, alError); - break; - } - if (*_isDestroyed) break; - alBufferDataStaticProc(_alBufferId, _format, _pcmData, (ALsizei)dataSize, (ALsizei)sampleRate); - framesRead = decoder.readFixedFrames(std::min(framesToReadOnce, remainingFrames), _pcmData + _framesRead * bytesPerFrame); _framesRead += framesRead; remainingFrames -= framesRead; @@ -285,10 +241,6 @@ void AudioCache::readDataTask(unsigned int selfId) if (*_isDestroyed) break; - _state = State::READY; - - invokingPlayCallbacks(); - uint32_t frames = 0; while (!*_isDestroyed && _framesRead < originalTotalFrames) { @@ -308,9 +260,22 @@ void AudioCache::readDataTask(unsigned int selfId) { memset(_pcmData + _framesRead * bytesPerFrame, 0x00, (totalFrames - _framesRead) * bytesPerFrame); } - ALOGV("pcm buffer was loaded successfully, total frames: %u, total read frames: %u, adjust frames: %u, remainingFrames: %u", totalFrames, _framesRead, adjustFrames, remainingFrames); + ALOGV("pcm buffer was loaded successfully, total frames: %u, total read frames: %u, adjust frames: %u, remainingFrames: %u", totalFrames, _framesRead, adjustFrames, remainingFrames); _framesRead += adjustFrames; + + alGenBuffers(1, &_alBufferId); + auto alError = alGetError(); + if (alError != AL_NO_ERROR) { + ALOGE("%s: attaching audio to buffer fail: %x", __PRETTY_FUNCTION__, alError); + break; + } + ALOGV(" id=%u generated alGenBuffers: %u for _pcmData: %p", selfId, _alBufferId, _pcmData); + ALOGV(" id=%u _pcmData alBufferData: %p", selfId, _pcmData); + alBufferData(_alBufferId, _format, _pcmData, (ALsizei)dataSize, (ALsizei)sampleRate); + _state = State::READY; + invokingPlayCallbacks(); + } else { @@ -332,6 +297,10 @@ void AudioCache::readDataTask(unsigned int selfId) } while (false); + if (_pcmData != nullptr){ + CC_SAFE_FREE(_pcmData); + } + decoder.close(); //IDEA: Why to invoke play callback first? Should it be after 'load' callback? @@ -344,7 +313,7 @@ void AudioCache::readDataTask(unsigned int selfId) _state = State::FAILED; if (_alBufferId != INVALID_AL_BUFFER_ID && alIsBuffer(_alBufferId)) { - ALOGV("readDataTask failed, delete buffer: %u", _alBufferId); + ALOGV(" id=%u readDataTask failed, delete buffer: %u", selfId, _alBufferId); alDeleteBuffers(1, &_alBufferId); _alBufferId = INVALID_AL_BUFFER_ID; }