speex support in android

半城伤御伤魂 提交于 2019-12-02 17:42:12

speex_bits_reset do following in its body:

bits->nbBits=0;

and speex_bits_nbytes returns ((bits->nbBits+7)>>3); So if you call speex_bits_nbytes right after speex_bits_reset, you always receive 0. So you must call speex_bits_read_from before array allocation:

/*Flush all the bits in the struct so we can decode a new frame*/
speex_bits_reset(&decod_bits);

/*Read bits in decod_bits struct from java array*/
speex_bits_read_from(&decod_bits,(char *) inputArrayElements, nbBytes);

/*Copy the bits to an array of char that can be written*/
nbBytes = speex_bits_nbytes(&decod_bits);
ret = (jshortArray)((*env)->NewShortArray(env, nbBytes));
jshort * arrayElements = (*env)->GetShortArrayElements(env, ret, 0);

/*Decode the frame*/
speex_decode_int(decod_state, &decod_bits, arrayElements);

(*env)->ReleaseCharArrayElements(env, inputCharData, inputArrayElements,
        JNI_ABORT);
(*env)->ReleaseShortArrayElements(env, ret, arrayElements, 0);
return ret;

Don't know about the code specifically, but there are a few open-source Android applications out there which include speex support, which you could use as a reference:

Fatal signal 11 (SIGSEGV) at 0x00000018 (code=1) Error comes,when u have not reinitialize decoder

decod_state = speex_decoder_init(&speex_wb_mode);

and try to use decode frame data,..

don't forget to call your initDecode() method from java first and then decode frame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!