OAL Loops, fixes

This commit is contained in:
erorcun 2021-02-02 16:39:08 +03:00
commit 713562685a
6 changed files with 143 additions and 66 deletions

View file

@ -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 {
@ -2001,6 +1996,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