diff options
-rw-r--r-- | src/audio/oal/stream.cpp | 36 | ||||
-rw-r--r-- | src/audio/sampman.h | 6 | ||||
-rw-r--r-- | src/audio/sampman_oal.cpp | 12 | ||||
-rw-r--r-- | src/core/FileMgr.cpp | 3 | ||||
-rw-r--r-- | src/core/FileMgr.h | 2 | ||||
-rw-r--r-- | src/core/Streaming.cpp | 8 | ||||
-rw-r--r-- | src/core/config.h | 14 | ||||
-rw-r--r-- | src/vehicles/HandlingMgr.cpp | 2 |
8 files changed, 54 insertions, 29 deletions
diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index f9c02821..ccb17577 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -4,20 +4,23 @@ #include "stream.h" #include "sampman.h" -#ifdef AUDIO_OPUS -#include <opusfile.h> -#else #ifdef _WIN32 #ifdef AUDIO_OAL_USE_SNDFILE #pragma comment( lib, "libsndfile-1.lib" ) #endif +#ifdef AUDIO_OAL_USE_MPG123 #pragma comment( lib, "libmpg123-0.lib" ) #endif +#endif #ifdef AUDIO_OAL_USE_SNDFILE #include <sndfile.h> #endif +#ifdef AUDIO_OAL_USE_MPG123 #include <mpg123.h> #endif +#ifdef AUDIO_OAL_USE_OPUS +#include <opusfile.h> +#endif #ifndef _WIN32 #include "crossplatform.h" @@ -81,7 +84,6 @@ public: CSortStereoBuffer SortStereoBuffer; -#ifndef AUDIO_OPUS class CImaADPCMDecoder { const uint16 StepTable[89] = { @@ -461,11 +463,9 @@ public: }; #endif -#ifdef _WIN32 +#ifdef AUDIO_OAL_USE_MPG123 // fuzzy seek eliminates stutter when playing ADF but spams errors a lot (nothing breaks though) #define MP3_USE_FUZZY_SEEK -#endif // _WIN32 - class CMP3File : public IDecoder { @@ -484,7 +484,7 @@ public: if ( m_pMH ) { #ifdef MP3_USE_FUZZY_SEEK - mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS, 0.0); + mpg123_param(m_pMH, MPG123_FLAGS, MPG123_FUZZY | MPG123_SEEKBUFFER | MPG123_GAPLESS | MPG123_QUIET, 0.0); #endif long rate = 0; int channels = 0; @@ -567,6 +567,7 @@ public: } }; +#endif #define VAG_LINE_SIZE (0x10) #define VAG_SAMPLES_IN_LINE (28) @@ -804,7 +805,7 @@ public: return bufSizePerChannel * m_nChannels; } }; -#else +#ifdef AUDIO_OAL_USE_OPUS class COpusFile : public IDecoder { OggOpusFile *m_FileH; @@ -902,14 +903,14 @@ public: void CStream::Initialise() { -#ifndef AUDIO_OPUS +#ifdef AUDIO_OAL_USE_MPG123 mpg123_init(); #endif } void CStream::Terminate() { -#ifndef AUDIO_OPUS +#ifdef AUDIO_OAL_USE_MPG123 mpg123_exit(); #endif } @@ -942,19 +943,20 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU DEV("Stream %s\n", m_aFilename); -#ifndef AUDIO_OPUS - if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3")) - m_pSoundFile = new CMP3File(m_aFilename); - else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) + if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) #ifdef AUDIO_OAL_USE_SNDFILE m_pSoundFile = new CSndFile(m_aFilename); #else m_pSoundFile = new CWavFile(m_aFilename); #endif +#ifdef AUDIO_OAL_USE_MPG123 + else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3")) + m_pSoundFile = new CMP3File(m_aFilename); +#endif else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".vb")], ".VB")) m_pSoundFile = new CVbFile(m_aFilename, overrideSampleRate); -#else - if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus")) +#ifdef AUDIO_OAL_USE_OPUS + else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus")) m_pSoundFile = new COpusFile(m_aFilename); #endif else diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 2284d385..72c3eb7f 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -218,7 +218,7 @@ extern uint32 BankStartOffset[MAX_SFX_BANKS]; extern int defaultProvider; #endif -#ifdef AUDIO_OPUS +#if defined(OPUS_AUDIO_PATHS) static char StreamedNameTable[][25] = { "AUDIO\\HEAD.OPUS", "AUDIO\\CLASS.OPUS", "AUDIO\\KJAH.OPUS", "AUDIO\\RISE.OPUS", "AUDIO\\LIPS.OPUS", "AUDIO\\GAME.OPUS", "AUDIO\\MSX.OPUS", "AUDIO\\FLASH.OPUS", "AUDIO\\CHAT.OPUS", "AUDIO\\HEAD.OPUS", "AUDIO\\POLICE.OPUS", "AUDIO\\CITY.OPUS", @@ -254,9 +254,9 @@ static char StreamedNameTable[][25] = { "AUDIO\\door_2.OPUS", "AUDIO\\door_3.OPUS", "AUDIO\\door_4.OPUS", "AUDIO\\door_5.OPUS", "AUDIO\\door_6.OPUS", "AUDIO\\t3_a.OPUS", "AUDIO\\t3_b.OPUS", "AUDIO\\t3_c.OPUS", "AUDIO\\k1_b.OPUS", "AUDIO\\cat1.OPUS"}; #else +#if defined(PS2_AUDIO_PATHS) static char StreamedNameTable[][25]= { -#ifdef PS2_AUDIO "AUDIO\\MUSIC\\HEAD.VB", "AUDIO\\MUSIC\\CLASS.VB", "AUDIO\\MUSIC\\KJAH.VB", @@ -353,6 +353,8 @@ static char StreamedNameTable[][25]= "AUDIO\\MUSIC\\MISCOM.VB", "AUDIO\\MUSIC\\END.VB", #else +static char StreamedNameTable[][25] = +{ "AUDIO\\HEAD.WAV", "AUDIO\\CLASS.WAV", "AUDIO\\KJAH.WAV", diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 07d943e3..bb7f0aac 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -30,7 +30,7 @@ #include "MusicManager.h" #include "Frontend.h" #include "Timer.h" -#ifdef AUDIO_OPUS +#ifdef AUDIO_OAL_USE_OPUS #include <opusfile.h> #endif @@ -83,7 +83,7 @@ char SampleBankDescFilename[] = "audio/sfx.SDT"; char SampleBankDataFilename[] = "audio/sfx.RAW"; FILE *fpSampleDescHandle; -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX OggOpusFile *fpSampleDataHandle; #else FILE *fpSampleDataHandle; @@ -1218,7 +1218,7 @@ cSampleManager::LoadSampleBank(uint8 nBank) return false; } -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX int samplesRead = 0; int samplesSize = nSampleBankSize[nBank] / 2; op_pcm_seek(fpSampleDataHandle, 0); @@ -1331,7 +1331,7 @@ cSampleManager::LoadPedComment(uint32 nComment) } } -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX int samplesRead = 0; int samplesSize = m_aSamples[nComment].nSize / 2; op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2); @@ -1978,7 +1978,7 @@ cSampleManager::InitialiseSampleBanks(void) fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) return false; -#ifndef AUDIO_OPUS +#ifndef OPUS_SFX fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb"); if ( fpSampleDataHandle == NULL ) { @@ -1996,7 +1996,7 @@ cSampleManager::InitialiseSampleBanks(void) fpSampleDataHandle = op_open_file(SampleBankDataFilename, &e); #endif fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); -#ifdef AUDIO_OPUS +#ifdef OPUS_SFX int32 _nSampleDataEndOffset = m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nSize; #endif fclose(fpSampleDescHandle); diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 99923ddf..32aa4041 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -241,7 +241,7 @@ CFileMgr::SetDirMyDocuments(void) } ssize_t -CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode) +CFileMgr::LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode) { int fd; ssize_t n, len; @@ -257,6 +257,7 @@ CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode) return -1; #endif len += n; + assert(len < maxlen); }while(n == 0x4000); buf[len] = 0; myfclose(fd); diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h index 98a78360..f70451b7 100644 --- a/src/core/FileMgr.h +++ b/src/core/FileMgr.h @@ -9,7 +9,7 @@ public: static void ChangeDir(const char *dir); static void SetDir(const char *dir); static void SetDirMyDocuments(void); - static ssize_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode); + static ssize_t LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode); static int OpenFile(const char *file, const char *mode); static int OpenFile(const char *file) { return OpenFile(file, "rb"); } static int OpenFileForWriting(const char *file); diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 03b49fd6..dae7fadb 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -509,10 +509,18 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) mi = CModelInfo::GetModelInfo(streamId); // Txd has to be loaded +#ifdef FIX_BUGS + if(!HasTxdLoaded(mi->GetTxdSlot())){ +#else + // texDict will exist even if only first part has loaded if(CTxdStore::GetSlot(mi->GetTxdSlot())->texDict == nil){ +#endif debug("failed to load %s because TXD %s is not in memory\n", mi->GetName(), CTxdStore::GetTxdName(mi->GetTxdSlot())); RemoveModel(streamId); +#ifndef FIX_BUGS + // if we're just waiting for it to load, don't remove this RemoveTxd(mi->GetTxdSlot()); +#endif ReRequestModel(streamId); RwStreamClose(stream, &mem); return false; diff --git a/src/core/config.h b/src/core/config.h index 9e52311c..295ddee0 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -356,9 +356,21 @@ enum Config { // Audio #define RADIO_SCROLL_TO_PREV_STATION #define AUDIO_CACHE -//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS +//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds) //#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder +#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files +#ifdef AUDIO_OPUS +#define AUDIO_OAL_USE_OPUS // enable support of opus files +#define OPUS_AUDIO_PATHS // changes audio paths to opus paths (doesn't work if AUDIO_OAL_USE_OPUS isn't enabled) +#define OPUS_SFX // enable if your sfx.raw is encoded with opus (doesn't work if AUDIO_OAL_USE_OPUS isn't enabled) + +#ifndef AUDIO_OAL_USE_OPUS +#undef OPUS_AUDIO_PATHS +#undef OPUS_SFX +#endif + +#endif // IMG #define BIG_IMG // allows to read larger img files diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp index fde280e8..00aaa682 100644 --- a/src/vehicles/HandlingMgr.cpp +++ b/src/vehicles/HandlingMgr.cpp @@ -191,7 +191,7 @@ void cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling) { // acceleration is in ms^-2, but we need mf^-2 where f is one frame time (50fps) - float velocity, a, b, specificVolume; + float velocity, a, b; handling->Transmission.fEngineAcceleration *= 1.0f/(50.0f*50.0f); handling->Transmission.fMaxVelocity *= 1000.0f/(60.0f*60.0f * 50.0f); |