diff options
author | eray orçunus <erayorcunus@gmail.com> | 2020-10-05 12:59:40 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2020-10-05 12:59:40 +0200 |
commit | 6f3f581d8acbd9581407bf9701afd2c7d06494f7 (patch) | |
tree | 2e2a496914a3a346e16c5cea9ab853959c15674e /src/audio/oal | |
parent | Fix Linux audio path (diff) | |
download | re3-6f3f581d8acbd9581407bf9701afd2c7d06494f7.tar re3-6f3f581d8acbd9581407bf9701afd2c7d06494f7.tar.gz re3-6f3f581d8acbd9581407bf9701afd2c7d06494f7.tar.bz2 re3-6f3f581d8acbd9581407bf9701afd2c7d06494f7.tar.lz re3-6f3f581d8acbd9581407bf9701afd2c7d06494f7.tar.xz re3-6f3f581d8acbd9581407bf9701afd2c7d06494f7.tar.zst re3-6f3f581d8acbd9581407bf9701afd2c7d06494f7.zip |
Diffstat (limited to 'src/audio/oal')
-rw-r--r-- | src/audio/oal/stream.cpp | 12 | ||||
-rw-r--r-- | src/audio/oal/stream.h | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 23a0a0c9..2f392264 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -162,13 +162,13 @@ public: void Seek(uint32 milliseconds) { if ( !IsOpened() ) return; - mpg123_seek(m_pMH, ms2samples(milliseconds)*GetSampleSize(), SEEK_SET); + mpg123_seek(m_pMH, ms2samples(milliseconds), SEEK_SET); } uint32 Tell() { if ( !IsOpened() ) return 0; - return samples2ms(mpg123_tell(m_pMH)/GetSampleSize()); + return samples2ms(mpg123_tell(m_pMH)); } uint32 Decode(void *buffer) @@ -254,13 +254,13 @@ public: void Seek(uint32 milliseconds) { if ( !IsOpened() ) return; - op_pcm_seek(m_FileH, ms2samples(milliseconds) * GetSampleSize()); + op_pcm_seek(m_FileH, ms2samples(milliseconds) / GetChannels()); } uint32 Tell() { if ( !IsOpened() ) return 0; - return samples2ms(op_pcm_tell(m_FileH)/GetSampleSize()); + return samples2ms(op_pcm_tell(m_FileH) * GetChannels()); } uint32 Decode(void *buffer) @@ -515,8 +515,8 @@ uint32 CStream::GetPosMS() alGetSourcei(m_alSource, AL_BYTE_OFFSET, &offset); return m_pSoundFile->Tell() - - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS-1)) - + m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize()); + - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS-1)) / m_pSoundFile->GetChannels() + + m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize()) / m_pSoundFile->GetChannels(); } uint32 CStream::GetLengthMS() diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index 456c080a..2476abcc 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -24,12 +24,12 @@ public: uint32 ms2samples(uint32 ms) { - return float(ms) / 1000.0f * float(GetChannels()) * float(GetSampleRate()); + return float(ms) / 1000.0f * float(GetSampleRate()); } uint32 samples2ms(uint32 sm) { - return float(sm) * 1000.0f / float(GetChannels()) / float(GetSampleRate()); + return float(sm) * 1000.0f / float(GetSampleRate()); } uint32 GetBufferSamples() @@ -108,4 +108,4 @@ public: void ProviderTerm(); }; -#endif
\ No newline at end of file +#endif |