Prevent busy loop by CDDA play time sync

This commit is contained in:
kichikuou
2017-04-23 19:35:03 +09:00
parent a227e560a1
commit e53e2b40c1
2 changed files with 9 additions and 0 deletions
+3
View File
@@ -23,6 +23,8 @@
#include "portab.h"
#include "cdrom.h"
int cdrom_getpos_count;
static int cdrom_init(char *);
static int cdrom_exit();
static int cdrom_start(int, boolean);
@@ -60,6 +62,7 @@ int cdrom_stop() {
}
int cdrom_getPlayingInfo(cd_time *info) {
cdrom_getpos_count++;
int t = EM_ASM_INT_V( return xsystem35.cdPlayer.getPosition(); );
info->t = t & 0xff;
FRAMES_TO_MSF(t >> 8, &info->m, &info->s, &info->f);
+6
View File
@@ -185,10 +185,14 @@ static int checkMessage() {
#ifdef __EMSCRIPTEN__
extern int cdrom_getpos_count;
static void mainloop() {
if (nact->is_quit)
emscripten_cancel_main_loop();
cdrom_getpos_count = 0;
for (int cnt = 0; cnt < 10000; cnt++) {
nact->input_state = InputNotChecked;
@@ -201,6 +205,8 @@ static void mainloop() {
if (nact->input_state == InputCheckMissed)
break;
if (cdrom_getpos_count >= 2)
break;
}
if (!nact->is_message_locked && nact->input_state == InputNotChecked)
sys_getInputInfo();