Cleanup sound.h (#60)
This commit is contained in:
parent
ead439335e
commit
0695947b49
75
src/sound.cc
75
src/sound.cc
|
@ -1,7 +1,6 @@
|
|||
#include "sound.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "memory.h"
|
||||
#include "platform_compat.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -20,26 +19,62 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#define SOUND_FLAG_SOUND_IS_PLAYING (0x02)
|
||||
#define SOUND_FLAG_SOUND_IS_PAUSED (0x08)
|
||||
|
||||
typedef char*(SoundFileNameMangler)(char*);
|
||||
|
||||
typedef struct STRUCT_51D478 {
|
||||
Sound* field_0;
|
||||
int field_4;
|
||||
int field_8;
|
||||
int field_C;
|
||||
int field_10;
|
||||
int field_14;
|
||||
struct STRUCT_51D478* prev;
|
||||
struct STRUCT_51D478* next;
|
||||
} STRUCT_51D478;
|
||||
|
||||
static void* soundMallocProcDefaultImpl(size_t size);
|
||||
static void* soundReallocProcDefaultImpl(void* ptr, size_t size);
|
||||
static void soundFreeProcDefaultImpl(void* ptr);
|
||||
static char* soundFileManglerDefaultImpl(char* fname);
|
||||
static void _refreshSoundBuffers(Sound* sound);
|
||||
static int _preloadBuffers(Sound* sound);
|
||||
static int _soundRewind(Sound* sound);
|
||||
static int _addSoundData(Sound* sound, unsigned char* buf, int size);
|
||||
static int _soundSetData(Sound* sound, unsigned char* buf, int size);
|
||||
static int soundContinue(Sound* sound);
|
||||
static int _soundGetVolume(Sound* sound);
|
||||
static void soundDeleteInternal(Sound* sound);
|
||||
#ifdef HAVE_DSOUND
|
||||
static void CALLBACK _doTimerEvent(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
|
||||
static void _removeTimedEvent(unsigned int* timerId);
|
||||
#endif
|
||||
static void _removeFadeSound(STRUCT_51D478* a1);
|
||||
static void _fadeSounds();
|
||||
static int _internalSoundFade(Sound* sound, int a2, int a3, int a4);
|
||||
|
||||
// 0x51D478
|
||||
STRUCT_51D478* _fadeHead = NULL;
|
||||
static STRUCT_51D478* _fadeHead = NULL;
|
||||
|
||||
// 0x51D47C
|
||||
STRUCT_51D478* _fadeFreeList = NULL;
|
||||
static STRUCT_51D478* _fadeFreeList = NULL;
|
||||
|
||||
// 0x51D480
|
||||
unsigned int _fadeEventHandle = UINT_MAX;
|
||||
static unsigned int _fadeEventHandle = UINT_MAX;
|
||||
|
||||
// 0x51D488
|
||||
MallocProc* gSoundMallocProc = soundMallocProcDefaultImpl;
|
||||
static MallocProc* gSoundMallocProc = soundMallocProcDefaultImpl;
|
||||
|
||||
// 0x51D48C
|
||||
ReallocProc* gSoundReallocProc = soundReallocProcDefaultImpl;
|
||||
static ReallocProc* gSoundReallocProc = soundReallocProcDefaultImpl;
|
||||
|
||||
// 0x51D490
|
||||
FreeProc* gSoundFreeProc = soundFreeProcDefaultImpl;
|
||||
static FreeProc* gSoundFreeProc = soundFreeProcDefaultImpl;
|
||||
|
||||
// 0x51D494
|
||||
SoundFileIO gSoundDefaultFileIO = {
|
||||
static SoundFileIO gSoundDefaultFileIO = {
|
||||
open,
|
||||
close,
|
||||
compat_read,
|
||||
|
@ -51,10 +86,10 @@ SoundFileIO gSoundDefaultFileIO = {
|
|||
};
|
||||
|
||||
// 0x51D4B4
|
||||
SoundFileNameMangler* gSoundFileNameMangler = soundFileManglerDefaultImpl;
|
||||
static SoundFileNameMangler* gSoundFileNameMangler = soundFileManglerDefaultImpl;
|
||||
|
||||
// 0x51D4B8
|
||||
const char* gSoundErrorDescriptions[SOUND_ERR_COUNT] = {
|
||||
static const char* gSoundErrorDescriptions[SOUND_ERR_COUNT] = {
|
||||
"sound.c: No error",
|
||||
"sound.c: SOS driver not loaded",
|
||||
"sound.c: SOS invalid pointer",
|
||||
|
@ -92,38 +127,38 @@ const char* gSoundErrorDescriptions[SOUND_ERR_COUNT] = {
|
|||
};
|
||||
|
||||
// 0x668150
|
||||
int gSoundLastError;
|
||||
static int gSoundLastError;
|
||||
|
||||
// 0x668154
|
||||
int _masterVol;
|
||||
static int _masterVol;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x668158
|
||||
LPDIRECTSOUNDBUFFER gDirectSoundPrimaryBuffer;
|
||||
static LPDIRECTSOUNDBUFFER gDirectSoundPrimaryBuffer;
|
||||
#endif
|
||||
|
||||
// 0x66815C
|
||||
int _sampleRate;
|
||||
static int _sampleRate;
|
||||
|
||||
// Number of sounds currently playing.
|
||||
//
|
||||
// 0x668160
|
||||
int _numSounds;
|
||||
static int _numSounds;
|
||||
|
||||
// 0x668164
|
||||
int _deviceInit;
|
||||
static int _deviceInit;
|
||||
|
||||
// 0x668168
|
||||
int _dataSize;
|
||||
static int _dataSize;
|
||||
|
||||
// 0x66816C
|
||||
int _numBuffers;
|
||||
static int _numBuffers;
|
||||
|
||||
// 0x668170
|
||||
bool gSoundInitialized;
|
||||
static bool gSoundInitialized;
|
||||
|
||||
// 0x668174
|
||||
Sound* gSoundListHead;
|
||||
static Sound* gSoundListHead;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x668178
|
||||
|
|
58
src/sound.h
58
src/sound.h
|
@ -4,9 +4,6 @@
|
|||
#include "memory_defs.h"
|
||||
#include "win32.h"
|
||||
|
||||
#define SOUND_FLAG_SOUND_IS_PLAYING (0x02)
|
||||
#define SOUND_FLAG_SOUND_IS_PAUSED (0x08)
|
||||
|
||||
#define VOLUME_MIN (0)
|
||||
#define VOLUME_MAX (0x7FFF)
|
||||
|
||||
|
@ -49,7 +46,6 @@ typedef enum SoundError {
|
|||
SOUND_ERR_COUNT,
|
||||
} SoundError;
|
||||
|
||||
typedef char*(SoundFileNameMangler)(char*);
|
||||
typedef int SoundOpenProc(const char* filePath, int flags, ...);
|
||||
typedef int SoundCloseProc(int fileHandle);
|
||||
typedef int SoundReadProc(int fileHandle, void* buf, unsigned int size);
|
||||
|
@ -110,64 +106,19 @@ typedef struct Sound {
|
|||
struct Sound* prev;
|
||||
} Sound;
|
||||
|
||||
typedef struct STRUCT_51D478 {
|
||||
Sound* field_0;
|
||||
int field_4;
|
||||
int field_8;
|
||||
int field_C;
|
||||
int field_10;
|
||||
int field_14;
|
||||
struct STRUCT_51D478* prev;
|
||||
struct STRUCT_51D478* next;
|
||||
} STRUCT_51D478;
|
||||
|
||||
extern STRUCT_51D478* _fadeHead;
|
||||
extern STRUCT_51D478* _fadeFreeList;
|
||||
|
||||
extern unsigned int _fadeEventHandle;
|
||||
extern MallocProc* gSoundMallocProc;
|
||||
extern ReallocProc* gSoundReallocProc;
|
||||
extern FreeProc* gSoundFreeProc;
|
||||
extern SoundFileIO gSoundDefaultFileIO;
|
||||
extern SoundFileNameMangler* gSoundFileNameMangler;
|
||||
extern const char* gSoundErrorDescriptions[SOUND_ERR_COUNT];
|
||||
|
||||
extern int gSoundLastError;
|
||||
extern int _masterVol;
|
||||
#ifdef HAVE_DSOUND
|
||||
extern LPDIRECTSOUNDBUFFER gDirectSoundPrimaryBuffer;
|
||||
#endif
|
||||
extern int _sampleRate;
|
||||
extern int _numSounds;
|
||||
extern int _deviceInit;
|
||||
extern int _dataSize;
|
||||
extern int _numBuffers;
|
||||
extern bool gSoundInitialized;
|
||||
extern Sound* gSoundListHead;
|
||||
#ifdef HAVE_DSOUND
|
||||
extern LPDIRECTSOUND gDirectSound;
|
||||
#endif
|
||||
|
||||
void* soundMallocProcDefaultImpl(size_t size);
|
||||
void* soundReallocProcDefaultImpl(void* ptr, size_t size);
|
||||
void soundFreeProcDefaultImpl(void* ptr);
|
||||
void soundSetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeProc* freeProc);
|
||||
|
||||
char* soundFileManglerDefaultImpl(char* fname);
|
||||
const char* soundGetErrorDescription(int err);
|
||||
void _refreshSoundBuffers(Sound* sound);
|
||||
int soundInit(int a1, int a2, int a3, int a4, int rate);
|
||||
void soundExit();
|
||||
Sound* soundAllocate(int a1, int a2);
|
||||
int _preloadBuffers(Sound* sound);
|
||||
int soundLoad(Sound* sound, char* filePath);
|
||||
int _soundRewind(Sound* sound);
|
||||
int _addSoundData(Sound* sound, unsigned char* buf, int size);
|
||||
int _soundSetData(Sound* sound, unsigned char* buf, int size);
|
||||
int soundPlay(Sound* sound);
|
||||
int soundStop(Sound* sound);
|
||||
int soundDelete(Sound* sound);
|
||||
int soundContinue(Sound* sound);
|
||||
bool soundIsPlaying(Sound* sound);
|
||||
bool _soundDone(Sound* sound);
|
||||
bool soundIsPaused(Sound* sound);
|
||||
|
@ -176,24 +127,15 @@ int soundGetDuration(Sound* sound);
|
|||
int soundSetLooping(Sound* sound, int a2);
|
||||
int _soundVolumeHMItoDirectSound(int a1);
|
||||
int soundSetVolume(Sound* sound, int volume);
|
||||
int _soundGetVolume(Sound* sound);
|
||||
int soundSetCallback(Sound* sound, SoundCallback* callback, void* userData);
|
||||
int soundSetChannels(Sound* sound, int channels);
|
||||
int soundSetReadLimit(Sound* sound, int readLimit);
|
||||
int soundPause(Sound* sound);
|
||||
int soundResume(Sound* sound);
|
||||
int soundSetFileIO(Sound* sound, SoundOpenProc* openProc, SoundCloseProc* closeProc, SoundReadProc* readProc, SoundWriteProc* writeProc, SoundSeekProc* seekProc, SoundTellProc* tellProc, SoundFileLengthProc* fileLengthProc);
|
||||
void soundDeleteInternal(Sound* sound);
|
||||
int _soundSetMasterVolume(int value);
|
||||
#ifdef HAVE_DSOUND
|
||||
void CALLBACK _doTimerEvent(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
|
||||
void _removeTimedEvent(unsigned int* timerId);
|
||||
#endif
|
||||
int _soundGetPosition(Sound* sound);
|
||||
int _soundSetPosition(Sound* sound, int a2);
|
||||
void _removeFadeSound(STRUCT_51D478* a1);
|
||||
void _fadeSounds();
|
||||
int _internalSoundFade(Sound* sound, int a2, int a3, int a4);
|
||||
int _soundFade(Sound* sound, int a2, int a3);
|
||||
void soundDeleteAll();
|
||||
void soundContinueAll();
|
||||
|
|
Loading…
Reference in New Issue