Fatal signal 7 (SIGBUS) at 0x3f8921d5 (code=1), thread 31131 (ohamsaa.ndktest)

437 views Asked by At

I am trying to record audio using ndk and converting audio into frequency format. I refered this link to record audio.( https://audioprograming.wordpress.com/2012/03/03/android-audio-streaming-with-opensl-es-and-the-ndk/ ).I can record audio but application crashing.i got this Fatal signal 7 (SIGBUS) at 0x3f8921d5 (code=1), thread 31131 (ndktest) error.Please help me and Thank you.

Android.mk

LOCAL_PATH :=$(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := ndktest
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS := -O3
LOCAL_CPPFLAGS :=$(LOCAL_CFLAGS)
###

LOCAL_SRC_FILES := java_interface_wrap.cpp opensl_example.c opensl_io.c 
RealDoubleFFT.c
LOCAL_LDLIBS := -llog -lOpenSLES
include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_STL := gnustl_static
APP_CPPFLAGS += -fexceptions -frtti
APP_ABI := armeabi-v7a

Recorder Code

double *bufferdDouble;
double *re;
double *im;
double *magnitude;
int fftlen = 512;

void start_process(JNIEnv *env) {

    short inbuffer[VECSAMPS_MONO]
    RealDoubleFFT(env, fftlen);//fft calculation
    bufferdDouble = (double*) malloc(512 * sizeof(double));  
    re = (double*) malloc( 512 * sizeof(double));
    im = (double*) malloc( 512 * sizeof(double));
    magnitude = (double*) malloc( 256 * sizeof(double));
    p = android_OpenAudioDevice(SR, 1, 2, BUFFERFRAMES);//
   if (p == NULL) {
        LOGE("%s", "P is null");
        return;
    }
    on = 1;      
   while (on) {

      samps = android_AudioIn(p, inbuffer, VECSAMPS_MONO);
      if (samps > 0) {
          audio_conversion(inbuffer);
      }

    }  
    android_CloseAudioDevice(p);

}

void audio_conversion(short bufferByte[]) {

    for (int i = 0; i < 256; i++) {
        bufferdDouble[i] = (double) bufferByte[i] / 32768.0; 
    }
   ft(jenv, bufferdDouble);//fft calculation
   for (int i = 0; i < (fftlen / 2) - 1; i++) {
        re[i] = bufferdDouble[i * 2];
        im[i] = bufferdDouble[(i * 2) + 1];
        magnitude[i] = sqrt((re[i] * re[i]) + (im[i] * im[i]));
   }
   double max_magnitude = -1;
   int max_index = -1;
   for (int i = 0; i < (fftlen / 2) - 1; i++) {
       if (magnitude[i] > max_magnitude) {
            max_magnitude = magnitude[i];
            max_index = i;
       }
    }
  int freq = max_index * 44100 / fftlen;
  LOGE("freq = %d", freq);  

 memset(bufferdDouble, 0, 512 * sizeof(double));
 memset(re, 0,512 * sizeof(double));
 memset(im, 0,512 * sizeof(double));
 memset(magnitude, 0, 256 * sizeof(double));
}
0

There are 0 answers