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
}
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 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);
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);
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);
int compat_mkdir(const char* path);
unsigned int compat_timeGetTime();

View File

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