Fixed SoundStream::GetPlayingOffset looping after a few seconds
This commit is contained in:
parent
d5ced60dec
commit
7f11d16f3b
@ -286,7 +286,7 @@ private :
|
|||||||
unsigned int mySampleRate; ///< Frequency (samples / second)
|
unsigned int mySampleRate; ///< Frequency (samples / second)
|
||||||
unsigned long myFormat; ///< Format of the internal sound buffers
|
unsigned long myFormat; ///< Format of the internal sound buffers
|
||||||
bool myLoop; ///< Loop flag (true to loop, false to play once)
|
bool myLoop; ///< Loop flag (true to loop, false to play once)
|
||||||
unsigned int mySamplesProcessed; ///< Number of buffers processed since beginning of the stream
|
Uint64 mySamplesProcessed; ///< Number of buffers processed since beginning of the stream
|
||||||
bool myEndBuffers[BuffersCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation
|
bool myEndBuffers[BuffersCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void SoundStream::SetPlayingOffset(Uint32 timeOffset)
|
|||||||
OnSeek(timeOffset);
|
OnSeek(timeOffset);
|
||||||
|
|
||||||
// Restart streaming
|
// Restart streaming
|
||||||
mySamplesProcessed = timeOffset * mySampleRate * myChannelsCount / 1000;
|
mySamplesProcessed = static_cast<Uint64>(timeOffset) * mySampleRate * myChannelsCount / 1000;
|
||||||
myIsStreaming = true;
|
myIsStreaming = true;
|
||||||
myThread.Launch();
|
myThread.Launch();
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ Uint32 SoundStream::GetPlayingOffset() const
|
|||||||
ALfloat seconds = 0.f;
|
ALfloat seconds = 0.f;
|
||||||
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
|
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
|
||||||
|
|
||||||
return static_cast<Uint32>(1000 * seconds) + 1000 * mySamplesProcessed / mySampleRate / myChannelsCount;
|
return static_cast<Uint32>(1000 * seconds + 1000 * mySamplesProcessed / mySampleRate / myChannelsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user