summaryrefslogtreecommitdiffstats
path: root/src/audio/sampman_miles.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-02-19 20:32:11 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2021-02-19 20:32:11 +0100
commit14dcd8f04c41bb4d70590d966ef5ce45bb3e9131 (patch)
treea87f86ffc3465be1e1bde4bea5eb2462644b8ea3 /src/audio/sampman_miles.cpp
parentmake debug render groups optional (diff)
downloadre3-14dcd8f04c41bb4d70590d966ef5ce45bb3e9131.tar
re3-14dcd8f04c41bb4d70590d966ef5ce45bb3e9131.tar.gz
re3-14dcd8f04c41bb4d70590d966ef5ce45bb3e9131.tar.bz2
re3-14dcd8f04c41bb4d70590d966ef5ce45bb3e9131.tar.lz
re3-14dcd8f04c41bb4d70590d966ef5ce45bb3e9131.tar.xz
re3-14dcd8f04c41bb4d70590d966ef5ce45bb3e9131.tar.zst
re3-14dcd8f04c41bb4d70590d966ef5ce45bb3e9131.zip
Diffstat (limited to '')
-rw-r--r--src/audio/sampman_miles.cpp186
1 files changed, 90 insertions, 96 deletions
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index 36f230b4..3eee78ae 100644
--- a/src/audio/sampman_miles.cpp
+++ b/src/audio/sampman_miles.cpp
@@ -2082,142 +2082,136 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
{
+ int i = 0;
uint32 position = nPos;
char filename[MAX_PATH];
- if ( m_bInitialised && nFile < TOTAL_STREAMED_SOUNDS )
+ if ( !m_bInitialised || nFile >= TOTAL_STREAMED_SOUNDS )
+ return false;
+
+ if ( mp3Stream[nStream] )
{
- if ( mp3Stream[nStream] )
- {
- AIL_pause_stream(mp3Stream[nStream], 1);
- AIL_close_stream(mp3Stream[nStream]);
- }
-
- if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ AIL_pause_stream(mp3Stream[nStream], 1);
+ AIL_close_stream(mp3Stream[nStream]);
+ }
+ if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ {
+ do
{
- uint32 i = 0;
- do {
- if(i != 0 || _bIsMp3Active) {
- if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0;
-
- _CurMP3Pos = 0;
-
- tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index);
-
- if(mp3) {
- mp3 = _pMP3List;
- if(mp3 == NULL) {
- _bIsMp3Active = false;
- nFile = 0;
- strcpy(filename, m_MiscomPath);
- strcat(filename, StreamedNameTable[nFile]);
-
- mp3Stream[nStream] =
- AIL_open_stream(DIG, filename, 0);
- if(mp3Stream[nStream]) {
- AIL_set_stream_loop_count(
- mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- AIL_set_stream_ms_position(
- mp3Stream[nStream], position);
- AIL_pause_stream(mp3Stream[nStream],
- 0);
- return true;
- }
-
- return false;
- }
+ // Just switched to MP3 player
+ if ( !_bIsMp3Active && i == 0 )
+ {
+ if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
+ position = 0;
+ tMP3Entry *e = _pMP3List;
+
+ // Try to continue from previous song, if already started
+ if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
+ nFile = 0;
+ strcpy(filename, m_MiscomPath);
+ strcat(filename, StreamedNameTable[nFile]);
+ mp3Stream[nStream] =
+ AIL_open_stream(DIG, filename, 0);
+ if(mp3Stream[nStream]) {
+ AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ AIL_set_stream_ms_position(mp3Stream[nStream], position);
+ AIL_pause_stream(mp3Stream[nStream], 0);
+ return true;
}
+ return false;
- if(mp3->pLinkPath != NULL)
- mp3Stream[nStream] =
- AIL_open_stream(DIG, mp3->pLinkPath, 0);
+ } else {
+ if ( e->pLinkPath != NULL )
+ mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0);
else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, mp3->aFilename);
-
- mp3Stream[nStream] =
- AIL_open_stream(DIG, filename, 0);
+ strcat(filename, e->aFilename);
+
+ mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
}
-
- if(mp3Stream[nStream]) {
+
+ if ( mp3Stream[nStream] ) {
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
- AIL_set_stream_ms_position(mp3Stream[nStream], 0);
+ AIL_set_stream_ms_position(mp3Stream[nStream], position);
AIL_pause_stream(mp3Stream[nStream], 0);
+
+ _bIsMp3Active = true;
+
return true;
}
-
- _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;
+ _bIsMp3Active = 0;
strcpy(filename, m_MiscomPath);
strcat(filename, StreamedNameTable[nFile]);
+
mp3Stream[nStream] =
AIL_open_stream(DIG, filename, 0);
if(mp3Stream[nStream]) {
- AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
+ AIL_set_stream_loop_count(
+ mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
nStreamLoopedFlag[nStream] = true;
- AIL_set_stream_ms_position(mp3Stream[nStream], position);
- AIL_pause_stream(mp3Stream[nStream], 0);
+ AIL_set_stream_ms_position(
+ mp3Stream[nStream], position);
+ AIL_pause_stream(mp3Stream[nStream],
+ 0);
return true;
}
-
return false;
}
}
-
- if ( e->pLinkPath != NULL )
- mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0);
- else
- {
+ if(mp3->pLinkPath != NULL)
+ mp3Stream[nStream] = AIL_open_stream(DIG, mp3->pLinkPath, 0);
+ else {
strcpy(filename, _mp3DirectoryPath);
- strcat(filename, e->aFilename);
-
- mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ strcat(filename, mp3->aFilename);
+
+ mp3Stream[nStream] =
+ AIL_open_stream(DIG, filename, 0);
}
-
- if ( mp3Stream[nStream] )
- {
+
+ if(mp3Stream[nStream]) {
AIL_set_stream_loop_count(mp3Stream[nStream], 1);
- AIL_set_stream_ms_position(mp3Stream[nStream], position);
+ AIL_set_stream_ms_position(mp3Stream[nStream], 0);
AIL_pause_stream(mp3Stream[nStream], 0);
-
+#ifdef FIX_BUGS
_bIsMp3Active = true;
-
+#endif
return true;
}
-
- _bIsMp3Active = false;
- } while(++i < nNumMP3s);
-
- position = 0;
- nFile = 0;
- }
-
- strcpy(filename, m_MiscomPath);
- strcat(filename, StreamedNameTable[nFile]);
-
- mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
- if ( mp3Stream[nStream] )
- {
- AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- AIL_set_stream_ms_position(mp3Stream[nStream], position);
- AIL_pause_stream(mp3Stream[nStream], 0);
- return true;
+ }
+ _bIsMp3Active = 0;
}
+ while ( ++i < nNumMP3s );
+ position = 0;
+ nFile = 0;
}
+ strcpy(filename, m_MiscomPath);
+ strcat(filename, StreamedNameTable[nFile]);
+ mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0);
+ if ( mp3Stream[nStream] )
+ {
+ AIL_set_stream_loop_count(mp3Stream[nStream], nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ AIL_set_stream_ms_position(mp3Stream[nStream], position);
+ AIL_pause_stream(mp3Stream[nStream], 0);
+ return true;
+ }
return false;
}