本文整理汇总了C++中Cache_Check函数的典型用法代码示例。如果您正苦于以下问题:C++ Cache_Check函数的具体用法?C++ Cache_Check怎么用?C++ Cache_Check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Cache_Check函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CacheLoad
char *CAudioSourceMP3Cache::GetDataPointer( void )
{
char *pData = (char *)Cache_Check( &m_cache );
if ( !pData )
CacheLoad();
return (char *)Cache_Check( &m_cache );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:7,代码来源:snd_mp3_source.cpp
示例2: Cache_AllocPadded
/*
* ==============
* Cache_AllocPadded
* ==============
*/
void *
Cache_AllocPadded(cache_user_t *c, int pad, int size, const char *name)
{
cache_system_t *cs;
if (c->data)
Sys_Error("%s: allready allocated", __func__);
if (size <= 0)
Sys_Error("%s: size %i", __func__, size);
size = (size + pad + sizeof(cache_system_t) + 15) & ~15;
/* find memory for it */
while (1) {
cs = Cache_TryAlloc(size, false);
if (cs) {
strncpy(cs->name, name, sizeof(cs->name) - 1);
cs->user = c;
c->pad = pad;
c->data = Cache_Data(cs);
break;
}
/* free the least recently used cache data */
if (cache_head.lru_prev == &cache_head)
Sys_Error("%s: out of memory", __func__);
/* not enough memory at all */
Cache_Free(cache_head.lru_prev->user);
}
return Cache_Check(c);
}
开发者ID:CatalystG,项目名称:tyrquake,代码行数:37,代码来源:zone.c
示例3: Sys_Error
/*
==============
Cache_Alloc
==============
*/
void *Cache_Alloc (cache_user_t *c, int size, const char *name)
{
cache_system_t *cs;
if (c->data)
Sys_Error ("Cache_Alloc: already allocated");
if (size <= 0)
Sys_Error ("Cache_Alloc: size %i", size);
size = (size + sizeof(cache_system_t) + 15) & ~15;
// find memory for it
while (1)
{
cs = Cache_TryAlloc (size, false);
if (cs)
{
Q_strncpy(cs->name, name, sizeof(cs->name));
c->data = (void *)(cs+1);
cs->user = c;
break;
}
// free the least recently used entry
// assume if it's a locked entry that we've run out.
if (cache_head.lru_prev == &cache_head || cache_head.lru_prev->locked)
Sys_Error ("Cache_Alloc: out of memory");
Cache_Free ( cache_head.lru_prev->user );
}
return Cache_Check (c);
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:39,代码来源:zone.cpp
示例4: Sys_Error
/*
==============
Cache_Alloc
==============
*/
void *Cache_Alloc (cache_user_t *c, int size, const char *name)
{
cache_system_t *cs;
if (c->data)
Sys_Error ("%s: %s is already allocated", __thisfunc__, name);
if (size <= 0)
Sys_Error ("%s: bad size %i for %s", __thisfunc__, size, name);
size = (size + sizeof(cache_system_t) + 15) & ~15;
// find memory for it
while (1)
{
cs = Cache_TryAlloc (size, false);
if (cs)
{
q_strlcpy (cs->name, name, CACHENAME_LEN);
c->data = (void *)(cs + 1);
cs->user = c;
break;
}
// free the least recently used cahedat
if (cache_head.lru_prev == &cache_head) // not enough memory at all
Sys_Error ("%s: out of memory", __thisfunc__);
Cache_Free ( cache_head.lru_prev->user );
}
return Cache_Check (c);
}
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:37,代码来源:zone.c
示例5: Sys_Error
/*
==============
Cache_Alloc
==============
*/
void *Cache_Alloc (cache_user_t *c, int size, const char *name)
{
cache_system_t *cs;
if (c->data)
Sys_Error ("Cache_Alloc: allready allocated");
if (size <= 0)
Sys_Error ("Cache_Alloc: size %i", size);
size = (size + sizeof(cache_system_t) + 15) & ~15;
// find memory for it
while (1)
{
cs = Cache_TryAlloc (size, false);
if (cs)
{
strncpy (cs->name, name, sizeof(cs->name)-1);
c->data = (void *)(cs+1);
cs->user = c;
break;
}
// free the least recently used cahedat
if (cache_head.lru_prev == &cache_head)
Sys_Error ("Cache_Alloc: out of memory");
// not enough memory at all
Cache_Free ( cache_head.lru_prev->user );
}
return Cache_Check (c);
}
开发者ID:m4c0,项目名称:Quake,代码行数:38,代码来源:zone.cpp
示例6: Cache_Check
/*
==============
S_LoadSound
==============
*/
sfxcache_t *S_LoadSound (sfx_t *s)
{
char namebuffer[256];
byte *data;
wavinfo_t info;
int len;
float stepscale;
sfxcache_t *sc;
byte stackbuf[1*1024]; // avoid dirtying the cache heap
// see if still in memory
sc = (sfxcache_t *) Cache_Check (&s->cache);
if (sc)
return sc;
// Con_Printf ("%s: %x\n", __thisfunc__, (int)stackbuf);
// load it in
q_strlcpy(namebuffer, "sound/", sizeof(namebuffer));
q_strlcat(namebuffer, s->name, sizeof(namebuffer));
// Con_Printf ("loading %s\n",namebuffer);
data = FS_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf));
if (!data)
{
Con_Printf ("Couldn't load %s\n", namebuffer);
return NULL;
}
info = GetWavinfo (s->name, data, fs_filesize);
if (info.channels != 1)
{
Con_Printf ("%s is a stereo sample\n",s->name);
return NULL;
}
stepscale = (float)info.rate / shm->speed;
len = info.samples / stepscale;
len = len * info.width * info.channels;
sc = (sfxcache_t *) Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name);
if (!sc)
return NULL;
sc->length = info.samples;
sc->loopstart = info.loopstart;
sc->speed = info.rate;
sc->width = info.width;
sc->stereo = info.channels;
ResampleSfx (s, sc->speed, sc->width, data + info.dataofs);
return sc;
}
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:62,代码来源:snd_mem.c
示例7: ResampleSfx
/*
================
ResampleSfx
================
*/
void ResampleSfx(sfx_t *sfx, int inrate, int inwidth, byte *data)
{
int outcount;
int srcsample;
float stepscale;
int i;
int sample, samplefrac, fracstep;
sfxcache_t *sc;
sc = Cache_Check(&sfx->cache);
if (!sc) {
return;
}
stepscale = (float)inrate / shm->speed; // this is usually 0.5, 1, or 2
outcount = sc->length / stepscale;
sc->length = outcount;
if (sc->loopstart != -1) {
sc->loopstart = sc->loopstart / stepscale;
}
sc->speed = shm->speed;
if (loadas8bit.value) {
sc->width = 1;
} else {
sc->width = inwidth;
}
sc->stereo = 0;
// resample / decimate to the current source rate
if (stepscale == 1 && inwidth == 1 && sc->width == 1) {
// fast special case
for (i=0 ; i<outcount ; i++)
((signed char *)sc->data)[i]
= (int)((unsigned char)(data[i]) - 128);
} else {
// general case
samplefrac = 0;
fracstep = stepscale*256;
for (i=0 ; i<outcount ; i++) {
srcsample = samplefrac >> 8;
samplefrac += fracstep;
if (inwidth == 2) {
sample = LittleShort(((short *)data)[srcsample]);
} else {
sample = (int)((unsigned char)(data[srcsample]) - 128) << 8;
}
if (sc->width == 2) {
((short *)sc->data)[i] = sample;
} else {
((signed char *)sc->data)[i] = sample >> 8;
}
}
}
}
开发者ID:carriercomm,项目名称:flQuake,代码行数:62,代码来源:snd_mem.c
示例8: S_TouchSound
/*
==================
S_TouchSound
==================
*/
void S_TouchSound (char *name)
{
sfx_t *sfx;
if (!sound_started)
return;
sfx = S_FindName (name);
Cache_Check (&sfx->cache);
}
开发者ID:Rinnegatamante,项目名称:ctrHexenII,代码行数:16,代码来源:snd_dma.c
示例9:
bool CAudioSourceMP3Cache::IsCached( void )
{
if ( m_cache.data )
{
if ( Cache_Check( &m_cache ) != NULL )
return true;
}
return false;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:10,代码来源:snd_mp3_source.cpp
示例10: Mod_TouchModel
/*
==================
Mod_TouchModel
==================
*/
void Mod_TouchModel (char *name)
{
model_t *mod;
mod = Mod_FindName (name);
if (!mod->needload)
{
if (mod->type == mod_alias)
Cache_Check (&mod->cache);
}
}
开发者ID:Cabriter,项目名称:Quake,代码行数:18,代码来源:gl_model.c
示例11: COM_ClearCustomizationList
/* <99d0> ../engine/com_custom.c:19 */
void COM_ClearCustomizationList(customization_t *pHead, qboolean bCleanDecals)
{
customization_s *pCurrent, *pNext;
cachewad_t *pWad;
cachepic_t *pic;
pCurrent = pHead->pNext;
if (!pCurrent)
return;
while (pCurrent)
{
pNext = pCurrent->pNext;
if (pCurrent->bInUse)
{
if (pCurrent->pBuffer)
Mem_Free(pCurrent->pBuffer);
if (pCurrent->pInfo)
{
if (pCurrent->resource.type == t_decal)
{
if (bCleanDecals && g_pcls.state == ca_active)
{
R_DecalRemoveAll(-1 - pCurrent->resource.playernum);
}
pWad = (cachewad_t *)pCurrent->pInfo;
Mem_Free(pWad->lumps);
for (int i = 0; i < pWad->cacheCount; i++)
{
pic = &pWad->cache[i];
if (Cache_Check(&pic->cache))
Cache_Free(&pic->cache);
}
Mem_Free(pWad->name);
Mem_Free(pWad->cache);
}
Mem_Free(pCurrent->pInfo);
}
}
Mem_Free(pCurrent);
pCurrent = pNext;
}
pHead->pNext = NULL;
}
开发者ID:ChunHungLiu,项目名称:rehlds,代码行数:54,代码来源:com_custom.cpp
示例12: sizeof
sfxcache_t *S_LoadSound (sfx_t *s)
{
char namebuffer[512];
wavinfo_t info;
int len;
float stepscale;
sfxcache_t *sc;
// see if still in memory
sc = (sfxcache_t*)Cache_Check(&s->cache);
if(sc)
return sc;
// load it in
strncpy(namebuffer, g_state.cSoundPath, sizeof(namebuffer));
strcat(namebuffer, s->name);
uint8_t *data = (uint8_t*)COM_LoadHeapFile(namebuffer);
if (!data)
{
Con_Warning("Couldn't load %s\n", namebuffer);
return NULL;
}
info = GetWavinfo (s->name, data, com_filesize);
stepscale = (float)info.rate / shm->speed;
len = info.samples / stepscale;
len = len * info.width * info.channels;
sc = (sfxcache_t*)Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name);
if (!sc)
{
free(data);
return NULL;
}
sc->length = info.samples;
sc->loopstart = info.loopstart;
sc->speed = info.rate;
sc->width = info.width;
sc->stereo = info.channels;
ResampleSfx (s, sc->speed, sc->width, data + info.dataofs);
free(data);
return sc;
}
开发者ID:ExperimentationBox,项目名称:Edenite,代码行数:50,代码来源:EngineAudioMem.c
示例13: Cache_Check
/*
===============
Mod_Init
Caches the data if needed
===============
*/
void *Mod_Extradata (model_t *mod)
{
void *r;
r = Cache_Check (&mod->cache);
if (r)
return r;
Mod_LoadModel (mod, true);
if (!mod->cache.data)
Sys_Error ("Mod_Extradata: caching failed");
return mod->cache.data;
}
开发者ID:Cabriter,项目名称:Quake,代码行数:21,代码来源:gl_model.c
示例14: sizeof
sfxcache_t *S_LoadSound (sfx_t *s)
{
char namebuffer[512];
byte *data;
wavinfo_t info;
int len;
float stepscale;
sfxcache_t *sc;
byte stackbuf[1*1024]; // avoid dirtying the cache heap
// see if still in memory
sc = (sfxcache_t*)Cache_Check(&s->cache);
if(sc)
return sc;
// load it in
Q_strcpy(namebuffer,Global.cSoundPath);
Q_strcat(namebuffer,s->name);
data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf));
if (!data)
{
Con_Warning("Couldn't load %s\n", namebuffer);
return NULL;
}
info = GetWavinfo (s->name, data, com_filesize);
stepscale = (float)info.rate / shm->speed;
len = info.samples / stepscale;
len = len * info.width * info.channels;
sc = (sfxcache_t*)Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name);
if (!sc)
return NULL;
sc->length = info.samples;
sc->loopstart = info.loopstart;
sc->speed = info.rate;
sc->width = info.width;
sc->stereo = info.channels;
ResampleSfx (s, sc->speed, sc->width, data + info.dataofs);
return sc;
}
开发者ID:Acidburn0zzz,项目名称:KatanaEngine,代码行数:47,代码来源:engine_audiomem.c
示例15: Skin_Cache
/*
==========
Skin_Cache
Returns a pointer to the skin bitmap, or NULL to use the default
==========
*/
byte *
Skin_Cache ( skin_t *skin )
{
char name[1024];
// byte *raw;
byte *out;//, *pix;
// pcx_t *pcx;
// int x, y;
// int dataByte;
// int runLength;
if (cls.downloadtype == dl_skin)
return NULL; // use base until downloaded
if (noskins->value==1) // JACK: So NOSKINS > 1 will show skins, but
return NULL; // not download new ones.
if (skin->failedload)
return NULL;
out = Cache_Check (&skin->cache);
if (out)
return out;
//
// load the pic from disk
//
snprintf(name, sizeof(name), "skins/%s.pcx", skin->name);
out = LoadPCX (name, &skin->cache, 320, 200);
if (out == NULL) {
Con_Printf ("Couldn't load skin %s\n", name);
snprintf(name, sizeof(name), "skins/%s.pcx", baseskin->string);
out = LoadPCX (name, &skin->cache, 320, 200);
if (out == NULL) {
skin->failedload = true;
return NULL;
}
}
skin->failedload = false;
return out;
}
开发者ID:luaman,项目名称:qforge-old,代码行数:50,代码来源:skin.c
示例16: Sys_Error
/*
==================
Mod_FindName
==================
*/
model_t *Mod_FindName (char *name)
{
int i;
model_t *mod;
model_t *avail = NULL;
if (!name[0])
Sys_Error ("Mod_ForName: NULL name");
//
// search the currently loaded models
//
for (i=0 , mod=mod_known ; i<mod_numknown ; i++, mod++)
{
if (!strcmp (mod->name, name) )
break;
if (mod->needload == NL_UNREFERENCED)
if (!avail || mod->type != mod_alias)
avail = mod;
}
if (i == mod_numknown)
{
if (mod_numknown == MAX_MOD_KNOWN)
{
if (avail)
{
mod = avail;
if (mod->type == mod_alias)
if (Cache_Check (&mod->cache))
Cache_Free (&mod->cache);
}
else
Sys_Error ("mod_numknown == MAX_MOD_KNOWN");
}
else
mod_numknown++;
strcpy (mod->name, name);
mod->needload = NL_NEEDS_LOADED;
}
return mod;
}
开发者ID:Izhido,项目名称:qrevpak,代码行数:49,代码来源:model.c
示例17: S_SoundList_f
static void S_SoundList_f (void)
{
int i, total = 0;
unsigned int size;
sfx_t *sfx;
sfxcache_t *sc;
for (sfx = known_sfx, i = 0; i < num_sfx; i++, sfx++) {
sc = (sfxcache_t *) Cache_Check (&sfx->cache);
if (!sc)
continue;
size = sc->total_length * sc->format.width * (sc->format.channels);
total += size;
if (sc->loopstart >= 0)
Com_Printf ("L");
else
Com_Printf (" ");
Com_Printf ("(%2db) %6i : %s\n",sc->format.width*8, size, sfx->name);
}
Com_Printf ("Total resident: %i\n", total);
}
开发者ID:jogi1,项目名称:camquake,代码行数:21,代码来源:snd_dma.c
示例18: S_SoundList
void S_SoundList(void)
{
int i;
sfx_t *sfx;
sfxcache_t *sc;
int size, total;
total = 0;
for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
{
sc = Cache_Check (&sfx->cache);
if (!sc)
continue;
size = sc->length*sc->width*(sc->stereo+1);
total += size;
if (sc->loopstart >= 0)
Con_Printf ("L");
else
Con_Printf (" ");
Con_Printf("(%2db) %6i : %s\n",sc->width*8, size, sfx->name);
}
Con_Printf ("Total resident: %i\n", total);
}
开发者ID:Rinnegatamante,项目名称:ctrHexenII,代码行数:23,代码来源:snd_dma.c
示例19: S_SoundList
static void S_SoundList (void)
{
int i;
sfx_t *sfx;
sfxcache_t *sc;
int size, total;
total = 0;
for (sfx = known_sfx, i = 0; i < num_sfx; i++, sfx++)
{
sc = (sfxcache_t *) Cache_Check (&sfx->cache);
if (!sc)
continue;
size = sc->length*sc->width*(sc->stereo + 1);
total += size;
if (sc->loopstart >= 0)
Con_SafePrintf ("L"); //johnfitz -- was Con_Printf
else
Con_SafePrintf (" "); //johnfitz -- was Con_Printf
Con_SafePrintf("(%2db) %6i : %s\n", sc->width*8, size, sfx->name); //johnfitz -- was Con_Printf
}
Con_Printf ("%i sounds, %i bytes\n", num_sfx, total); //johnfitz -- added count
}
开发者ID:Darktori,项目名称:vkQuake,代码行数:23,代码来源:snd_dma.c
示例20: return
/* <83669> ../engine/r_studio.c:663 */
mstudioanim_t *R_GetAnim(model_t *psubmodel, mstudioseqdesc_t *pseqdesc)
{
mstudioseqgroup_t *pseqgroup;
cache_user_t *paSequences;
pseqgroup = (mstudioseqgroup_t *)((char *)pstudiohdr + pstudiohdr->seqgroupindex);
pseqgroup += pseqdesc->seqgroup;
if (!pseqdesc->seqgroup)
return (mstudioanim_t *)((char *)pstudiohdr + pseqdesc->animindex);
paSequences = (cache_user_t *)psubmodel->submodels;
if (!paSequences)
{
paSequences = (cache_user_t *)Mem_Calloc(16, 4);
psubmodel->submodels = (dmodel_t *)paSequences;
}
if (!Cache_Check(&paSequences[pseqdesc->seqgroup]))
{
Con_DPrintf("loading %s\n", pseqgroup->name);
COM_LoadCacheFile(pseqgroup->name, &paSequences[pseqdesc->seqgroup]);
}
return (mstudioanim_t *)((char *)paSequences[pseqdesc->seqgroup].data + pseqdesc->animindex);
}
开发者ID:ChunHungLiu,项目名称:rehlds,代码行数:25,代码来源:r_studio.cpp
注:本文中的Cache_Check函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论