This commit is contained in:
Glenn Maynard
2003-10-03 09:00:02 +00:00
parent eb46c45567
commit b532617434
2 changed files with 11 additions and 10 deletions
+9 -8
View File
@@ -555,8 +555,8 @@ float RageSound::GetLengthSeconds()
return len / 1000.f; /* ms -> secs */ return len / 1000.f; /* ms -> secs */
} }
/* Get the position, not counting GetOffsetFix. */ /* Get the position in samples, not counting GetOffsetFix, playback rate. */
float RageSound::GetPositionSecondsInternal() const int RageSound::GetPositionSecondsInternal() const
{ {
LockMut(SOUNDMAN->lock); LockMut(SOUNDMAN->lock);
@@ -565,7 +565,7 @@ float RageSound::GetPositionSecondsInternal() const
{ {
if(stopped_position != -1) if(stopped_position != -1)
return stopped_position; return stopped_position;
return position / float(samplerate()); return position;
} }
/* If we don't yet have any position data, GetPCM hasn't yet been called at all, /* If we don't yet have any position data, GetPCM hasn't yet been called at all,
@@ -573,7 +573,7 @@ float RageSound::GetPositionSecondsInternal() const
if(pos_map.empty()) if(pos_map.empty())
{ {
LOG->Trace("no data yet; %i", position); LOG->Trace("no data yet; %i", position);
return position / float(samplerate()); return position;
} }
/* Get our current hardware position. */ /* Get our current hardware position. */
@@ -590,7 +590,7 @@ float RageSound::GetPositionSecondsInternal() const
/* cur_sample lies in this block; it's an exact match. Figure /* cur_sample lies in this block; it's an exact match. Figure
* out the exact position. */ * out the exact position. */
int diff = pos_map[i].position - pos_map[i].sampleno; int diff = pos_map[i].position - pos_map[i].sampleno;
return float(cur_sample + diff) / samplerate(); return cur_sample + diff;
} }
/* See if the current position is close to the beginning of this block. */ /* See if the current position is close to the beginning of this block. */
@@ -621,13 +621,14 @@ float RageSound::GetPositionSecondsInternal() const
*/ */
LOG->Trace("Approximate sound time: sample %i, dist %i, closest %i", cur_sample, closest_position_dist, closest_position); LOG->Trace("Approximate sound time: sample %i, dist %i, closest %i", cur_sample, closest_position_dist, closest_position);
return closest_position / float(samplerate()); return closest_position;
} }
float RageSound::GetPositionSeconds() const float RageSound::GetPositionSeconds() const
{ {
const float ret = GetPositionSecondsInternal() + Sample->GetOffsetFix(); const float pos = GetPositionSecondsInternal() / float(samplerate());
return GetPlaybackRate() * ret; const float fixed_pos = pos + Sample->GetOffsetFix();
return GetPlaybackRate() * fixed_pos;
} }
+2 -2
View File
@@ -122,7 +122,7 @@ private:
* (we're not playing); and we can't seek back to the current playing position * (we're not playing); and we can't seek back to the current playing position
* when we stop (too slow), but we want to be able to report the position we * when we stop (too slow), but we want to be able to report the position we
* were at when we stopped without jumping to the last position we buffered. */ * were at when we stopped without jumping to the last position we buffered. */
float stopped_position; int stopped_position;
bool playing; bool playing;
/* Number of samples input and output when changing speed. Currently, /* Number of samples input and output when changing speed. Currently,
@@ -132,7 +132,7 @@ private:
CString error; CString error;
float GetPositionSecondsInternal() const; int GetPositionSecondsInternal() const;
bool SetPositionSamples( int samples = -1 ); bool SetPositionSamples( int samples = -1 );
int GetData(char *buffer, int size); int GetData(char *buffer, int size);
void Fail(CString reason); void Fail(CString reason);