|
|
|
@ -19,6 +19,8 @@ extern "C" { |
|
|
|
|
#include "libavutil/opt.h" |
|
|
|
|
#include "ffmpeg_jni_define.h" |
|
|
|
|
|
|
|
|
|
#include "visualizer/execute_fft.h" |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
@ -357,4 +359,50 @@ AUDIO_PLAYER_FUNC(void, again, jstring filter_jstr) { |
|
|
|
|
|
|
|
|
|
AUDIO_PLAYER_FUNC(void, release) { |
|
|
|
|
filter_release = 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pthread_t input_thread; |
|
|
|
|
filter_sys_t *p_sys; |
|
|
|
|
|
|
|
|
|
static void *input(void *); |
|
|
|
|
|
|
|
|
|
AUDIO_PLAYER_FUNC(void, openFFT) { |
|
|
|
|
pthread_create(&input_thread, nullptr, input, nullptr); |
|
|
|
|
|
|
|
|
|
p_sys = static_cast<filter_sys_t *>(malloc(sizeof(filter_sys_t))); |
|
|
|
|
open_visualizer(p_sys); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void fft_callback(void* arg) { |
|
|
|
|
float* data = (float*) arg; |
|
|
|
|
for (int i = 0; i < 3; ++i) { |
|
|
|
|
LOGE(TAG, "fft data[0]=%f,data[1]=%f,data[2]=%f", data[0], data[1], data[2]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void *input(void *) { |
|
|
|
|
int64_t tick = 0; |
|
|
|
|
size_t len = 256; |
|
|
|
|
auto *data = static_cast<uint8_t *>(malloc(len * sizeof(uint8_t))); |
|
|
|
|
auto *block = static_cast<block_t *>(malloc(sizeof(block_t))); |
|
|
|
|
block->i_buffer = len; |
|
|
|
|
block->p_buffer = data; |
|
|
|
|
block->i_nb_samples = len; |
|
|
|
|
block->i_pts = tick; |
|
|
|
|
|
|
|
|
|
block->fft_callback.callback = fft_callback; |
|
|
|
|
|
|
|
|
|
LOGE(TAG, "begin input..."); |
|
|
|
|
for (int i = 0; i < 50; i++) { |
|
|
|
|
for (int j = 0; j < len; j++) { |
|
|
|
|
block->p_buffer[j] = i+j; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
filter_audio(p_sys, block); |
|
|
|
|
tick += 16*1000; |
|
|
|
|
usleep(200 * 1000); |
|
|
|
|
} |
|
|
|
|
LOGE(TAG, "finish input-_-"); |
|
|
|
|
// close_visualizer(p_sys);
|
|
|
|
|
return nullptr; |
|
|
|
|
} |