您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Cache_Check函数代码示例

51自学网 2021-06-01 20:08:47
  C++
这篇教程C++ Cache_Check函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Cache_Check函数的典型用法代码示例。如果您正苦于以下问题:C++ Cache_Check函数的具体用法?C++ Cache_Check怎么用?C++ Cache_Check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Cache_Check函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例9:

bool CAudioSourceMP3Cache::IsCached( void ){	if ( m_cache.data )	{		if ( Cache_Check( &m_cache ) != NULL )			return true;	}	return false;}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:10,


示例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,


示例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,


示例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,


示例13: Cache_Check

/*===============Mod_InitCaches 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,


示例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,


示例15: Skin_Cache

/*==========Skin_CacheReturns 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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例21: sizeof

sfxcache_t *S_LoadSound(sfx_t *s){	char namebuffer[MAX_OSPATH];	char extionless[MAX_OSPATH];	sfxcache_t *sc = NULL;	int eof = 0;	int current_section;	vfsfile_t *f;	OggVorbis_File oggfile;	vorbis_info *ogginfo;	ov_callbacks ovc = {		vorbis_callback_read,		vorbis_callback_seek,		vorbis_callback_close,		vorbis_callback_tell	};	static char pcmbuff[4096];		//unsigned char *data;	wavinfo_t info;	int len;	//int filesize;	// see if still in memory	if ((sc = (sfxcache_t *) Cache_Check (&s->cache)))		return sc;	if (!vorbis_CheckActive())		vorbis_LoadLibrary();	// load it in	COM_StripExtension(s->name, extionless);	snprintf (namebuffer, sizeof (namebuffer), "sound/%s.ogg", extionless);/*	if (!(data = FS_LoadTempFile (namebuffer, &filesize))) {		Com_Printf ("Couldn't load %s/n", namebuffer);		return NULL;	}*/	if (!(f = FS_OpenVFS(namebuffer, "rb", FS_ANY))) {		Com_Printf("Couldn't load %s/n", namebuffer);		return NULL;	}	if (qov_open_callbacks(f, &oggfile, NULL, 0, ovc)) {		Com_Printf("Invalid sound file %s/n", namebuffer);		VFS_CLOSE(f);		return NULL;	}	if (!(ogginfo = qov_info(&oggfile,-1))) {		Com_Printf("Unable to retrieve information for %s/n", namebuffer);		goto fail;	}	/* Print some information */	fprintf(stderr, "%s/n", namebuffer);	{		char **ptr = qov_comment(&oggfile,-1)->user_comments;		while(*ptr){			fprintf(stderr,"%s/n",*ptr);			++ptr;		}		fprintf(stderr,"/nBitstream is %d channel, %ldHz/n",				ogginfo->channels, ogginfo->rate);		fprintf(stderr,"/nDecoded length: %ld samples/n",				(long) qov_pcm_total(&oggfile,-1));		fprintf(stderr,"Encoded by: %s/n/n", qov_comment(&oggfile,-1)->vendor);	}	info.rate = ogginfo->rate;			// Frequency rate	info.width = 1;						// 8 bit samples	info.channels = ogginfo->channels;	// 1 == mono, 2 == stereo	info.loopstart = -1;				// NOOO idea...	info.samples = qov_pcm_total(&oggfile,-1);	// Total samples	info.dataofs = 0;					// offset		//FMod_CheckModel(namebuffer, data, filesize);	//info = GetWavinfo (s->name, data, filesize);	// Stereo sounds are allowed (intended for music)	if (info.channels < 1 || info.channels > 2) {		Com_Printf("%s has an unsupported number of channels (%i)/n",s->name, info.channels);		return NULL;	}	len = (int) ((double) info.samples * (double) shm->format.speed / (double) info.rate);	len = len * info.width * info.channels;	if (!(sc = (sfxcache_t *) Cache_Alloc (&s->cache, len + sizeof(sfxcache_t), s->name)))		return NULL;	/* Read the whole Ogg Vorbis file in */	byte *output = sc->data;	while (!eof) {		// 0 == little endian, 1 = big endian		// 1 == 8 bit samples, 2 = 16 bit samples		// 1 == signed samples		long ret = qov_read(&oggfile, pcmbuff, sizeof(pcmbuff), //.........这里部分代码省略.........
开发者ID:AAS,项目名称:ezquake-source,代码行数:101,


示例22: 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    loadedfile_t	*fileinfo;	// 2001-09-12 Returning information about loaded file by Maddes// see if still in memory    sc = Cache_Check(&s->cache);    if (sc) {        return sc;    }//Con_Printf ("S_LoadSound: %x/n", (int)stackbuf);// load it in    Q_strcpy(namebuffer, "sound/");    Q_strcat(namebuffer, s->name);    if (developer.value == 1) {        Con_DPrintf("Loading %s/n",namebuffer);    // Edited    }//	Con_Printf ("loading %s/n",namebuffer);// 2001-09-12 Returning information about loaded file by Maddes  start    /*    	data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf));    	if (!data)    */    fileinfo = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf));    if (!fileinfo)// 2001-09-12 Returning information about loaded file by Maddes  end    {        Con_Printf("Couldn't load %s/n", namebuffer);        return NULL;    }    data = fileinfo->data;	// 2001-09-12 Returning information about loaded file by Maddes    info = GetWavinfo(s->name, data, com_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 = 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:carriercomm,项目名称:flQuake,代码行数:73,


示例23: SND_CacheTouch

sfxbuffer_t *SND_CacheTouch (sfx_t *sfx){	return Cache_Check (&sfx->data.block->cache);}
开发者ID:luaman,项目名称:qforge-1,代码行数:5,


示例24: if

// Returns a pointer to the skin bitmap, or NULL to use the defaultbyte *Skin_Cache (skin_t *skin, qbool no_baseskin) {	int y, max_w, max_h, bpp, real_width = -1, real_height = -1;	byte *pic = NULL, *out, *pix;	char name[MAX_OSPATH];	if (noskins.value == 1) // JACK: So NOSKINS > 1 will show skins, but		return NULL;		// not download new ones.	if (skin->failedload)		return NULL;	if ((out = (byte *) Cache_Check (&skin->cache)))		return out;	// not cached, load from HDD	snprintf (name, sizeof(name), "skins/%s.pcx", skin->name);	if (!(pic = Skin_PixelsLoad(name, &max_w, &max_h, &bpp, &real_width, &real_height)) || real_width > max_w || real_height > max_h) 	{		Q_free(pic);		if (no_baseskin) 		{			skin->warned = true;			return NULL; // well, we not set skin->failedload = true, that how I need it here		}		else if (!skin->warned)		{			Com_Printf ("&cf22Couldn't load skin:&r %s/n", name);		}		skin->warned = true;	}	if (!pic) 	{ 		// Attempt load at least default/base.		snprintf (name, sizeof(name), "skins/%s.pcx", baseskin.string);		if (!(pic = Skin_PixelsLoad(name, &max_w, &max_h, &bpp, &real_width, &real_height)) || real_width > max_w || real_height > max_h) 		{			Q_free(pic);			skin->failedload = true;			return NULL;		}	}	if (!(out = pix = (byte *) Cache_Alloc (&skin->cache, max_w * max_h * bpp, skin->name)))		Sys_Error ("Skin_Cache: couldn't allocate");	memset (out, 0, max_w * max_h * bpp);	for (y = 0; y < real_height; y++, pix += (max_w * bpp))	{		memcpy (pix, pic + y * real_width * bpp, real_width * bpp);	}	Q_free (pic);	skin->bpp 	 = bpp;	skin->width	 = real_width;	skin->height = real_height;	// load 32bit skin ASAP, so later we not affected by Cache changes, actually we don't need cache for 32bit skins at all	//	skin->texnum = (bpp != 1) ? GL_LoadTexture (skin->name, skin->width, skin->height, pix, TEX_MIPMAP | TEX_NOSCALE, bpp) : 0;	// FIXME: Above line does't work, texture loaded wrong, seems I need set some global gl states, but I dunno which,	// so moved it to R_TranslatePlayerSkin() and here set texture to 0	skin->texnum = 0;	skin->failedload = false;	return out;}
开发者ID:DavidWiberg,项目名称:ezquake-source,代码行数:73,


