mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-05 13:18:08 +03:00
Prevent busy loop by CDDA play time sync
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user