From: notaz Date: Wed, 4 Jul 2012 16:53:30 +0000 (+0300) Subject: spu: remove some hacks, to be reworked X-Git-Tag: r15~38 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8edb5bc279ba09aa7bc762da51236fd368827b0;p=pcsx_rearmed.git spu: remove some hacks, to be reworked get rid of always-iSpuAsyncWait and iSecureStart hacks. Also SoundGetBytesBuffered is lying, make that lie more obvious and remove some confusing pointless constants. --- diff --git a/plugins/dfsound/alsa.c b/plugins/dfsound/alsa.c index 7e594338..c67943a0 100644 --- a/plugins/dfsound/alsa.c +++ b/plugins/dfsound/alsa.c @@ -135,11 +135,11 @@ unsigned long SoundGetBytesBuffered(void) unsigned long l; if (handle == NULL) // failed to open? - return SOUNDSIZE; + return 1; l = snd_pcm_avail(handle); if (l < 0) return 0; if (l < buffer_size / 2) // can we write in at least the half of fragments? - l = SOUNDSIZE; // -> no? wait + l = 1; // -> no? wait else l = 0; // -> else go on return l; diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 18521ce4..bdf59566 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -35,12 +35,6 @@ // spu defines //////////////////////////////////////////////////////////////////////// -// sound buffer sizes -// 400 ms complete sound buffer -#define SOUNDSIZE 70560 -// 137 ms test buffer... if less than that is buffered, a new upload will happen -#define TESTSIZE 24192 - // num of channels #define MAXCHAN 24 diff --git a/plugins/dfsound/oss.c b/plugins/dfsound/oss.c index b2685fbf..04d74463 100644 --- a/plugins/dfsound/oss.c +++ b/plugins/dfsound/oss.c @@ -129,13 +129,13 @@ unsigned long SoundGetBytesBuffered(void) audio_buf_info info; unsigned long l; - if(oss_audio_fd == -1) return SOUNDSIZE; + if(oss_audio_fd == -1) return 1; if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==-1) l=0; else { if(info.fragments<(info.fragstotal>>1)) // can we write in at least the half of fragments? - l=SOUNDSIZE; // -> no? wait + l=1; // -> no? wait else l=0; // -> else go on } diff --git a/plugins/dfsound/pulseaudio.c b/plugins/dfsound/pulseaudio.c index e5ffb59e..1dadd88a 100644 --- a/plugins/dfsound/pulseaudio.c +++ b/plugins/dfsound/pulseaudio.c @@ -303,7 +303,7 @@ unsigned long SoundGetBytesBuffered (void) int playing = 0; if ((device.mainloop == NULL) || (device.api == NULL) || ( device.context == NULL) || (device.stream == NULL)) - return SOUNDSIZE; + return 1; pa_threaded_mainloop_lock (device.mainloop); free_space = pa_stream_writable_size (device.stream); @@ -315,7 +315,7 @@ unsigned long SoundGetBytesBuffered (void) { // Don't buffer anymore, just play //fprintf (stderr, "Not buffering.\n"); - return SOUNDSIZE; + return 1; } else { diff --git a/plugins/dfsound/sdl.c b/plugins/dfsound/sdl.c index f6777440..f7dc298c 100644 --- a/plugins/dfsound/sdl.c +++ b/plugins/dfsound/sdl.c @@ -106,12 +106,12 @@ void RemoveSound(void) { unsigned long SoundGetBytesBuffered(void) { int size; - if (pSndBuffer == NULL) return SOUNDSIZE; + if (pSndBuffer == NULL) return 1; size = iReadPos - iWritePos; if (size <= 0) size += iBufSize; - if (size < iBufSize / 2) return SOUNDSIZE; + if (size < iBufSize / 2) return 1; return 0; } diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index f5aab9f1..b087cdfd 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -124,7 +124,6 @@ short * pS; int lastch=-1; // last channel processed on spu irq in timer mode static int lastns=0; // last ns pos -static int iSecureStart=0; // secure start counter #define CDDA_BUFFER_SIZE (16384 * sizeof(uint32_t)) // must be power of 2 @@ -682,15 +681,7 @@ static int do_samples(void) // until enuff free place is available/a new channel gets // started - if(dwNewChannel) // new channel should start immedately? - { // (at least one bit 0 ... MAXCHANNEL is set?) - iSecureStart++; // -> set iSecure - if(iSecureStart>5) iSecureStart=0; // (if it is set 5 times - that means on 5 tries a new samples has been started - in a row, we will reset it, to give the sound update a chance) - } - else iSecureStart=0; // 0: no new channel should start - - if(!iSecureStart && // no new start? - (SoundGetBytesBuffered()>TESTSIZE)) // and still enuff data in sound buffer? + if(!dwNewChannel && SoundGetBytesBuffered()) // still enuff data in sound buffer? { return 0; } @@ -872,6 +863,8 @@ static int do_samples(void) void CALLBACK SPUasync(unsigned long cycle) { + if(!bSpuInit) return; // -> no init, no call + if(iSpuAsyncWait) { iSpuAsyncWait++; @@ -879,14 +872,7 @@ void CALLBACK SPUasync(unsigned long cycle) iSpuAsyncWait=0; } - if(!bSpuInit) return; // -> no init, no call - do_samples(); - - // abuse iSpuAsyncWait mechanism to reduce calls to above function - // to make it do larger chunks - // note: doing it less often than once per frame causes skips - iSpuAsyncWait=1; } // SPU UPDATE... new epsxe func