diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 8945ec46..87ddc0d0 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -399,7 +399,6 @@ public: }; #ifdef AUDIO_OAL_USE_SNDFILE -#if 1 static sf_count_t sndfile_vio_get_filelen(void* user_data) { int32 pos = ftell((FILE*)user_data); @@ -528,7 +527,8 @@ public: return size; } }; -#else + +#if DR_WAV_IMPLEMENTATION static size_t drwav_read_replacement(void* pUserData, void* pBufferOut, size_t bytesToRead) { return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData); @@ -1156,7 +1156,7 @@ CStream::CStream(char *filename, ALuint *sources, ALuint (&buffers)[NUM_STREAMBU if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) #ifdef AUDIO_OAL_USE_SNDFILE m_pSoundFile = new CSndFile(m_aFilename); -#elif 0 +#elif defined(DR_WAV_IMPLEMENTATION) m_pSoundFile = new CDrWav(m_aFilename); #else m_pSoundFile = new CWavFile(m_aFilename); diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 9e66bf45..2ead7a3f 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -11,12 +11,6 @@ const char *_psGetUserFilesFolder(); -// io is really slow on the Wii U -// so we're buffering files -#ifdef __WIIU__ -#define BUFFER -#endif - /* * Windows FILE is BROKEN for GTA. * @@ -29,7 +23,7 @@ struct myFILE { bool isText; FILE *file; -#ifdef BUFFER +#ifdef BUFFER_FILES char* buf; #endif }; @@ -90,7 +84,7 @@ found: myfiles[fd].file = fcaseopen(filename, realmode); if(myfiles[fd].file == nil) return 0; -#ifdef BUFFER +#ifdef BUFFER_FILES myfiles[fd].buf = (char*) memalign(0x40, IO_BUFFER_SIZE); setvbuf(myfiles[fd].file, myfiles[fd].buf, _IOFBF, IO_BUFFER_SIZE); #endif @@ -105,7 +99,7 @@ myfclose(int fd) if(myfiles[fd].file){ ret = fclose(myfiles[fd].file); myfiles[fd].file = nil; -#ifdef BUFFER +#ifdef BUFFER_FILES free(myfiles[fd].buf); #endif return ret; diff --git a/src/core/config.h b/src/core/config.h index f4cccb94..198ad28d 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -141,8 +141,6 @@ enum Config { NUM_EXPLOSIONS = 48, }; -#define IO_BUFFER_SIZE 128*1024 - // We don't expect to compile for PS2 or Xbox // but it might be interesting for documentation purposes #define GTA_PC @@ -410,6 +408,16 @@ enum Config { #define VC_RAIN_NERF // Reduces number of rain particles #endif +#ifdef __WIIU__ +#define KEEP_FRONTEND_LOADED +#define BUFFER_FILES +#endif + +#ifdef BUFFER_FILES +#define IO_BUFFER_SIZE (128*1024) +#define INI_BUFFER_SIZE (8*1024) // 8k should be enough for the ini file +#endif + #if defined __MWERKS__ || defined VANILLA_DEFINES #define FINAL #undef CHATTYSPLASH diff --git a/src/extras/ini_parser.hpp b/src/extras/ini_parser.hpp index 7bea024c..7a3b3396 100644 --- a/src/extras/ini_parser.hpp +++ b/src/extras/ini_parser.hpp @@ -33,6 +33,9 @@ #include // for std::FILE #include // for std::find_if #include // for std::function +#ifdef BUFFER_FILES +#include // for memalign +#endif namespace linb { @@ -193,6 +196,11 @@ namespace linb string_type null_string; size_type pos; +#ifdef BUFFER_FILES + char* buffer = (char*) memalign(0x40, INI_BUFFER_SIZE); + setvbuf(f, buffer, _IOFBF, INI_BUFFER_SIZE); +#endif + // Trims an string auto trim = [](string_type& s, bool trimLeft, bool trimRight) -> string_type& { @@ -264,6 +272,9 @@ namespace linb } fclose(f); +#ifdef BUFFER_FILES + free(buffer); +#endif return true; } return false; @@ -276,6 +287,10 @@ namespace linb { if(FILE* f = fopen(filename, "w")) { +#ifdef BUFFER_FILES + char* buffer = (char*) memalign(0x40, INI_BUFFER_SIZE); + setvbuf(f, buffer, _IOFBF, INI_BUFFER_SIZE); +#endif bool first = true; for(auto& sec : this->data) { @@ -290,6 +305,9 @@ namespace linb } } fclose(f); +#ifdef BUFFER_FILES + free(buffer); +#endif return true; } return false;