Wrap sound stuff

See #17, #24
This commit is contained in:
Alexander Batalov 2022-05-30 00:40:09 +03:00
parent e7f6bbf867
commit 501ae1161d
3 changed files with 37 additions and 4 deletions

View File

@ -101,6 +101,26 @@ 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)
{
return lseek(fd, 0, SEEK_CUR);
}
long compat_filelength(int fd) long compat_filelength(int fd)
{ {
long originalOffset = lseek(fd, 0, SEEK_CUR); long originalOffset = lseek(fd, 0, SEEK_CUR);

View File

@ -24,6 +24,10 @@ 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_filelength(int fd); long compat_filelength(int fd);
int compat_mkdir(const char* path); int compat_mkdir(const char* path);
unsigned int compat_timeGetTime(); unsigned int compat_timeGetTime();

View File

@ -4,10 +4,17 @@
#include "memory.h" #include "memory.h"
#include "platform_compat.h" #include "platform_compat.h"
#ifdef _WIN32
#include <io.h> #include <io.h>
#else
#include <fcntl.h>
#include <unistd.h>
#endif
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#ifdef HAVE_DSOUND
#include <mmsystem.h> #include <mmsystem.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -35,10 +42,10 @@ FreeProc* gSoundFreeProc = soundFreeProcDefaultImpl;
SoundFileIO gSoundDefaultFileIO = { SoundFileIO gSoundDefaultFileIO = {
open, open,
close, close,
read, compat_read,
write, compat_write,
lseek, compat_lseek,
tell, compat_tell,
compat_filelength, compat_filelength,
-1, -1,
}; };
@ -1718,10 +1725,12 @@ void _fadeSounds()
} }
} }
#ifdef HAVE_DSOUND
if (_fadeHead == NULL && _fadeEventHandle != -1) { if (_fadeHead == NULL && _fadeEventHandle != -1) {
timeKillEvent(_fadeEventHandle); timeKillEvent(_fadeEventHandle);
_fadeEventHandle = -1; _fadeEventHandle = -1;
} }
#endif
} }
// 0x4AE988 // 0x4AE988