RageSound::CleanPosMap

This commit is contained in:
Glenn Maynard
2004-01-19 20:37:14 +00:00
parent c8d3e46ea4
commit ce6b11a343
2 changed files with 19 additions and 2 deletions
+18 -2
View File
@@ -393,9 +393,9 @@ int RageSound::GetPCM(char *buffer, int size, int sampleno)
LockMut(SOUNDMAN->lock);
ASSERT(playing);
/* Erase old pos_map data. */
while(pos_map.size() > 1 && pos_map.back().sampleno - pos_map.front().sampleno > pos_map_backlog_samples)
pos_map.pop_front();
CleanPosMap( pos_map );
/*
* "sampleno" is the audio driver's conception of time. "position"
@@ -621,6 +621,22 @@ int RageSound::SearchPosMap( const deque<pos_map_t> &pos_map, int cur_sample, bo
return closest_position;
}
void RageSound::CleanPosMap( deque<pos_map_t> &pos_map )
{
/* Determine the number of frames of data we have. */
int total_frames = 0;
for( unsigned i = 0; i < pos_map.size(); ++i )
total_frames += pos_map[i].samples;
/* Remove the oldest entry so long we'll stil have enough data. Don't delete every
* sample, so we'll always have some data to extrapolate from. */
while( pos_map.size() > 1 && total_frames - pos_map.front().samples > pos_map_backlog_samples )
{
total_frames -= pos_map.front().samples;
pos_map.pop_front();
}
}
/* Get the position in frames (ignoring GetOffsetFix). */
int RageSound::GetPositionSecondsInternal( bool *approximate ) const
{
+1
View File
@@ -106,6 +106,7 @@ private:
};
deque<pos_map_t> pos_map;
static int SearchPosMap( const deque<pos_map_t> &pos_map, int cur_sample, bool *approximate );
static void CleanPosMap( deque<pos_map_t> &pos_map );
CString m_sFilePath;