X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfsound%2Fspu.c;h=7d3f1a0efc2a479d48a41fafb0ae76424ada29eb;hb=2b30c1291db9d9801d51cf85f71f40fe54958898;hp=b89ab1af8c120ba4a25a379a5da9a94f110e8bef;hpb=ee9afdbd4d9e0aee75dd9e17878c76f1c7236d04;p=pcsx_rearmed.git diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index b89ab1af..7d3f1a0e 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -692,7 +692,7 @@ static void noinline do_decode_bufs(int which, int start, int count) static int do_samples(int forced_updates) { int volmult = iVolume; - int ns,ns_from,ns_to; + int ns,ns_from,ns_to,ns_len; int ch,d,silentch; int bIRQReturn=0; @@ -707,8 +707,6 @@ static int do_samples(int forced_updates) while(!bIRQReturn) { - cycles_since_update = 0; - ns_from=0; ns_to=NSSIZE; ch=0; @@ -742,21 +740,22 @@ static int do_samples(int forced_updates) lastch=ch; lastns=ns_to=d; } + ns_len = ns_to - ns_from; MixADSR(ch, ns_from, ns_to); if(ch==1 || ch==3) { - do_decode_bufs(ch/2, ns_from, ns_to-ns_from); + do_decode_bufs(ch/2, ns_from, ns_len); decode_dirty_ch |= 1<busy()) break; } + + if(cycles_since_update <= -PSXCLK/60 / 4) + break; } + // this may cause desync, but help audio when the emu can't keep up.. + if(cycles_since_update < 0) + cycles_since_update = 0; + return 0; } @@ -900,7 +908,6 @@ static int do_samples(int forced_updates) void CALLBACK SPUasync(unsigned long cycle) { - static int old_ctrl; int forced_updates = 0; int do_update = 0; @@ -915,17 +922,9 @@ void CALLBACK SPUasync(unsigned long cycle) had_dma = 0; } - if((spuCtrl&CTRL_IRQ) && (((spuCtrl^old_ctrl)&CTRL_IRQ) // irq was enabled - || cycles_since_update > PSXCLK/60 / 4)) { - do_update = 1; - forced_updates = cycles_since_update / (PSXCLK/44100) / NSSIZE; - } - // with no irqs, once per frame should be fine (using a bit more because of BIAS) - else if(cycles_since_update > PSXCLK/60 * 5/4) + if(cycles_since_update > PSXCLK/60 * 5/4) do_update = 1; - old_ctrl = spuCtrl; - if(do_update) do_samples(forced_updates); } @@ -1122,6 +1121,10 @@ void CALLBACK SPUregisterCDDAVolume(void (CALLBACK *CDDAVcallback)(unsigned shor cddavCallback = CDDAVcallback; } +void CALLBACK SPUregisterScheduleCb(void (CALLBACK *callback)(unsigned int)) +{ +} + // COMMON PLUGIN INFO FUNCS /* char * CALLBACK PSEgetLibName(void)