Review sound IO functions
This commit is contained in:
parent
36b5ceba8a
commit
075de8f837
|
@ -58,7 +58,7 @@ static int audioSoundDecoderReadHandler(void* data, void* buffer, unsigned int s
|
||||||
|
|
||||||
// AudioOpen
|
// AudioOpen
|
||||||
// 0x41A2EC
|
// 0x41A2EC
|
||||||
int audioOpen(const char* fname, int flags, ...)
|
int audioOpen(const char* fname, int flags)
|
||||||
{
|
{
|
||||||
char path[80];
|
char path[80];
|
||||||
snprintf(path, sizeof(path), "%s", fname);
|
snprintf(path, sizeof(path), "%s", fname);
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace fallout {
|
||||||
|
|
||||||
typedef bool(AudioQueryCompressedFunc)(char* filePath);
|
typedef bool(AudioQueryCompressedFunc)(char* filePath);
|
||||||
|
|
||||||
int audioOpen(const char* fname, int mode, ...);
|
int audioOpen(const char* fname, int mode);
|
||||||
int audioClose(int handle);
|
int audioClose(int handle);
|
||||||
int audioRead(int handle, void* buffer, unsigned int size);
|
int audioRead(int handle, void* buffer, unsigned int size);
|
||||||
long audioSeek(int handle, long offset, int origin);
|
long audioSeek(int handle, long offset, int origin);
|
||||||
|
|
|
@ -57,7 +57,7 @@ static int audioFileSoundDecoderReadHandler(void* data, void* buffer, unsigned i
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x41A88C
|
// 0x41A88C
|
||||||
int audioFileOpen(const char* fname, int flags, ...)
|
int audioFileOpen(const char* fname, int flags)
|
||||||
{
|
{
|
||||||
char path[COMPAT_MAX_PATH];
|
char path[COMPAT_MAX_PATH];
|
||||||
strcpy(path, fname);
|
strcpy(path, fname);
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace fallout {
|
||||||
|
|
||||||
typedef bool(AudioFileQueryCompressedFunc)(char* filePath);
|
typedef bool(AudioFileQueryCompressedFunc)(char* filePath);
|
||||||
|
|
||||||
int audioFileOpen(const char* fname, int flags, ...);
|
int audioFileOpen(const char* fname, int flags);
|
||||||
int audioFileClose(int handle);
|
int audioFileClose(int handle);
|
||||||
int audioFileRead(int handle, void* buf, unsigned int size);
|
int audioFileRead(int handle, void* buf, unsigned int size);
|
||||||
long audioFileSeek(int handle, long offset, int origin);
|
long audioFileSeek(int handle, long offset, int origin);
|
||||||
|
|
|
@ -157,7 +157,7 @@ static int _gsound_speech_volume_get_set(int volume);
|
||||||
static void speechPause();
|
static void speechPause();
|
||||||
static void speechResume();
|
static void speechResume();
|
||||||
static void _gsound_bkg_proc();
|
static void _gsound_bkg_proc();
|
||||||
static int gameSoundFileOpen(const char* fname, int access, ...);
|
static int gameSoundFileOpen(const char* fname, int access);
|
||||||
static long _gsound_write_();
|
static long _gsound_write_();
|
||||||
static long gameSoundFileTellNotImplemented(int handle);
|
static long gameSoundFileTellNotImplemented(int handle);
|
||||||
static int gameSoundFileWrite(int handle, const void* buf, unsigned int size);
|
static int gameSoundFileWrite(int handle, const void* buf, unsigned int size);
|
||||||
|
@ -898,7 +898,7 @@ int speechLoad(const char* fname, int a2, int a3, int a4)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (soundSetFileIO(gSpeechSound, &audioOpen, &audioClose, &audioRead, NULL, &audioSeek, &gameSoundFileTellNotImplemented, &audioGetSize)) {
|
if (soundSetFileIO(gSpeechSound, audioOpen, audioClose, audioRead, NULL, audioSeek, gameSoundFileTellNotImplemented, audioGetSize)) {
|
||||||
if (gGameSoundDebugEnabled) {
|
if (gGameSoundDebugEnabled) {
|
||||||
debugPrint("failed because file IO could not be set for compression.\n");
|
debugPrint("failed because file IO could not be set for compression.\n");
|
||||||
}
|
}
|
||||||
|
@ -1548,7 +1548,7 @@ void _gsound_bkg_proc()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x451A08
|
// 0x451A08
|
||||||
int gameSoundFileOpen(const char* fname, int flags, ...)
|
int gameSoundFileOpen(const char* fname, int flags)
|
||||||
{
|
{
|
||||||
if ((flags & 2) != 0) {
|
if ((flags & 2) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -187,21 +187,6 @@ void compat_makepath(char* path, const char* drive, const char* dir, const char*
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int compat_read(int fileHandle, void* buf, unsigned int size)
|
|
||||||
{
|
|
||||||
return read(fileHandle, buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
int compat_write(int fileHandle, const void* buf, unsigned int size)
|
|
||||||
{
|
|
||||||
return write(fileHandle, buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
long compat_lseek(int fileHandle, long offset, int origin)
|
|
||||||
{
|
|
||||||
return lseek(fileHandle, offset, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
long compat_tell(int fd)
|
long compat_tell(int fd)
|
||||||
{
|
{
|
||||||
return lseek(fd, 0, SEEK_CUR);
|
return lseek(fd, 0, SEEK_CUR);
|
||||||
|
|
|
@ -29,9 +29,6 @@ char* compat_strlwr(char* string);
|
||||||
char* compat_itoa(int value, char* buffer, int radix);
|
char* compat_itoa(int value, char* buffer, int radix);
|
||||||
void compat_splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
|
void compat_splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
|
||||||
void compat_makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext);
|
void compat_makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext);
|
||||||
int compat_read(int fileHandle, void* buf, unsigned int size);
|
|
||||||
int compat_write(int fileHandle, const void* buf, unsigned int size);
|
|
||||||
long compat_lseek(int fileHandle, long offset, int origin);
|
|
||||||
long compat_tell(int fileHandle);
|
long compat_tell(int fileHandle);
|
||||||
long compat_filelength(int fd);
|
long compat_filelength(int fd);
|
||||||
int compat_mkdir(const char* path);
|
int compat_mkdir(const char* path);
|
||||||
|
|
70
src/sound.cc
70
src/sound.cc
|
@ -45,6 +45,13 @@ typedef struct FadeSound {
|
||||||
static void* soundMallocProcDefaultImpl(size_t size);
|
static void* soundMallocProcDefaultImpl(size_t size);
|
||||||
static void* soundReallocProcDefaultImpl(void* ptr, size_t size);
|
static void* soundReallocProcDefaultImpl(void* ptr, size_t size);
|
||||||
static void soundFreeProcDefaultImpl(void* ptr);
|
static void soundFreeProcDefaultImpl(void* ptr);
|
||||||
|
static long soundFileSize(int fileHandle);
|
||||||
|
static long soundTellData(int fileHandle);
|
||||||
|
static int soundWriteData(int fileHandle, const void* buf, unsigned int size);
|
||||||
|
static int soundReadData(int fileHandle, void* buf, unsigned int size);
|
||||||
|
static int soundOpenData(const char* filePath, int flags);
|
||||||
|
static long soundSeekData(int fileHandle, long offset, int origin);
|
||||||
|
static int soundCloseData(int fileHandle);
|
||||||
static char* soundFileManglerDefaultImpl(char* fname);
|
static char* soundFileManglerDefaultImpl(char* fname);
|
||||||
static void _refreshSoundBuffers(Sound* sound);
|
static void _refreshSoundBuffers(Sound* sound);
|
||||||
static int _preloadBuffers(Sound* sound);
|
static int _preloadBuffers(Sound* sound);
|
||||||
|
@ -77,13 +84,13 @@ static FreeProc* gSoundFreeProc = soundFreeProcDefaultImpl;
|
||||||
|
|
||||||
// 0x51D494
|
// 0x51D494
|
||||||
static SoundFileIO gSoundDefaultFileIO = {
|
static SoundFileIO gSoundDefaultFileIO = {
|
||||||
open,
|
soundOpenData,
|
||||||
close,
|
soundCloseData,
|
||||||
compat_read,
|
soundReadData,
|
||||||
compat_write,
|
soundWriteData,
|
||||||
compat_lseek,
|
soundSeekData,
|
||||||
compat_tell,
|
soundTellData,
|
||||||
compat_filelength,
|
soundFileSize,
|
||||||
-1,
|
-1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,6 +191,55 @@ void soundSetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeP
|
||||||
gSoundFreeProc = freeProc;
|
gSoundFreeProc = freeProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0x4AC71C
|
||||||
|
static long soundFileSize(int fileHandle)
|
||||||
|
{
|
||||||
|
long pos;
|
||||||
|
long size;
|
||||||
|
|
||||||
|
pos = compat_tell(fileHandle);
|
||||||
|
size = lseek(fileHandle, 0, SEEK_END);
|
||||||
|
lseek(fileHandle, pos, SEEK_SET);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0x4AC750
|
||||||
|
static long soundTellData(int fileHandle)
|
||||||
|
{
|
||||||
|
return compat_tell(fileHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0x4AC758
|
||||||
|
static int soundWriteData(int fileHandle, const void* buf, unsigned int size)
|
||||||
|
{
|
||||||
|
return write(fileHandle, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0x4AC760
|
||||||
|
static int soundReadData(int fileHandle, void* buf, unsigned int size)
|
||||||
|
{
|
||||||
|
return read(fileHandle, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0x4AC768
|
||||||
|
static int soundOpenData(const char* filePath, int flags)
|
||||||
|
{
|
||||||
|
return open(filePath, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0x4AC774
|
||||||
|
static long soundSeekData(int fileHandle, long offset, int origin)
|
||||||
|
{
|
||||||
|
return lseek(fileHandle, offset, origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0x4AC77C
|
||||||
|
static int soundCloseData(int fileHandle)
|
||||||
|
{
|
||||||
|
return close(fileHandle);
|
||||||
|
}
|
||||||
|
|
||||||
// 0x4AC78C
|
// 0x4AC78C
|
||||||
char* soundFileManglerDefaultImpl(char* fname)
|
char* soundFileManglerDefaultImpl(char* fname)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,7 @@ typedef enum SoundError {
|
||||||
SOUND_ERR_COUNT,
|
SOUND_ERR_COUNT,
|
||||||
} SoundError;
|
} SoundError;
|
||||||
|
|
||||||
typedef int SoundOpenProc(const char* filePath, int flags, ...);
|
typedef int SoundOpenProc(const char* filePath, int flags);
|
||||||
typedef int SoundCloseProc(int fileHandle);
|
typedef int SoundCloseProc(int fileHandle);
|
||||||
typedef int SoundReadProc(int fileHandle, void* buf, unsigned int size);
|
typedef int SoundReadProc(int fileHandle, void* buf, unsigned int size);
|
||||||
typedef int SoundWriteProc(int fileHandle, const void* buf, unsigned int size);
|
typedef int SoundWriteProc(int fileHandle, const void* buf, unsigned int size);
|
||||||
|
|
|
@ -154,7 +154,7 @@ void soundEffectsCacheFlush()
|
||||||
|
|
||||||
// sfxc_cached_open
|
// sfxc_cached_open
|
||||||
// 0x4A915C
|
// 0x4A915C
|
||||||
int soundEffectsCacheFileOpen(const char* fname, int mode, ...)
|
int soundEffectsCacheFileOpen(const char* fname, int mode)
|
||||||
{
|
{
|
||||||
if (_sfxc_files_open >= SOUND_EFFECTS_MAX_COUNT) {
|
if (_sfxc_files_open >= SOUND_EFFECTS_MAX_COUNT) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -11,7 +11,7 @@ int soundEffectsCacheInit(int cache_size, const char* effectsPath);
|
||||||
void soundEffectsCacheExit();
|
void soundEffectsCacheExit();
|
||||||
int soundEffectsCacheInitialized();
|
int soundEffectsCacheInitialized();
|
||||||
void soundEffectsCacheFlush();
|
void soundEffectsCacheFlush();
|
||||||
int soundEffectsCacheFileOpen(const char* fname, int mode, ...);
|
int soundEffectsCacheFileOpen(const char* fname, int mode);
|
||||||
int soundEffectsCacheFileClose(int handle);
|
int soundEffectsCacheFileClose(int handle);
|
||||||
int soundEffectsCacheFileRead(int handle, void* buf, unsigned int size);
|
int soundEffectsCacheFileRead(int handle, void* buf, unsigned int size);
|
||||||
int soundEffectsCacheFileWrite(int handle, const void* buf, unsigned int size);
|
int soundEffectsCacheFileWrite(int handle, const void* buf, unsigned int size);
|
||||||
|
|
Loading…
Reference in New Issue