diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index 16972d92..d2da13e5 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -83,14 +83,14 @@ public: { memset(&m_soundInfo, 0, sizeof(m_soundInfo)); - m_buffer = (char*) memalign(0x40, BUFSIZ); + m_buffer = (char*) memalign(0x40, IO_BUFFER_SIZE); m_fileHandle = fopen(path, "rb"); if (!m_fileHandle) { return; } - setbuf(m_fileHandle, m_buffer); + setvbuf(m_fileHandle, m_buffer, _IOFBF, IO_BUFFER_SIZE); m_pfSound = sf_open_virtual(&vio, SFM_READ, &m_soundInfo, m_fileHandle); } @@ -177,14 +177,14 @@ public: { memset(&m_drWav, 0, sizeof(m_drWav)); - m_buffer = (char*) memalign(0x40, BUFSIZ); + m_buffer = (char*) memalign(0x40, IO_BUFFER_SIZE); m_fileHandle = fopen(path, "rb"); if (!m_fileHandle) { return; } - setbuf(m_fileHandle, m_buffer); + setvbuf(m_fileHandle, m_buffer, _IOFBF, IO_BUFFER_SIZE); if( !drwav_init(&m_drWav, drwav_read_replacement, drwav_seek_replacement, m_fileHandle, NULL) ) { return; @@ -300,7 +300,7 @@ public: int channels = 0; int encoding = 0; - m_buffer = (char*) memalign(0x40, BUFSIZ); + m_buffer = (char*) memalign(0x40, IO_BUFFER_SIZE); m_fileHandle = fopen(path, "rb"); if (!m_fileHandle) { @@ -308,7 +308,7 @@ public: return; } - setbuf(m_fileHandle, m_buffer); + setvbuf(m_fileHandle, m_buffer, _IOFBF, IO_BUFFER_SIZE); m_bOpened = mpg123_replace_reader_handle(m_pMH, mpg123_read_replacement, mpg123_seek_replacement, NULL) == MPG123_OK && mpg123_open_handle(m_pMH, m_fileHandle) == MPG123_OK diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 20d533fe..aa665c68 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -91,8 +91,8 @@ found: if(myfiles[fd].file == nil) return 0; #ifdef BUFFER - myfiles[fd].buf = (char*) memalign(0x40, BUFSIZ); - setbuf(myfiles[fd].file, myfiles[fd].buf); + myfiles[fd].buf = (char*) memalign(0x40, IO_BUFFER_SIZE); + setvbuf(myfiles[fd].file, myfiles[fd].buf, _IOFBF, IO_BUFFER_SIZE); #endif return fd; } diff --git a/src/core/config.h b/src/core/config.h index 2d739896..a5a054f0 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -135,6 +135,8 @@ 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