# HG changeset patch # User koda # Date 1255622088 0 # Node ID c8b1fb10003c5749a2e010ad7b7e7f584c9c236f # Parent fdb76012b6884b9c034d4e1fdb8fc5645ac314b0 fix a potential bug when playing two sounds at the same time (or very near) diff -r fdb76012b688 -r c8b1fb10003c openalbridge/common.h --- a/openalbridge/common.h Thu Oct 15 15:49:42 2009 +0000 +++ b/openalbridge/common.h Thu Oct 15 15:54:48 2009 +0000 @@ -17,8 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifndef COMMON_H -#define COMMON_H + #include #include @@ -39,6 +38,9 @@ #define LOG_ERR 3 #endif +#ifndef COMMON_H +#define COMMON_H + /* magics */ #define OGG_FILE_FORMAT 0x4F676753 #define WAV_FILE_FORMAT 0x52494646 @@ -77,6 +79,30 @@ #define ENDIAN_BIG_16(x) x #endif +/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] **/ +#ifndef _SLEEP_H +#define _SLEEP_H +#ifdef _WIN32 +# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) +# include +# define sleep(t) _sleep((t) * 1000) +# else +# define WIN32_LEAN_AND_MEAN +# include +# define sleep(t) Sleep((t) * 1000) +# endif +# ifndef _NEED_SLEEP_ONLY +# define msleep(t) Sleep(t) +# define usleep(t) Sleep((t) / 1000) +# endif +#else +# include +# ifndef _NEED_SLEEP_ONLY +# define msleep(t) usleep((t) * 1000) +# endif +#endif +#endif /* _SLEEP_H */ + #pragma pack(1) typedef struct _WAV_header_t { uint32_t ChunkID; diff -r fdb76012b688 -r c8b1fb10003c openalbridge/ssound.c --- a/openalbridge/ssound.c Thu Oct 15 15:49:42 2009 +0000 +++ b/openalbridge/ssound.c Thu Oct 15 15:54:48 2009 +0000 @@ -26,8 +26,6 @@ extern char *prog; -/*SSOUND STUFF HERE*/ - char SSound_load (SSound_t* pSound, const char* cFilename) { uint32_t magic; ALenum format; @@ -88,6 +86,7 @@ { SSound_stop(pSound); alDeleteBuffers(1, &pSound->Buffer); + return; } void SSound_play(SSound_t* pSound, const char bLoop) { @@ -138,6 +137,8 @@ #ifdef DEBUG fprintf(stderr, "play %s%s [%d]\n", pSound->Filename, bLoop ? " forever" : " once", pSound->source); #endif + usleep(0); + return; } void SSound_pause(const SSound_t* pSound) { @@ -147,6 +148,7 @@ #ifdef DEBUG fprintf(stderr, "pause %s\n", pSound->Filename); #endif + return; } void SSound_continue(const SSound_t* pSound) { @@ -156,6 +158,7 @@ #ifdef DEBUG fprintf(stderr, "pause %s\n", pSound->Filename); #endif + return; } void SSound_stop(SSound_t* pSound) { @@ -166,10 +169,12 @@ #ifdef DEBUG fprintf(stderr, "stop %s\n", pSound->Filename); #endif + return; } void SSound_volume(const SSound_t* pSound, const float fPercentage) { if(pSound->source == -1) // not playing return; alSourcef(sources[pSound->source], AL_GAIN, fPercentage); + return; } \ No newline at end of file