aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound
diff options
context:
space:
mode:
authornotaz2012-07-04 19:53:30 +0300
committernotaz2012-07-09 02:35:59 +0300
commitf8edb5bc279ba09aa7bc762da51236fd368827b0 (patch)
tree1b33700d53c696ccb8bc2c8362f5df24a63191e5 /plugins/dfsound
parent6d75977b13fede33db381324c610561c6e723a8b (diff)
downloadpcsx_rearmed-f8edb5bc279ba09aa7bc762da51236fd368827b0.tar.gz
pcsx_rearmed-f8edb5bc279ba09aa7bc762da51236fd368827b0.tar.bz2
pcsx_rearmed-f8edb5bc279ba09aa7bc762da51236fd368827b0.zip
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.
Diffstat (limited to 'plugins/dfsound')
-rw-r--r--plugins/dfsound/alsa.c4
-rw-r--r--plugins/dfsound/externals.h6
-rw-r--r--plugins/dfsound/oss.c4
-rw-r--r--plugins/dfsound/pulseaudio.c4
-rw-r--r--plugins/dfsound/sdl.c4
-rw-r--r--plugins/dfsound/spu.c20
6 files changed, 11 insertions, 31 deletions
diff --git a/plugins/dfsound/alsa.c b/plugins/dfsound/alsa.c
index 7e59433..c67943a 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 18521ce..bdf5956 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 b2685fb..04d7446 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 e5ffb59..1dadd88 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 f677744..f7dc298 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 f5aab9f..b087cdf 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