mirror of
https://github.com/kichikuou/system3-sdl2.git
synced 2026-10-02 03:47:58 +03:00
Fix MAKO::check_music()
This fixes infinite loop in the opening demo of Only You, waiting for the end of the music.
This commit is contained in:
+33
-11
@@ -123,25 +123,47 @@ void MAKO::stop_music()
|
||||
return;
|
||||
|
||||
JNILocalFrame jni(16);
|
||||
if (!jni.env())
|
||||
return;
|
||||
|
||||
if (current_music < 100 && cd_track[current_music]) {
|
||||
jmethodID mid = jni.GetMethodID("cddaStop", "()V");
|
||||
jni.env()->CallVoidMethod(jni.context(), mid);
|
||||
} else {
|
||||
jmethodID mid = jni.GetMethodID("midiStop", "()V");
|
||||
jni.env()->CallVoidMethod(jni.context(), mid);
|
||||
if (jni.env()) {
|
||||
if (current_music < 100 && cd_track[current_music]) {
|
||||
jmethodID cdda = jni.GetMethodID("cddaStop", "()V");
|
||||
jni.env()->CallVoidMethod(jni.context(), cdda);
|
||||
} else {
|
||||
jmethodID mid = jni.GetMethodID("midiStop", "()V");
|
||||
jni.env()->CallVoidMethod(jni.context(), mid);
|
||||
}
|
||||
}
|
||||
|
||||
if (use_fm)
|
||||
if (fm) {
|
||||
SDL_PauseAudio(1);
|
||||
SDL_LockMutex(fm_mutex);
|
||||
fm = nullptr;
|
||||
SDL_UnlockMutex(fm_mutex);
|
||||
}
|
||||
current_music = 0;
|
||||
}
|
||||
|
||||
bool MAKO::check_music()
|
||||
{
|
||||
return current_music != 0;
|
||||
if (!current_music)
|
||||
return false;
|
||||
if (fm) {
|
||||
int mark, loop;
|
||||
SDL_LockMutex(fm_mutex);
|
||||
fm->get_mark(&mark, &loop);
|
||||
SDL_UnlockMutex(fm_mutex);
|
||||
return !loop;
|
||||
}
|
||||
|
||||
JNILocalFrame jni(16);
|
||||
if (!jni.env())
|
||||
return false;
|
||||
if (current_music < 100 && cd_track[current_music]) {
|
||||
jmethodID cdda = jni.GetMethodID("cddaCurrentPosition", "()I");
|
||||
return jni.env()->CallIntMethod(jni.context(), cdda) != 0;
|
||||
} else {
|
||||
jmethodID mid = jni.GetMethodID("midiCurrentPosition", "()I");
|
||||
return jni.env()->CallIntMethod(jni.context(), mid) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MAKO::get_mark(int* mark, int* loop)
|
||||
|
||||
@@ -70,7 +70,15 @@ void MAKO::stop_music()
|
||||
|
||||
bool MAKO::check_music()
|
||||
{
|
||||
return current_music != 0;
|
||||
if (!current_music)
|
||||
return false;
|
||||
if (fm) {
|
||||
int mark, loop;
|
||||
fm->get_mark(&mark, &loop);
|
||||
return !loop;
|
||||
}
|
||||
|
||||
return EM_ASM_INT_V( return xsystem35.cdPlayer.getPosition(); ) != 0;
|
||||
}
|
||||
|
||||
void MAKO::get_mark(int* mark, int* loop)
|
||||
|
||||
+13
-1
@@ -150,12 +150,24 @@ void MAKO::stop_music()
|
||||
mix_music = NULL;
|
||||
smf.clear();
|
||||
}
|
||||
Mix_HookMusic(NULL, NULL);
|
||||
if (fm) {
|
||||
Mix_HookMusic(NULL, NULL);
|
||||
SDL_LockMutex(fm_mutex);
|
||||
fm = nullptr;
|
||||
SDL_UnlockMutex(fm_mutex);
|
||||
}
|
||||
current_music = 0;
|
||||
}
|
||||
|
||||
bool MAKO::check_music()
|
||||
{
|
||||
if (fm) {
|
||||
int mark, loop;
|
||||
SDL_LockMutex(fm_mutex);
|
||||
fm->get_mark(&mark, &loop);
|
||||
SDL_UnlockMutex(fm_mutex);
|
||||
return !loop;
|
||||
}
|
||||
return Mix_PlayingMusic();
|
||||
}
|
||||
|
||||
|
||||
+13
-1
@@ -353,12 +353,24 @@ void MAKO::stop_music()
|
||||
delete music;
|
||||
music = nullptr;
|
||||
}
|
||||
SDL_PauseAudio(1);
|
||||
if (fm) {
|
||||
SDL_PauseAudio(1);
|
||||
SDL_LockMutex(fm_mutex);
|
||||
fm = nullptr;
|
||||
SDL_UnlockMutex(fm_mutex);
|
||||
}
|
||||
current_music = 0;
|
||||
}
|
||||
|
||||
bool MAKO::check_music()
|
||||
{
|
||||
if (fm) {
|
||||
int mark, loop;
|
||||
SDL_LockMutex(fm_mutex);
|
||||
fm->get_mark(&mark, &loop);
|
||||
SDL_UnlockMutex(fm_mutex);
|
||||
return !loop;
|
||||
}
|
||||
return music && music->is_playing();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user