Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17098

Android and EasyNDK

$
0
0

@expose wrote:

I'm using cocos2d-x 3.10 and EasyNDKHelper https://github.com/alfonsocejudo/EasyNDK-for-cocos2dx3 My game is using microphone to read volume of speech and use that value to alter CCSprite SpriteFrame mouth of the character.
I'm testing sprite update condition every 0.08 second and if condition is met i'm sending message to cocos like this:

            Cocos2dxGLSurfaceView.getInstance().queueEvent(new Runnable() {
                @Override
                public void run() {
                    int delay = 80; //milliseconds
                    audioCallbackHandler.postDelayed(lipsyncRunnable, delay);
                }
            });

and lipsyncRunnable looks like this:

**        lipsyncRunnable = new Runnable() {
            @Override
            public void run() {
                    float peak = getLipsyncValue();
                            JSONObject message = new JSONObject();
                            try {
                                message.put("type","lipsync");
                                message.put("status",true);
                                message.put("peak",peak);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            AndroidNDKHelper.SendMessageWithParameters("newLipsyncValue", message);
                            audioCallbackHandler.postDelayed(lipsyncRunnable, 80);
                }
                }
            }
        };

Everything works but occasionally(quite often) i get runtime errors:

06-06 14:44:36.491 7711-7758/org.cocos2dx.fun2oonx A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x118 in tid 7758 (GLThread 19612)

with ndk-stack debug info:

tack frame #00 pc 00cca880  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (cocos2d::Sequence::update(float)+956)
Stack frame #01 pc 00cc99e0  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (cocos2d::ActionInterval::step(float)+584)
Stack frame #02 pc 00f65d88  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (cocos2d::ActionManager::update(float)+244)
Stack frame #03 pc 00e0ce04  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (void cocos2d::Scheduler::scheduleUpdate<cocos2d::ActionManager>(cocos2d::ActionManager*, int, bool)::{lambda(float)#1}::operator()(float) const+36)
Stack frame #04 pc 00e0eb78  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (std::_Function_handler<void (float), void cocos2d::Scheduler::scheduleUpdate<cocos2d::ActionManager>(cocos2d::ActionManager*, int, bool)::{lambda(float)#1}>::_M_invoke(std::_Any_data const&, float)+60)
Stack frame #05 pc 00cd5f68  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (std::function<void (float)>::operator()(float) const+88)
Stack frame #06 pc 00e483a8  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (cocos2d::Scheduler::update(float)+196)
Stack frame #07 pc 00e08494  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (cocos2d::Director::drawScene()+160)
Stack frame #08 pc 00e0cb3c  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (cocos2d::DisplayLinkDirector::mainLoop()+136)
Stack frame #09 pc 006fcd6c  /data/app/org.cocos2dx.fun2oonx-2/lib/arm/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender+40)
Stack frame #10 pc 008363f1  /data/dalvik-cache/arm/data@app@org.cocos2dx.fun2oonx-2@base.apk@classes.dex

I also tried to use this.runOnGLThread instead queueEvent but with no luck.

What could be wrong here? My guess is that the CCSprite has not yet updated CCSpriteFrame and the software wants to update it again which is causing some kind of race condition. Is there a way to prevent it?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17098

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>