log mixing underruns
remove potential raced ASSERT
This commit is contained in:
@@ -13,6 +13,8 @@ static int frames_to_buffer;
|
|||||||
static const int num_chunks = 8;
|
static const int num_chunks = 8;
|
||||||
static int chunksize() { return frames_to_buffer / num_chunks; }
|
static int chunksize() { return frames_to_buffer / num_chunks; }
|
||||||
|
|
||||||
|
static int underruns = 0, logged_underruns = 0;
|
||||||
|
|
||||||
RageSound_Generic_Software::sound::sound()
|
RageSound_Generic_Software::sound::sound()
|
||||||
{
|
{
|
||||||
snd = NULL;
|
snd = NULL;
|
||||||
@@ -120,15 +122,14 @@ void RageSound_Generic_Software::Mix( int16_t *buf, int frames, int64_t frameno,
|
|||||||
|
|
||||||
// LOG->Trace( "incr fr rd %i += %i = %i (%i left) (state %i) (%p)",
|
// LOG->Trace( "incr fr rd %i += %i = %i (%i left) (state %i) (%p)",
|
||||||
// OldFramesRead, (int) frames_to_read, (int) s.frames_read, (int) s.frames_buffered(), s.state, s.snd );
|
// OldFramesRead, (int) frames_to_read, (int) s.frames_read, (int) s.frames_buffered(), s.state, s.snd );
|
||||||
ASSERT( s.frames_read <= s.frames_written );
|
|
||||||
|
|
||||||
got_frames += frames_to_read;
|
got_frames += frames_to_read;
|
||||||
frames_left -= frames_to_read;
|
frames_left -= frames_to_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we don't have enough to fill the buffer, we've underrun. */
|
/* If we don't have enough to fill the buffer, we've underrun. */
|
||||||
// if( got_frames < frames && s.state == sound::PLAYING )
|
if( got_frames < frames && s.state == sound::PLAYING )
|
||||||
// s.underruns++
|
++underruns;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset( buf, 0, frames*bytes_per_frame );
|
memset( buf, 0, frames*bytes_per_frame );
|
||||||
@@ -247,6 +248,22 @@ void RageSound_Generic_Software::Update(float delta)
|
|||||||
sounds[i].state = sound::HALTING;
|
sounds[i].state = sound::HALTING;
|
||||||
// LOG->Trace("set (#%i) %p from STOPPING to HALTING", i, sounds[i].snd);
|
// LOG->Trace("set (#%i) %p from STOPPING to HALTING", i, sounds[i].snd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static float fNext = 0;
|
||||||
|
if( RageTimer::GetTimeSinceStart() >= fNext )
|
||||||
|
{
|
||||||
|
/* Lockless: only Mix() can write to underruns. */
|
||||||
|
int current_underruns = underruns;
|
||||||
|
if( current_underruns > logged_underruns )
|
||||||
|
{
|
||||||
|
LOG->Trace( "Mixing underruns: %i", current_underruns - logged_underruns );
|
||||||
|
logged_underruns = current_underruns;
|
||||||
|
|
||||||
|
/* Don't log again for at least a second, or we'll burst output
|
||||||
|
* and possibly cause more underruns. */
|
||||||
|
fNext = RageTimer::GetTimeSinceStart() + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSound_Generic_Software::StartMixing( RageSoundBase *snd )
|
void RageSound_Generic_Software::StartMixing( RageSoundBase *snd )
|
||||||
|
|||||||
Reference in New Issue
Block a user