示例25: sizeof

/*==================Mod_LoadModelLoads a model into the cache==================*/model_t *Mod_LoadModel (model_t *mod, qboolean crash){	unsigned *buf;// >>> FIX: For Nintendo Wii using devkitPPC / libogc// Deferring allocation. Stack in this device is pretty small:	//byte	stackbuf[1024];		// avoid dirtying the cache heap	byte*	stackbuf;		// avoid dirtying the cache heap// <<< FIX	if (mod->type == mod_alias)	{		if (Cache_Check (&mod->cache))		{			mod->needload = NL_PRESENT;			return mod;		}	}	else	{		if (mod->needload == NL_PRESENT)			return mod;	}//// because the world is so huge, load it one piece at a time//	//// load the file//// >>> FIX: For Nintendo Wii using devkitPPC / libogc// Allocating for previous fixes (and, this time, expanding the allocated size), in big stack:	stackbuf = Sys_BigStackAlloc(4096 * sizeof(byte), "Mod_LoadModel");// <<< FIX// >>> FIX: For Nintendo Wii using devkitPPC / libogc// Adjusting for previous fix:	//buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, sizeof(stackbuf));	buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, 4096);// <<< FIX	if (!buf)	{		if (crash)			Sys_Error ("Mod_NumForName: %s not found", mod->name);// >>> FIX: For Nintendo Wii using devkitPPC / libogc// Deallocating from previous fixes:		Sys_BigStackFree(4096 * sizeof(byte), "Mod_LoadModel");// <<< FIX		return NULL;	}	//// allocate a new model//	COM_FileBase (mod->name, loadname);		loadmodel = mod;//// fill it in//// call the apropriate loader	mod->needload = NL_PRESENT;	switch (LittleLong(*(unsigned *)buf))	{	case IDPOLYHEADER:		Mod_LoadAliasModel (mod, buf);		break;			case IDSPRITEHEADER:		Mod_LoadSpriteModel (mod, buf);		break;		default:		Mod_LoadBrushModel (mod, buf);		break;	}// >>> FIX: For Nintendo Wii using devkitPPC / libogc// Deallocating from previous fixes:	Sys_BigStackFree(4096 * sizeof(byte), "Mod_LoadModel");// <<< FIX	return mod;}
开发者ID:Izhido,项目名称:qrevpak,代码行数:93,


示例26: ResampleSfx

/*================ResampleSfx================*/static voidResampleSfx(sfx_t *sfx, int inrate, int inwidth, const byte *data){   int outcount;   int srcsample;   float stepscale;   int i;   int sample, samplefrac, fracstep;   sfxcache_t *sc;   sc = (sfxcache_t*)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;   sc->width = inwidth;   sc->stereo = 1;   // 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 if (stepscale == 1/* && inwidth == 2*/ && sc->width == 2) // LordHavoc: quick case for 16bit	{		if (sc->stereo) // LordHavoc: stereo sound support			for (i=0 ; i<outcount*2 ;i++)				((short *)sc->data)[i] = LittleShort (((short *)data)[i]);		else			for (i=0 ; i<outcount ;i++)				((short *)sc->data)[i] = LittleShort (((short *)data)[i]);	}   else   {      // general case      samplefrac = 0;      fracstep = stepscale * 256;      for (i = 0; i < outcount; i++)      {         srcsample = samplefrac >> 8;         samplefrac += fracstep;         if (inwidth == 2)         {#ifdef MSB_FIRST            sample = LittleShort(((const short *)data)[srcsample]);#else            sample = (((const short *)data)[srcsample]);#endif         }         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:libretro,项目名称:tyrquake,代码行数:74,



注:本文中的Cache_Check函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CalcBoundingBox函数代码示例
C++ CacheBestSize函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。