Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决Android使用AudioTrack播放时,因为多线程同步问题导致的AudioTrack没有调用play的问题 #4879

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ijkmedia/ijksdl/android/ijksdl_aout_android_audiotrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ static int aout_thread_n(JNIEnv *env, SDL_Aout *aout)
assert(buffer);

SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);

if (!opaque->abort_request && !opaque->pause_on)
bool isPlaying = false;
if (!opaque->abort_request && !opaque->pause_on){
SDL_Android_AudioTrack_play(env, atrack);
isPlaying = true;
}


while (!opaque->abort_request) {
SDL_LockMutex(opaque->wakeup_mutex);
Expand All @@ -99,8 +102,15 @@ static int aout_thread_n(JNIEnv *env, SDL_Aout *aout)
SDL_Android_AudioTrack_flush(env, atrack);
}
SDL_Android_AudioTrack_play(env, atrack);
isPlaying = true;
}
}

if(!opaque->abort_request && !isPlaying){
isPlaying = true;
SDL_Android_AudioTrack_play(env, atrack);
}

if (opaque->need_flush) {
opaque->need_flush = 0;
SDL_Android_AudioTrack_flush(env, atrack);
Expand Down