aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authornotaz2011-10-05 02:11:18 +0300
committernotaz2011-10-08 03:29:24 +0300
commit983a7cfdccceaa612267a1b045110b4f831d1495 (patch)
tree9db370d4f7a553f078d8ab4793324ca220a90bc5 /libpcsxcore
parent4600ba0381ea86bdfdcba8f4f762c89f5c51af5b (diff)
downloadpcsx_rearmed-983a7cfdccceaa612267a1b045110b4f831d1495.tar.gz
pcsx_rearmed-983a7cfdccceaa612267a1b045110b4f831d1495.tar.bz2
pcsx_rearmed-983a7cfdccceaa612267a1b045110b4f831d1495.zip
spu/cdda: sync cdda to spu playback
this will probably make cdrom/vsync timing desync situation worse (those were never in sync anyway) but fix some cdda related sound stuttering. Those magic values are used trying to preserve other SPU plugin compatibility.
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/cdriso.c55
-rw-r--r--libpcsxcore/plugins.h2
2 files changed, 33 insertions, 24 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index c29fd77..aa6e47f 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -164,33 +164,13 @@ static void playthread(void *param)
static void *playthread(void *param)
#endif
{
- long d, t, i, s;
+ long osleep, d, t, i, s;
unsigned char tmp;
+ int ret = 0;
t = GetTickCount();
while (playing) {
- d = t - (long)GetTickCount();
- if (d <= 0) {
- d = 1;
- }
- else if (d > CDDA_FRAMETIME) {
- d = CDDA_FRAMETIME;
- }
-#ifdef _WIN32
- Sleep(d);
-#else
- usleep(d * 1000);
-#endif
- // HACK: stop feeding data while emu is paused
- extern int stop;
- if (stop) {
- usleep(100000);
- continue;
- }
-
- t = GetTickCount() + CDDA_FRAMETIME;
-
s = 0;
for (i = 0; i < sizeof(sndbuffer) / CD_FRAMESIZE_RAW; i++) {
d = cdimg_read_func(cddaHandle, sndbuffer + s, cdda_cur_sector, 0);
@@ -223,8 +203,37 @@ static void *playthread(void *param)
}
}
- SPU_playCDDAchannel((short *)sndbuffer, s);
+ do {
+ ret = SPU_playCDDAchannel((short *)sndbuffer, s);
+ if (ret == 0x7761)
+ usleep(6 * 1000);
+ } while (ret == 0x7761 && playing); // rearmed_wait
}
+
+ if (ret != 0x676f) { // !rearmed_go
+ // do approx sleep
+ long now;
+
+ // HACK: stop feeding data while emu is paused
+ extern int stop;
+ while (stop && playing)
+ usleep(10000);
+
+ now = GetTickCount();
+ osleep = t - now;
+ if (osleep <= 0) {
+ osleep = 1;
+ t = now;
+ }
+ else if (osleep > CDDA_FRAMETIME) {
+ osleep = CDDA_FRAMETIME;
+ t = now;
+ }
+
+ usleep(osleep * 1000);
+ t += CDDA_FRAMETIME;
+ }
+
}
#ifdef _WIN32
diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h
index 42028ea..9125391 100644
--- a/libpcsxcore/plugins.h
+++ b/libpcsxcore/plugins.h
@@ -206,7 +206,7 @@ typedef struct {
} SPUFreeze_t;
typedef long (CALLBACK* SPUfreeze)(uint32_t, SPUFreeze_t *);
typedef void (CALLBACK* SPUasync)(uint32_t);
-typedef void (CALLBACK* SPUplayCDDAchannel)(short *, int);
+typedef int (CALLBACK* SPUplayCDDAchannel)(short *, int);
// SPU function pointers
extern SPUconfigure SPU_configure;