Audio/Sound: Fix GetPlayingOffset/SetPlayingOffset on some implementations
Former-commit-id: 64223409d16af0d8ada3edeb2eb24366c5e312ca
This commit is contained in:
parent
b87a8b3f25
commit
2415002fc5
|
|
@ -49,10 +49,10 @@ namespace Nz
|
||||||
|
|
||||||
UInt32 Sound::GetPlayingOffset() const
|
UInt32 Sound::GetPlayingOffset() const
|
||||||
{
|
{
|
||||||
ALfloat seconds = -1.f;
|
ALint samples = 0;
|
||||||
alGetSourcef(m_source, AL_SEC_OFFSET, &seconds);
|
alGetSourcei(m_source, AL_SAMPLE_OFFSET, &samples);
|
||||||
|
|
||||||
return static_cast<UInt32>(seconds*1000);
|
return static_cast<UInt32>(1000ULL * samples / m_buffer->GetSampleRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundStatus Sound::GetStatus() const
|
SoundStatus Sound::GetStatus() const
|
||||||
|
|
@ -160,7 +160,7 @@ namespace Nz
|
||||||
|
|
||||||
void Sound::SetPlayingOffset(UInt32 offset)
|
void Sound::SetPlayingOffset(UInt32 offset)
|
||||||
{
|
{
|
||||||
alSourcef(m_source, AL_SEC_OFFSET, offset/1000.f);
|
alSourcei(m_source, AL_SAMPLE_OFFSET, static_cast<ALint>(offset/1000.f * m_buffer->GetSampleRate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::Stop()
|
void Sound::Stop()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue