Back ported SDL sound bug fixes from QT to GTK GUI.
This commit is contained in:
parent
33c5b328b2
commit
989d39c26e
|
@ -49,16 +49,21 @@ fillaudio(void *udata,
|
||||||
uint8 *stream,
|
uint8 *stream,
|
||||||
int len)
|
int len)
|
||||||
{
|
{
|
||||||
|
static int16_t sample = 0;
|
||||||
int16 *tmps = (int16*)stream;
|
int16 *tmps = (int16*)stream;
|
||||||
len >>= 1;
|
len >>= 1;
|
||||||
while(len) {
|
while (len)
|
||||||
int16 sample = 0;
|
{
|
||||||
if(s_BufferIn) {
|
if (s_BufferIn)
|
||||||
|
{
|
||||||
sample = s_Buffer[s_BufferRead];
|
sample = s_Buffer[s_BufferRead];
|
||||||
s_BufferRead = (s_BufferRead + 1) % s_BufferSize;
|
s_BufferRead = (s_BufferRead + 1) % s_BufferSize;
|
||||||
s_BufferIn--;
|
s_BufferIn--;
|
||||||
} else {
|
} else {
|
||||||
sample = 0;
|
// Retain last known sample value, helps avoid clicking
|
||||||
|
// noise when sound system is starved of audio data.
|
||||||
|
//sample = 0;
|
||||||
|
//bufStarveDetected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*tmps = sample;
|
*tmps = sample;
|
||||||
|
@ -179,11 +184,20 @@ WriteSound(int32 *buf,
|
||||||
{
|
{
|
||||||
extern int EmulationPaused;
|
extern int EmulationPaused;
|
||||||
if (EmulationPaused == 0)
|
if (EmulationPaused == 0)
|
||||||
|
{
|
||||||
|
int waitCount = 0;
|
||||||
|
|
||||||
while(Count)
|
while(Count)
|
||||||
{
|
{
|
||||||
while(s_BufferIn == s_BufferSize)
|
while(s_BufferIn == s_BufferSize)
|
||||||
{
|
{
|
||||||
SDL_Delay(1);
|
SDL_Delay(1); waitCount++;
|
||||||
|
|
||||||
|
if ( waitCount > 1000 )
|
||||||
|
{
|
||||||
|
printf("Error: Sound sink is not draining... Breaking out of audio loop to prevent lockup.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s_Buffer[s_BufferWrite] = *buf;
|
s_Buffer[s_BufferWrite] = *buf;
|
||||||
|
@ -196,6 +210,7 @@ WriteSound(int32 *buf,
|
||||||
|
|
||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue