summaryrefslogtreecommitdiffstats
path: root/src/audio
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-02-26 10:07:32 +0100
committerSergeanur <s.anureev@yandex.ua>2021-02-26 10:07:32 +0100
commitf6910d35f702e7767e6b52d5e7b3edd80fe85f96 (patch)
tree3968c943b721813f6880765e11a8ae2ade07da23 /src/audio
parentrename error strings to RELCS (diff)
parentPoliceRadio -> PolRadio (original name) (diff)
downloadre3-f6910d35f702e7767e6b52d5e7b3edd80fe85f96.tar
re3-f6910d35f702e7767e6b52d5e7b3edd80fe85f96.tar.gz
re3-f6910d35f702e7767e6b52d5e7b3edd80fe85f96.tar.bz2
re3-f6910d35f702e7767e6b52d5e7b3edd80fe85f96.tar.lz
re3-f6910d35f702e7767e6b52d5e7b3edd80fe85f96.tar.xz
re3-f6910d35f702e7767e6b52d5e7b3edd80fe85f96.tar.zst
re3-f6910d35f702e7767e6b52d5e7b3edd80fe85f96.zip
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/AudioManager.h2
-rw-r--r--src/audio/MusicManager.cpp10
-rw-r--r--src/audio/PolRadio.cpp (renamed from src/audio/PoliceRadio.cpp)2
-rw-r--r--src/audio/PolRadio.h (renamed from src/audio/PoliceRadio.h)0
-rw-r--r--src/audio/sampman_miles.cpp186
-rw-r--r--src/audio/sampman_oal.cpp177
6 files changed, 184 insertions, 193 deletions
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 2eb2220b..98a9b32d 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -2,7 +2,7 @@
#include "audio_enums.h"
#include "AudioCollision.h"
-#include "PoliceRadio.h"
+#include "PolRadio.h"
#include "VehicleModelInfo.h"
#include "Vehicle.h"
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index 34eae77c..e15bde94 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -1265,7 +1265,8 @@ cMusicManager::DisplayRadioStationName()
if (vehicle)
{
-#if defined RADIO_SCROLL_TO_PREV_STATION || defined FIX_BUGS // Because m_nFrontendTrack can have NO_TRACK
+ // Prev scroll needs it to be signed, and m_nFrontendTrack can be NO_TRACK thus FIX_BUGS
+#if defined RADIO_SCROLL_TO_PREV_STATION || defined FIX_BUGS
int track;
#else
uint8 track;
@@ -1281,13 +1282,16 @@ cMusicManager::DisplayRadioStationName()
#endif
while (track >= NUM_RADIOS + 1) track -= NUM_RADIOS + 1;
- // We already handle this condition while scrolling back, on key press. No need to change this.
+ // On scrolling back we handle this condition on key press. No need to change this.
if (!DMAudio.IsMP3RadioChannelAvailable() && track == USERTRACK)
gNumRetunePresses++;
}
else
+#ifdef RADIO_OFF_TEXT
+ track = GetCarTuning(); // gStreamedSound or veh->m_nRadioStation would also work, but these don't cover police/taxi radios
+#else
track = m_nFrontendTrack;
-
+#endif
wchar* string = nil;
switch (track) {
case WILDSTYLE: string = TheText.Get("FEA_FM0"); break;
diff --git a/src/audio/PoliceRadio.cpp b/src/audio/PolRadio.cpp
index b8f44f60..17bf95e8 100644
--- a/src/audio/PoliceRadio.cpp
+++ b/src/audio/PolRadio.cpp
@@ -7,7 +7,7 @@
#include "AudioSamples.h"
#include "MusicManager.h"
#include "PlayerPed.h"
-#include "PoliceRadio.h"
+#include "PolRadio.h"
#include "Replay.h"
#include "Vehicle.h"
#include "World.h"
diff --git a/src/audio/PoliceRadio.h b/src/audio/PolRadio.h
index d7c928e2..d7c928e2 100644
--- a/src/audio/PoliceRadio.h
+++ b/src/audio/PolRadio.h
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp
index bf91a874..b115654a 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;
}
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 57a70246..921cbfad 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -1734,93 +1734,94 @@ cSampleManager::StartPreloadedStreamedFile(uint8 nStream)
bool
cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
{
+ int i = 0;
uint32 position = nPos;
- char filename[256];
-
- ASSERT( nStream < MAX_STREAMS );
+ char filename[MAX_PATH];
- if ( nFile < TOTAL_STREAMED_SOUNDS )
+ if ( nFile >= TOTAL_STREAMED_SOUNDS )
+ return false;
+
+ if ( aStream[nStream] )
{
- if ( aStream[nStream] )
- {
- delete aStream[nStream];
- aStream[nStream] = NULL;
- }
-
- if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
+ delete aStream[nStream];
+ aStream[nStream] = NULL;
+ }
+ 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;
- strcat(filename, StreamedNameTable[nFile]);
+ // Just switched to MP3 player
+ if ( !_bIsMp3Active && i == 0 )
+ {
+ if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
+ position = 0;
+ tMP3Entry *e = _pMP3List;
- CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- ASSERT(stream != NULL);
+ // Try to continue from previous song, if already started
+ if(!_GetMP3PosFromStreamPos(&position, &e) && !e) {
+ nFile = 0;
- aStream[nStream] = stream;
+ strcpy(filename, StreamedNameTable[nFile]);
+ CStream* stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
- if (stream->Setup()) {
- stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- if (position != 0)
- stream->SetPosMS(position);
+ aStream[nStream] = stream;
- stream->Start();
+ if (stream->Setup()) {
+ stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ 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);
+ strcat(filename, e->aFilename);
- aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
+ 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;
@@ -1837,63 +1838,55 @@ cSampleManager::StartStreamedFile(uint32 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]);
+ aStream[nStream] = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream], IsThisTrackAt16KHz(nFile) ? 16000 : 32000);
}
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() ) {
+ stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
+ nStreamLoopedFlag[nStream] = true;
+ if (position != 0)
+ stream->SetPosMS(position);
- aStream[nStream] = stream;
+ stream->Start();
- if ( stream->Setup() ) {
- stream->SetLoopCount(nStreamLoopedFlag[nStream] ? 0 : 1);
- nStreamLoopedFlag[nStream] = true;
- 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;
}