get rid of always-iSpuAsyncWait and iSecureStart hacks.
Also SoundGetBytesBuffered is lying, make that lie more obvious
and remove some confusing pointless constants.
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;
// spu defines\r
////////////////////////////////////////////////////////////////////////\r
\r
-// sound buffer sizes\r
-// 400 ms complete sound buffer\r
-#define SOUNDSIZE 70560\r
-// 137 ms test buffer... if less than that is buffered, a new upload will happen\r
-#define TESTSIZE 24192\r
-\r
// num of channels\r
#define MAXCHAN 24\r
\r
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
}
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);
{
// Don't buffer anymore, just play
//fprintf (stderr, "Not buffering.\n");
- return SOUNDSIZE;
+ return 1;
}
else
{
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;
}
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
// 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;
}
void CALLBACK SPUasync(unsigned long cycle)
{
+ if(!bSpuInit) return; // -> no init, no call
+
if(iSpuAsyncWait)
{
iSpuAsyncWait++;
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