summaryrefslogtreecommitdiffstats
path: root/src/audio/sampman_oal.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-02-19 12:30:41 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2021-02-19 12:30:41 +0100
commit139c6bfcf3dd2e2f8e26d987b6da6db51645f210 (patch)
tree6f532f596e72861aac9af7b7c3a3a3c4e4e308df /src/audio/sampman_oal.cpp
parentGet keyboard input from X11 on Linux (diff)
downloadre3-139c6bfcf3dd2e2f8e26d987b6da6db51645f210.tar
re3-139c6bfcf3dd2e2f8e26d987b6da6db51645f210.tar.gz
re3-139c6bfcf3dd2e2f8e26d987b6da6db51645f210.tar.bz2
re3-139c6bfcf3dd2e2f8e26d987b6da6db51645f210.tar.lz
re3-139c6bfcf3dd2e2f8e26d987b6da6db51645f210.tar.xz
re3-139c6bfcf3dd2e2f8e26d987b6da6db51645f210.tar.zst
re3-139c6bfcf3dd2e2f8e26d987b6da6db51645f210.zip
Diffstat (limited to 'src/audio/sampman_oal.cpp')
-rw-r--r--src/audio/sampman_oal.cpp176
1 files changed, 83 insertions, 93 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index d9adef5b..3d4b8dbd 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -730,8 +730,6 @@ _FindMP3s(void)
delete aStream[0];
aStream[0] = NULL;
- OutputDebugString(fd.cFileName);
-
pList->pNext = new tMP3Entry;
tMP3Entry *e = pList->pNext;
@@ -1706,91 +1704,91 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
{
+ int i = 0;
uint32 position = nPos;
- char filename[256];
-
- ASSERT( nStream < MAX_STREAMS );
-
- if ( nFile < TOTAL_STREAMED_SOUNDS )
- {
- if ( aStream[nStream] )
- {
- delete aStream[nStream];
- aStream[nStream] = NULL;
- }
-
- if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
- {
- uint32 i = 0;
- do {
- if(i != 0 || _bIsMp3Active) {
- if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
-
- _CurMP3Pos = 0;
-
- tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
+ char filename[MAX_PATH];
- if(mp3) {
- mp3 = _pMP3List;
- if(mp3 == NULL) {
- _bIsMp3Active = false;
- nFile = 0;
- strcat(filename, StreamedNameTable[nFile]);
+ if ( nFile >= TOTAL_STREAMED_SOUNDS )
+ return false;
- CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- ASSERT(stream != NULL);
+ if ( aStream[nStream] )
+ {
+ delete aStream[nStream];
+ aStream[nStream] = NULL;
+ }
+ if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ {
+ do
+ {
+ // Switched to MP3 player just now
+ if ( !_bIsMp3Active && i == 0 )
+ {
+ if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
+ position = 0;
+ tMP3Entry *e = _pMP3List;
- aStream[nStream] = stream;
+ // Try to continue from previous song, if already started
+ if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
+ nFile = 0;
+ strcpy(filename, StreamedNameTable[nFile]);
+
+ CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- if (stream->Setup()) {
- if (position != 0)
- stream->SetPosMS(position);
+ aStream[nStream] = stream;
- stream->Start();
+ if (stream->Setup()) {
+ if (position != 0)
+ stream->SetPosMS(position);
- return true;
- } else {
- delete stream;
- aStream[nStream] = NULL;
- }
+ stream->Start();
- return false;
- }
+ return true;
+ } else {
+ delete stream;
+ aStream[nStream] = NULL;
}
+ return false;
- if (mp3->pLinkPath != NULL)
- aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ } else {
+ if ( e->pLinkPath != NULL )
+ aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, mp3->aFilename);
-
- aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ strcat(filename, e->aFilename);
+
+ aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
}
-
+
if (aStream[nStream]->Setup()) {
+ if (position != 0)
+ aStream[nStream]->SetPosMS(position);
+
aStream[nStream]->Start();
+ _bIsMp3Active = true;
return true;
} else {
delete aStream[nStream];
aStream[nStream] = NULL;
}
-
- _bIsMp3Active = false;
- continue;
+ // fall through, start playing from another song
}
- if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
- position = 0;
-
- tMP3Entry *e;
- if ( !_GetMP3PosFromStreamPos(&position, &e) )
+ } else {
+ if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
+
+ _CurMP3Pos = 0;
+
+ tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
+ if ( !mp3 )
{
- if ( e == NULL )
+ mp3 = _pMP3List;
+ if ( !_pMP3List )
{
nFile = 0;
- strcat(filename, StreamedNameTable[nFile]);
+ _bIsMp3Active = 0;
+ strcpy(filename, StreamedNameTable[nFile]);
+
CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- ASSERT(stream != NULL);
aStream[nStream] = stream;
@@ -1805,61 +1803,53 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
delete stream;
aStream[nStream] = NULL;
}
-
return false;
}
}
-
- if (e->pLinkPath != NULL)
- aStream[nStream] = new CStream(e->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ if(mp3->pLinkPath != NULL)
+ aStream[nStream] = new CStream(mp3->pLinkPath, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, e->aFilename);
+ strcat(filename, mp3->aFilename);
aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]);
}
if (aStream[nStream]->Setup()) {
- if (position != 0)
- aStream[nStream]->SetPosMS(position);
-
aStream[nStream]->Start();
-
+#ifdef FIX_BUGS
_bIsMp3Active = true;
+#endif
return true;
} else {
delete aStream[nStream];
aStream[nStream] = NULL;
}
-
- _bIsMp3Active = false;
- } while(++i < nNumMP3s);
-
- position = 0;
- nFile = 0;
+ }
+ _bIsMp3Active = 0;
}
+ while ( ++i < nNumMP3s );
+ position = 0;
+ nFile = 0;
+ }
+ strcpy(filename, StreamedNameTable[nFile]);
+
+ CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- strcpy(filename, StreamedNameTable[nFile]);
-
- CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- ASSERT(stream != NULL);
+ aStream[nStream] = stream;
+
+ if ( stream->Setup() ) {
+ if (position != 0)
+ stream->SetPosMS(position);
- aStream[nStream] = stream;
+ stream->Start();
- if ( stream->Setup() ) {
- if (position != 0)
- stream->SetPosMS(position);
-
- stream->Start();
-
- return true;
- } else {
- delete stream;
- aStream[nStream] = NULL;
- }
+ return true;
+ } else {
+ delete stream;
+ aStream[nStream] = NULL;
}
-
return false;
}