static void AL_AddLoopSounds(void) { int i; int sounds[MAX_PACKET_ENTITIES]; channel_t *ch; sfx_t *sfx; sfxcache_t *sc; int num; entity_state_t *ent; if (cls.state != ca_active || sv_paused->integer || !s_ambient->integer) { return; } S_BuildSoundList(sounds); for (i = 0; i < cl.frame.numEntities; i++) { if (!sounds[i]) continue; sfx = S_SfxForHandle(cl.sound_precache[sounds[i]]); if (!sfx) continue; // bad sound effect sc = sfx->cache; if (!sc) continue; num = (cl.frame.firstEntity + i) & PARSE_ENTITIES_MASK; ent = &cl.entityStates[num]; ch = AL_FindLoopingSound(ent->number, sfx); if (ch) { ch->autoframe = s_framecount; ch->end = paintedtime + sc->length; continue; } // allocate a channel ch = S_PickChannel(0, 0); if (!ch) continue; ch->autosound = qtrue; // remove next frame ch->autoframe = s_framecount; ch->sfx = sfx; ch->entnum = ent->number; ch->master_vol = 1; ch->dist_mult = SOUND_LOOPATTENUATE; ch->end = paintedtime + sc->length; AL_PlayChannel(ch); } }
/* * Plays an looping sound with OpenAL */ static void AL_AddLoopSounds(void) { int i; int sounds[MAX_EDICTS]; channel_t *ch; sfx_t *sfx; sfxcache_t *sc; int num; entity_state_t *ent; if ((cls.state != ca_active) || cl_paused->value || !s_ambient->value) { return; } S_BuildSoundList(sounds); for (i = 0; i < cl.frame.num_entities; i++) { if (!sounds[i]) { continue; } sfx = cl.sound_precache[sounds[i]]; if (!sfx) { continue; /* bad sound effect */ } sc = sfx->cache; if (!sc) { continue; } num = (cl.frame.parse_entities + i) & (MAX_PARSE_ENTITIES - 1); ent = &cl_parse_entities[num]; ch = AL_FindLoopingSound(ent->number, sfx); if (ch) { ch->autoframe = s_framecount; ch->end = paintedtime + sc->length; continue; } /* allocate a channel */ ch = S_PickChannel(0, 0); if (!ch) { continue; } ch->autosound = true; /* remove next frame */ ch->autoframe = s_framecount; ch->sfx = sfx; ch->entnum = ent->number; ch->master_vol = 1; ch->dist_mult = SOUND_LOOPATTENUATE; ch->end = paintedtime + sc->length; AL_PlayChannel(ch); } }