Skip to content

Commit 31d19d6

Browse files
author
xufuji456
committed
Feature: remove audio_player.cpp
1 parent 638ccff commit 31d19d6

7 files changed

Lines changed: 150 additions & 380 deletions

File tree

app/src/main/cpp/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ add_library( # Sets the name of the library.
2525
ffmpeg_cmd.c
2626
ffmpeg/ffprobe.c
2727
ffmpeg/ffmpeg_hw.c
28-
audio_player.cpp
2928
video_player.cpp
3029
ffmpeg_pusher.cpp
3130
video_filter.c

app/src/main/cpp/audio_player.cpp

Lines changed: 0 additions & 280 deletions
This file was deleted.

app/src/main/cpp/audio_player_jni.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@
88

99
#define SLEEP_TIME (16000)
1010

11-
FFAudioPlayer *audioPlayer;
12-
1311
void fftCallback(JNIEnv *env, jobject thiz, jmethodID fft_method, int8_t *data, int size) {
1412
jbyteArray dataArray = env->NewByteArray(size);
1513
env->SetByteArrayRegion(dataArray, 0, size, data);
1614
env->CallVoidMethod(thiz, fft_method, dataArray);
1715
env->DeleteLocalRef(dataArray);
1816
}
1917

20-
AUDIO_PLAYER_FUNC(void, play, jstring path) {
18+
AUDIO_PLAYER_FUNC(long, native_1init) {
19+
auto *audioPlayer = new FFAudioPlayer();
20+
return (long)audioPlayer;
21+
}
22+
23+
AUDIO_PLAYER_FUNC(void, native_1play, long context, jstring path, jstring filter) {
2124
if (path == nullptr)
2225
return;
2326

2427
int result = 0;
2528
const char* native_path = env->GetStringUTFChars(path, JNI_FALSE);
26-
audioPlayer = new FFAudioPlayer();
29+
auto *audioPlayer = (FFAudioPlayer*) context;
2730
// open stream, and init work
2831
audioPlayer->open(native_path);
2932
// init AudioTrack
@@ -73,14 +76,16 @@ AUDIO_PLAYER_FUNC(void, play, jstring path) {
7376
delete audioPlayer;
7477
}
7578

76-
AUDIO_PLAYER_FUNC(void, again, jstring filter_jstr) {
79+
AUDIO_PLAYER_FUNC(void, native_1again, long context, jstring filter_jstr) {
7780
if (!filter_jstr) return;
81+
auto *audioPlayer = (FFAudioPlayer*) context;
7882
audioPlayer->setFilterAgain(true);
7983
const char *desc = env->GetStringUTFChars(filter_jstr, nullptr);
8084
audioPlayer->setFilterDesc(desc);
8185
}
8286

83-
AUDIO_PLAYER_FUNC(void, release) {
87+
AUDIO_PLAYER_FUNC(void, native_1release, long context) {
88+
auto *audioPlayer = (FFAudioPlayer*) context;
8489
audioPlayer->setExit(true);
8590
}
8691

0 commit comments

Comments
 (0)