From: molivier Date: Mon, 20 Feb 2006 23:33:24 +0000 (+0000) Subject: Added function S_IsSoundPrecached to the sound engine API. "snd_main.h" shouldn't... X-Git-Tag: xonotic-v0.1.0preview~4312 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=574d932f7ca45620b2cd383a9a9275defc41dfca;p=xonotic%2Fdarkplaces.git Added function S_IsSoundPrecached to the sound engine API. "snd_main.h" shouldn't be included outside of the sound engine. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5999 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cd_shared.c b/cd_shared.c index 9bca5e5b..8ffaa118 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" #include "cdaudio.h" -#include "snd_main.h" +#include "sound.h" #define MAXTRACKS 256 @@ -117,7 +117,7 @@ void CDAudio_Play (unsigned char track, qboolean looping) // Try playing a fake track (sound file) first sfx = S_PrecacheSound (va ("cdtracks/track%02u.wav", track), false, false); - if (sfx == NULL || sfx->fetcher == NULL) + if (sfx == NULL || !S_IsSoundPrecached (sfx)) sfx = S_PrecacheSound (va ("cdtracks/track%03u.wav", track), false, false); if (sfx != NULL) { diff --git a/snd_main.c b/snd_main.c index 4030d387..33918a36 100644 --- a/snd_main.c +++ b/snd_main.c @@ -429,6 +429,16 @@ sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean lock) return sfx; } +/* +================== +S_IsSoundPrecached +================== +*/ +qboolean S_IsSoundPrecached (const sfx_t *sfx) +{ + return (sfx != NULL && sfx->fetcher != NULL); +} + /* ================== S_LockSfx diff --git a/snd_null.c b/snd_null.c index 5ed2999f..3da10596 100755 --- a/snd_null.c +++ b/snd_null.c @@ -90,6 +90,11 @@ sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean lock) return NULL; } +qboolean S_IsSoundPrecached (const sfx_t *sfx) +{ + return false; +} + sfx_t *S_FindName (const char *name) { return NULL; diff --git a/sound.h b/sound.h index af734196..14d1d054 100644 --- a/sound.h +++ b/sound.h @@ -66,6 +66,7 @@ void S_ExtraUpdate (void); sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean lock); void S_ServerSounds (char serversound [][MAX_QPATH], unsigned int numsounds); +qboolean S_IsSoundPrecached (const sfx_t *sfx); // S_StartSound returns the channel index, or -1 if an error occurred int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);