Log in or register to post comments

SIGSEGV Error when trying to invoke sound effects in C code

March 25, 2012 - 8:12pm #1

Hi,

So I have a function in my java code as follows that plays a sound:

public void call_arrow_sound() {

sp.play(arrow_noise, 1, 1, 0, 0, 1);
sp.stop(arrow_noise);

}

In my C-code I use the following code to invoke the call_arrow_sound function:

void
call_arrow_sound()
{
jmethodID method = javaEnv2->GetMethodID(javaClass2, "call_arrow_sound", "()V");
javaEnv2->CallVoidMethod(javaObj2, method);
}

.
.
.
if (some_condition) {
call_arrow_sound();
}

So when I start the application, it runs fine and the sound effects work. However, at some point the app crashes and I see the following in the logcat:

03-26 03:09:09.030: INFO/DEBUG(1782): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-26 03:09:09.030: INFO/DEBUG(1782): Build fingerprint: 'asus/WW_epad/TF101:3.2.1/HTK75/WW_epad-8.6.5.18-20111028:user/release-keys'
03-26 03:09:09.030: INFO/DEBUG(1782): pid: 1876, tid: 1934 >>> com.qualcomm.QCARSamples.ImageTargets 03-26 03:09:09.040: INFO/DEBUG(1782): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000028

I've seen this type of errors in other forums but didn't find a solution that work. Has anyone else encountered this?

Thanks.

Re: SIGSEGV Error when trying to invoke sound effects in C code

March 26, 2012 - 9:15pm #2

Make sure that you are using the javaEnv2 variable from the same thread you received it. So if you're storing this in renderFrame you need to use it on the GLThread. If you're storing it in any method called from the main activity you're probably on the main/UI thread.

Also, I don't think you want to stop the sound playback right after calling play. I believe the play method is asynchronous.

- Kim

Log in or register to post comments