diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-02-16 17:08:19 +0100 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-02-16 17:08:19 +0100 |
commit | e38467ef3affef25b83daf0c0c3b8a61f04e8a65 (patch) | |
tree | 3628aed1314f21147e7a46f3095fa341088d8044 /src/audio/sampman_oal.cpp | |
parent | fix mailbox particle (diff) | |
parent | PR rules (diff) | |
download | re3-e38467ef3affef25b83daf0c0c3b8a61f04e8a65.tar re3-e38467ef3affef25b83daf0c0c3b8a61f04e8a65.tar.gz re3-e38467ef3affef25b83daf0c0c3b8a61f04e8a65.tar.bz2 re3-e38467ef3affef25b83daf0c0c3b8a61f04e8a65.tar.lz re3-e38467ef3affef25b83daf0c0c3b8a61f04e8a65.tar.xz re3-e38467ef3affef25b83daf0c0c3b8a61f04e8a65.tar.zst re3-e38467ef3affef25b83daf0c0c3b8a61f04e8a65.zip |
Diffstat (limited to 'src/audio/sampman_oal.cpp')
-rw-r--r-- | src/audio/sampman_oal.cpp | 82 |
1 files changed, 50 insertions, 32 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 7da871a5..57a70246 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -46,7 +46,6 @@ //TODO: fix eax3 reverb //TODO: max channels -//TODO: loop count cSampleManager SampleManager; bool _bSampmanInitialised = false; @@ -1695,7 +1694,7 @@ cSampleManager::PreloadStreamedFile(uint32 nFile, uint8 nStream) ASSERT(stream != NULL); aStream[nStream] = stream; - if ( !stream->IsOpened() ) + if ( !stream->Setup() ) { delete stream; aStream[nStream] = NULL; @@ -1725,7 +1724,7 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream) if ( stream ) { - if ( stream->Setup() ) + if ( stream->IsOpened() ) { stream->Start(); } @@ -1771,13 +1770,13 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = stream; - if (stream->IsOpened()) { - if (stream->Setup()) { - if (position != 0) - stream->SetPosMS(position); + if (stream->Setup()) { + stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1); + nStreamLoopedFlag[nStream] = true; + if (position != 0) + stream->SetPosMS(position); - stream->Start(); - } + stream->Start(); return true; } else { @@ -1798,10 +1797,8 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000); } - if (aStream[nStream]->IsOpened()) { - if (aStream[nStream]->Setup()) { - aStream[nStream]->Start(); - } + if (aStream[nStream]->Setup()) { + aStream[nStream]->Start(); return true; } else { @@ -1827,13 +1824,13 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = stream; - if (stream->IsOpened()) { - if (stream->Setup()) { - if (position != 0) - stream->SetPosMS(position); + if (stream->Setup()) { + stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1); + nStreamLoopedFlag[nStream] = true; + if (position != 0) + stream->SetPosMS(position); - stream->Start(); - } + stream->Start(); return true; } else { @@ -1854,13 +1851,11 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); } - if (aStream[nStream]->IsOpened()) { - if (aStream[nStream]->Setup()) { - if (position != 0) - aStream[nStream]->SetPosMS(position); + if (aStream[nStream]->Setup()) { + if (position != 0) + aStream[nStream]->SetPosMS(position); - aStream[nStream]->Start(); - } + aStream[nStream]->Start(); _bIsMp3Active = true; return true; @@ -1884,13 +1879,13 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream) aStream[nStream] = stream; - if ( stream->IsOpened() ) { - if ( stream->Setup() ) { - if (position != 0) - stream->SetPosMS(position); + if ( stream->Setup() ) { + stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1); + nStreamLoopedFlag[nStream] = true; + if (position != 0) + stream->SetPosMS(position); - stream->Start(); - } + stream->Start(); return true; } else { @@ -1913,6 +1908,9 @@ cSampleManager::StopStreamedFile(uint8 nStream) { delete stream; aStream[nStream] = NULL; + + if ( nStream == 0 ) + _bIsMp3Active = false; } } @@ -1925,7 +1923,21 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream) if ( stream ) { - return stream->GetPosMS(); + if ( _bIsMp3Active ) + { + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + + if ( mp3 != NULL ) + { + return stream->GetPosMS() + mp3->nTrackStreamPos; + } + else + return 0; + } + else + { + return stream->GetPosMS(); + } } return 0; @@ -2001,6 +2013,12 @@ cSampleManager::Service(void) if ( stream ) stream->Update(); } + int refCount = CChannel::channelsThatNeedService; + for ( int32 i = 0; refCount && i < MAXCHANNELS+MAX2DCHANNELS; i++ ) + { + if ( aChannel[i].Update() ) + refCount--; + } } bool |