change int to short

dev
xufulong 3 years ago
parent 318ba98c2b
commit ed5abd7236
  1. 7
      app/src/main/cpp/audio_player.cpp
  2. 1
      app/src/main/cpp/visualizer/execute_fft.c
  3. 4
      app/src/main/java/com/frank/ffmpeg/AudioPlayer.java

@ -283,7 +283,7 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) {
// goto end; // goto end;
} }
jmethodID fft_method = env->GetMethodID(player_class, "fftCallbackFromJNI", "([I)V"); jmethodID fft_method = env->GetMethodID(player_class, "fftCallbackFromJNI", "([S)V");
filter_sys_t *fft_filter = static_cast<filter_sys_t *>(malloc(sizeof(filter_sys_t))); filter_sys_t *fft_filter = static_cast<filter_sys_t *>(malloc(sizeof(filter_sys_t)));
open_visualizer(fft_filter); open_visualizer(fft_filter);
@ -387,7 +387,8 @@ AUDIO_PLAYER_FUNC(void, release) {
} }
void fft_callback(JNIEnv *jniEnv, jobject thiz, jmethodID fft_method, int16_t * arg) { void fft_callback(JNIEnv *jniEnv, jobject thiz, jmethodID fft_method, int16_t * arg) {
jintArray dataArray = jniEnv->NewIntArray(256); LOGE(TAG, "arg[100]=%d,arg[101]=%d,arg[102]=%d", arg[100], arg[101], arg[102]);
jniEnv->SetIntArrayRegion(dataArray, 0, 256, (int*)arg); jshortArray dataArray = jniEnv->NewShortArray(256);
jniEnv->SetShortArrayRegion(dataArray, 0, 256, arg);
jniEnv->CallVoidMethod(thiz, fft_method, dataArray); jniEnv->CallVoidMethod(thiz, fft_method, dataArray);
} }

@ -304,6 +304,7 @@ void fft_once(void *p_data, block_t *block, int16_t *output)
} }
memcpy(output, p_dest, FFT_BUFFER_SIZE); memcpy(output, p_dest, FFT_BUFFER_SIZE);
LOGE("out[100]=%d,out[101]=%d,out[102]=%d", output[100], output[101], output[102]);
release: release:
window_close(&wind_ctx); window_close(&wind_ctx);

@ -63,14 +63,14 @@ public class AudioPlayer {
private OnFFTCallback onFFTCallback; private OnFFTCallback onFFTCallback;
public interface OnFFTCallback { public interface OnFFTCallback {
void onFFT(int[] data); void onFFT(short[] data);
} }
public void setOnFftCallback(OnFFTCallback onFFTCallback) { public void setOnFftCallback(OnFFTCallback onFFTCallback) {
this.onFFTCallback = onFFTCallback; this.onFFTCallback = onFFTCallback;
} }
public void fftCallbackFromJNI(int[] data) { public void fftCallbackFromJNI(short[] data) {
if (data != null && onFFTCallback != null) { if (data != null && onFFTCallback != null) {
onFFTCallback.onFFT(data); onFFTCallback.onFFT(data);
} }

Loading…
Cancel
Save