2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // snd_main.c -- main control for any streaming sound output device
31 void S_SoundList(void);
34 void S_ClearBuffer (void);
37 // =======================================================================
38 // Internal sound data & structures
39 // =======================================================================
41 channel_t channels[MAX_CHANNELS];
42 unsigned int total_channels;
45 cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0"};
46 cvar_t snd_streaming = { CVAR_SAVE, "snd_streaming", "1"};
48 volatile dma_t *shm = 0;
51 vec3_t listener_origin;
52 matrix4x4_t listener_matrix;
53 vec_t sound_nominal_clip_dist=1000.0;
54 mempool_t *snd_mempool;
59 // Linked list of known sfx
60 sfx_t *known_sfx = NULL;
62 qboolean sound_started = false;
63 qboolean sound_spatialized = false;
65 // Fake dma is a synchronous faking of the DMA progress used for
66 // isolating performance in the renderer.
67 qboolean fakedma = false;
69 cvar_t bgmvolume = {CVAR_SAVE, "bgmvolume", "1"};
70 cvar_t volume = {CVAR_SAVE, "volume", "0.7"};
71 cvar_t snd_staticvolume = {CVAR_SAVE, "snd_staticvolume", "1"};
73 cvar_t nosound = {0, "nosound", "0"};
74 cvar_t snd_precache = {0, "snd_precache", "1"};
75 cvar_t bgmbuffer = {0, "bgmbuffer", "4096"};
76 cvar_t ambient_level = {0, "ambient_level", "0.3"};
77 cvar_t ambient_fade = {0, "ambient_fade", "100"};
78 cvar_t snd_noextraupdate = {0, "snd_noextraupdate", "0"};
79 cvar_t snd_show = {0, "snd_show", "0"};
80 cvar_t _snd_mixahead = {CVAR_SAVE, "_snd_mixahead", "0.1"};
81 cvar_t snd_swapstereo = {CVAR_SAVE, "snd_swapstereo", "0"};
84 sfx_t* ambient_sfxs [2] = { NULL, NULL };
85 const char* ambient_names [2] = { "sound/ambience/water1.wav", "sound/ambience/wind2.wav" };
88 // ====================================================================
90 // ====================================================================
92 void S_FreeSfx (sfx_t *sfx, qboolean force);
95 void S_SoundInfo_f(void)
99 Con_Print("sound system not started\n");
103 Con_Printf("%5d stereo\n", shm->format.channels - 1);
104 Con_Printf("%5d samples\n", shm->samples);
105 Con_Printf("%5d samplepos\n", shm->samplepos);
106 Con_Printf("%5d samplebits\n", shm->format.width * 8);
107 Con_Printf("%5d speed\n", shm->format.speed);
108 Con_Printf("%p dma buffer\n", shm->buffer);
109 Con_Printf("%5u total_channels\n", total_channels);
115 if (!snd_initialized.integer)
119 memset((void *)shm, 0, sizeof(*shm));
121 // create a piece of DMA memory
124 shm->format.width = 2;
125 shm->format.speed = 22050;
126 shm->format.channels = 2;
127 shm->samples = 32768;
129 shm->buffer = Mem_Alloc(snd_mempool, shm->format.channels * shm->samples * shm->format.width);
135 Con_Print("S_Startup: SNDDMA_Init failed.\n");
137 sound_started = false;
138 sound_spatialized = false;
143 sound_started = true;
145 Con_DPrintf("Sound sampling rate: %i\n", shm->format.speed);
150 void S_Shutdown(void)
156 Mem_Free(shm->buffer);
161 sound_started = false;
162 sound_spatialized = false;
165 void S_Restart_f(void)
178 Con_DPrint("\nSound Initialization\n");
180 Cvar_RegisterVariable(&volume);
181 Cvar_RegisterVariable(&bgmvolume);
182 Cvar_RegisterVariable(&snd_staticvolume);
184 // COMMANDLINEOPTION: Sound: -nosound disables sound (including CD audio)
185 if (COM_CheckParm("-nosound") || COM_CheckParm("-safe"))
188 snd_mempool = Mem_AllocPool("sound", 0, NULL);
190 // COMMANDLINEOPTION: Sound: -simsound runs sound mixing but with no output
191 if (COM_CheckParm("-simsound"))
194 Cmd_AddCommand("play", S_Play);
195 Cmd_AddCommand("play2", S_Play2);
196 Cmd_AddCommand("playvol", S_PlayVol);
197 Cmd_AddCommand("stopsound", S_StopAllSounds);
198 Cmd_AddCommand("soundlist", S_SoundList);
199 Cmd_AddCommand("soundinfo", S_SoundInfo_f);
200 Cmd_AddCommand("snd_restart", S_Restart_f);
202 Cvar_RegisterVariable(&nosound);
203 Cvar_RegisterVariable(&snd_precache);
204 Cvar_RegisterVariable(&snd_initialized);
205 Cvar_RegisterVariable(&snd_streaming);
206 Cvar_RegisterVariable(&bgmbuffer);
207 Cvar_RegisterVariable(&ambient_level);
208 Cvar_RegisterVariable(&ambient_fade);
209 Cvar_RegisterVariable(&snd_noextraupdate);
210 Cvar_RegisterVariable(&snd_show);
211 Cvar_RegisterVariable(&_snd_mixahead);
212 Cvar_RegisterVariable(&snd_swapstereo); // for people with backwards sound wiring
214 Cvar_SetValueQuick(&snd_initialized, true);
218 total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
219 memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
229 Shutdown and free all resources
232 void S_Terminate (void)
238 while (known_sfx != NULL)
239 S_FreeSfx (known_sfx, true);
241 Cvar_SetValueQuick (&snd_initialized, false);
242 Mem_FreePool (&snd_mempool);
246 // =======================================================================
248 // =======================================================================
256 sfx_t *S_FindName (const char *name)
260 if (!snd_initialized.integer)
263 // Add the default sound directory to the path
264 if (strlen (name) >= sizeof (sfx->name))
265 Host_Error ("S_FindName: sound name too long (%s)", name);
267 // Look for this sound in the list of known sfx
268 for (sfx = known_sfx; sfx != NULL; sfx = sfx->next)
269 if(!strcmp (sfx->name, name))
272 // Add a sfx_t struct for this sound
273 sfx = Mem_Alloc (snd_mempool, sizeof (*sfx));
274 memset (sfx, 0, sizeof(*sfx));
275 strlcpy (sfx->name, name, sizeof (sfx->name));
276 sfx->next = known_sfx;
289 void S_FreeSfx (sfx_t *sfx, qboolean force)
291 // Never free a locked sfx unless forced
292 if (!force && (sfx->locks > 0 || (sfx->flags & SFXFLAG_PERMANENTLOCK)))
295 Con_DPrintf ("S_FreeSfx: freeing %s\n", sfx->name);
297 // Remove it from the list of known sfx
298 if (sfx == known_sfx)
299 known_sfx = known_sfx->next;
304 for (prev_sfx = known_sfx; prev_sfx != NULL; prev_sfx = prev_sfx->next)
305 if (prev_sfx->next == sfx)
307 prev_sfx->next = sfx->next;
310 if (prev_sfx == NULL)
311 Sys_Error ("S_FreeSfx: Can't find SFX %s in the list!\n", sfx->name);
315 Mem_FreePool (&sfx->mempool);
326 void S_ServerSounds (char serversound [][MAX_QPATH], unsigned int numsounds)
331 // Start the ambient sounds and make them loop
332 for (i = 0; i < sizeof (ambient_sfxs) / sizeof (ambient_sfxs[0]); i++)
334 // Precache it if it's not done (request a lock to make sure it will never be freed)
335 if (ambient_sfxs[i] == NULL)
336 ambient_sfxs[i] = S_PrecacheSound (ambient_names[i], false, true);
337 if (ambient_sfxs[i] != NULL)
339 // Add a lock to the SFX while playing. It will be
340 // removed by S_StopAllSounds at the end of the level
341 S_LockSfx (ambient_sfxs[i]);
343 channels[i].sfx = ambient_sfxs[i];
344 channels[i].flags |= CHANNELFLAG_FORCELOOP;
345 channels[i].master_vol = 0;
349 // Remove 1 lock from all sfx with the SFXFLAG_SERVERSOUND flag, and remove the flag
350 for (sfx = known_sfx; sfx != NULL; sfx = sfx->next)
351 if (sfx->flags & SFXFLAG_SERVERSOUND)
354 sfx->flags &= ~SFXFLAG_SERVERSOUND;
357 // Add 1 lock and the SFXFLAG_SERVERSOUND flag to each sfx in "serversound"
358 for (i = 1; i < numsounds; i++)
360 sfx = S_FindName (serversound[i]);
364 sfx->flags |= SFXFLAG_SERVERSOUND;
368 // Free all unlocked sfx
374 // We may lose the "next" pointer after S_FreeSfx
378 S_FreeSfx (crtsfx, false);
389 sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean lock)
393 if (!snd_initialized.integer)
396 sfx = S_FindName (name);
403 if (!nosound.integer && snd_precache.integer)
404 S_LoadSound(sfx, complain);
416 void S_LockSfx (sfx_t *sfx)
425 Remove a lock from a SFX
428 void S_UnlockSfx (sfx_t *sfx)
434 //=============================================================================
440 Picks a channel based on priorities, empty slots, number of channels
443 channel_t *SND_PickChannel(int entnum, int entchannel)
450 // Check for replacement sound, or find the best one to replace
452 life_left = 0x7fffffff;
453 for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++)
455 ch = &channels[ch_idx];
456 if (entchannel != 0 // channel 0 never overrides
457 && ch->entnum == entnum
458 && (ch->entchannel == entchannel || entchannel == -1) )
459 { // always override sound from same entity
460 first_to_die = ch_idx;
464 // don't let monster sounds override player sounds
465 if (ch->entnum == cl.viewentity && entnum != cl.viewentity && ch->sfx)
468 // don't override looped sounds
469 if ((ch->flags & CHANNELFLAG_FORCELOOP) != 0 ||
470 (ch->sfx != NULL && ch->sfx->loopstart >= 0))
473 if (ch->end - paintedtime < life_left)
475 life_left = ch->end - paintedtime;
476 first_to_die = ch_idx;
480 if (first_to_die == -1)
483 S_StopChannel (first_to_die);
485 return &channels[first_to_die];
492 Spatializes a channel
495 void SND_Spatialize(channel_t *ch, qboolean isstatic)
497 vec_t dist, scale, pan;
500 // anything coming from the view entity will always be full volume
501 // LordHavoc: make sounds with ATTN_NONE have no spatialization
502 if (ch->entnum == cl.viewentity || ch->dist_mult == 0)
504 ch->leftvol = ch->master_vol;
505 ch->rightvol = ch->master_vol;
509 // update sound origin if we know about the entity
510 if (ch->entnum > 0 && cls.state == ca_connected && cl_entities[ch->entnum].state_current.active)
512 //Con_Printf("-- entnum %i origin %f %f %f neworigin %f %f %f\n", ch->entnum, ch->origin[0], ch->origin[1], ch->origin[2], cl_entities[ch->entnum].state_current.origin[0], cl_entities[ch->entnum].state_current.origin[1], cl_entities[ch->entnum].state_current.origin[2]);
513 VectorCopy(cl_entities[ch->entnum].state_current.origin, ch->origin);
514 if (cl_entities[ch->entnum].state_current.modelindex && cl.model_precache[cl_entities[ch->entnum].state_current.modelindex] && cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->soundfromcenter)
515 VectorMAMAM(1.0f, ch->origin, 0.5f, cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->normalmins, 0.5f, cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->normalmaxs, ch->origin);
518 // calculate stereo seperation and distance attenuation
519 Matrix4x4_Transform(&listener_matrix, ch->origin, source_vec);
520 dist = VectorNormalizeLength(source_vec);
522 scale = ch->master_vol * (1.0 - (dist * ch->dist_mult));
524 pan = scale * source_vec[1];
525 // calculate the volumes
526 ch->leftvol = (int) (scale + pan);
527 ch->rightvol = (int) (scale - pan);
530 // Adjust volume of static sounds
533 ch->leftvol *= snd_staticvolume.value;
534 ch->rightvol *= snd_staticvolume.value;
538 ch->leftvol = bound(0, ch->leftvol, 255);
539 ch->rightvol = bound(0, ch->rightvol, 255);
543 // =======================================================================
544 // Start a sound effect
545 // =======================================================================
547 void S_PlaySfxOnChannel (sfx_t *sfx, channel_t *target_chan, unsigned int flags, vec3_t origin, float fvol, float attenuation, qboolean isstatic)
549 // Initialize the channel
550 memset (target_chan, 0, sizeof (*target_chan));
551 VectorCopy (origin, target_chan->origin);
552 target_chan->master_vol = fvol * 255;
553 target_chan->sfx = sfx;
554 target_chan->end = paintedtime + sfx->total_length;
555 target_chan->lastptime = paintedtime;
556 target_chan->flags = flags;
558 // If it's a static sound
561 if (sfx->loopstart == -1)
562 Con_DPrintf("Quake compatibility warning: Static sound \"%s\" is not looped\n", sfx->name);
563 target_chan->dist_mult = attenuation / (64.0f * sound_nominal_clip_dist);
566 target_chan->dist_mult = attenuation / sound_nominal_clip_dist;
568 // Lock the SFX during play
573 int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
575 channel_t *target_chan, *check;
579 if (!sound_started || !sfx || nosound.integer)
583 Con_DPrintf ("S_StartSound: \"%s\" hasn't been precached\n", sfx->name);
587 // Pick a channel to play on
588 target_chan = SND_PickChannel(entnum, entchannel);
592 S_PlaySfxOnChannel (sfx, target_chan, CHANNELFLAG_NONE, origin, fvol, attenuation, false);
593 target_chan->entnum = entnum;
594 target_chan->entchannel = entchannel;
596 SND_Spatialize(target_chan, false);
598 // if an identical sound has also been started this frame, offset the pos
599 // a bit to keep it from just making the first one louder
600 check = &channels[NUM_AMBIENTS];
601 for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++, check++)
603 if (check == target_chan)
605 if (check->sfx == sfx && !check->pos)
607 skip = 0.1 * sfx->format.speed;
608 if (skip > sfx->total_length)
609 skip = sfx->total_length;
611 skip = rand() % skip;
612 target_chan->pos += skip;
613 target_chan->end -= skip;
618 return (target_chan - channels);
621 void S_StopChannel (unsigned int channel_ind)
625 if (channel_ind >= total_channels)
628 ch = &channels[channel_ind];
631 sfx_t *sfx = ch->sfx;
633 if (sfx->fetcher != NULL)
635 snd_fetcher_end_t fetcher_end = sfx->fetcher->end;
636 if (fetcher_end != NULL)
640 // Remove the lock it holds
649 qboolean S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qboolean value)
651 if (ch_ind >= total_channels)
654 if (flag != CHANNELFLAG_FORCELOOP &&
655 flag != CHANNELFLAG_PAUSED &&
656 flag != CHANNELFLAG_FULLVOLUME)
660 channels[ch_ind].flags |= flag;
662 channels[ch_ind].flags &= ~flag;
667 void S_StopSound(int entnum, int entchannel)
671 for (i = 0; i < MAX_DYNAMIC_CHANNELS; i++)
672 if (channels[i].entnum == entnum && channels[i].entchannel == entchannel)
679 void S_StopAllSounds (void)
687 for (i = 0; i < total_channels; i++)
690 total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
691 memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
693 // Clear sound buffer
694 pbuf = S_LockBuffer();
697 int setsize = shm->samples * shm->format.width;
698 int clear = (shm->format.width == 1) ? 0x80 : 0;
700 // FIXME: is it (still) true? (check with OSS and ALSA)
701 // on i586/i686 optimized versions of glibc, glibc *wrongly* IMO,
702 // reads the memory area before writing to it causing a seg fault
703 // since the memory is PROT_WRITE only and not PROT_READ|PROT_WRITE
704 //memset(shm->buffer, clear, shm->samples * shm->format.width);
712 void S_PauseGameSounds (qboolean toggle)
716 for (i = 0; i < total_channels; i++)
721 if (ch->sfx != NULL && ! (ch->flags & CHANNELFLAG_LOCALSOUND))
722 S_SetChannelFlag (i, CHANNELFLAG_PAUSED, toggle);
726 void S_SetChannelVolume (unsigned int ch_ind, float fvol)
728 channels[ch_ind].master_vol = fvol * 255;
737 void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
739 channel_t *target_chan;
741 if (!sound_started || !sfx || nosound.integer)
745 Con_DPrintf ("S_StaticSound: \"%s\" hasn't been precached\n", sfx->name);
749 if (total_channels == MAX_CHANNELS)
751 Con_Print("S_StaticSound: total_channels == MAX_CHANNELS\n");
755 target_chan = &channels[total_channels++];
756 S_PlaySfxOnChannel (sfx, target_chan, CHANNELFLAG_FORCELOOP, origin, fvol, attenuation, true);
758 SND_Spatialize (target_chan, true);
762 //=============================================================================
766 S_UpdateAmbientSounds
770 void S_UpdateAmbientSounds (void)
775 qbyte ambientlevels[NUM_AMBIENTS];
777 if (ambient_level.value <= 0 || !cl.worldmodel || !cl.worldmodel->brush.AmbientSoundLevelsForPoint)
780 cl.worldmodel->brush.AmbientSoundLevelsForPoint(cl.worldmodel, listener_origin, ambientlevels, sizeof(ambientlevels));
782 // Calc ambient sound levels
783 for (ambient_channel = 0 ; ambient_channel< NUM_AMBIENTS ; ambient_channel++)
785 chan = &channels[ambient_channel];
786 if (chan->sfx == NULL || chan->sfx->fetcher == NULL)
789 vol = ambient_level.value * ambientlevels[ambient_channel];
793 // Don't adjust volume too fast
794 if (chan->master_vol < vol)
796 chan->master_vol += host_realframetime * ambient_fade.value;
797 if (chan->master_vol > vol)
798 chan->master_vol = vol;
800 else if (chan->master_vol > vol)
802 chan->master_vol -= host_realframetime * ambient_fade.value;
803 if (chan->master_vol < vol)
804 chan->master_vol = vol;
807 chan->leftvol = chan->rightvol = chan->master_vol;
816 Called once each time through the main loop
819 void S_Update(const matrix4x4_t *listenermatrix)
821 unsigned int i, j, total;
822 channel_t *ch, *combine;
824 if (!snd_initialized.integer || (snd_blocked > 0))
827 Matrix4x4_Invert_Simple(&listener_matrix, listenermatrix);
828 Matrix4x4_OriginFromMatrix(listenermatrix, listener_origin);
830 // update general area ambient sound sources
831 S_UpdateAmbientSounds ();
835 // update spatialization for static and dynamic sounds
836 ch = channels+NUM_AMBIENTS;
837 for (i=NUM_AMBIENTS ; i<total_channels; i++, ch++)
841 SND_Spatialize(ch, i >= MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS); // respatialize channel
842 if (!ch->leftvol && !ch->rightvol)
845 // try to combine static sounds with a previous channel of the same
846 // sound effect so we don't mix five torches every frame
847 if (i > MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS)
849 // see if it can just use the last one
850 if (combine && combine->sfx == ch->sfx)
852 combine->leftvol += ch->leftvol;
853 combine->rightvol += ch->rightvol;
854 ch->leftvol = ch->rightvol = 0;
858 combine = channels+MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS;
859 for (j=MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS ; j<i; j++, combine++)
860 if (combine->sfx == ch->sfx)
863 if (j == total_channels)
869 combine->leftvol += ch->leftvol;
870 combine->rightvol += ch->rightvol;
871 ch->leftvol = ch->rightvol = 0;
878 sound_spatialized = true;
881 if (snd_show.integer)
885 for (i=0 ; i<total_channels; i++, ch++)
886 if (ch->sfx && (ch->leftvol || ch->rightvol) )
889 Con_Printf("----(%u)----\n", total);
895 void GetSoundtime(void)
899 static int oldsamplepos;
902 fullsamples = shm->samples / shm->format.channels;
904 // it is possible to miscount buffers if it has wrapped twice between
905 // calls to S_Update. Oh well.
906 samplepos = SNDDMA_GetDMAPos();
908 if (samplepos < oldsamplepos)
910 buffers++; // buffer wrapped
912 if (paintedtime > 0x40000000)
913 { // time to chop things off to avoid 32 bit limits
915 paintedtime = fullsamples;
919 oldsamplepos = samplepos;
921 soundtime = buffers * fullsamples + samplepos / shm->format.channels;
924 void S_ExtraUpdate (void)
926 if (snd_noextraupdate.integer || !sound_spatialized)
937 if (!sound_started || (snd_blocked > 0))
943 // check to make sure that we haven't overshot
944 if (paintedtime < soundtime)
945 paintedtime = soundtime;
947 // mix ahead of current position
948 endtime = soundtime + _snd_mixahead.value * shm->format.speed;
949 samps = shm->samples >> (shm->format.channels - 1);
950 if (endtime > (unsigned int)(soundtime + samps))
951 endtime = soundtime + samps;
953 S_PaintChannels (endtime);
959 ===============================================================================
963 ===============================================================================
966 static void S_Play_Common(float fvol, float attenuation)
976 strlcpy(name, Cmd_Argv(i), sizeof(name));
977 if (!strrchr(name, '.'))
978 strlcat(name, ".wav", sizeof(name));
981 // If we need to get the volume from the command line
984 fvol = atof(Cmd_Argv(i));
988 sfx = S_PrecacheSound (name, true, false);
991 ch_ind = S_StartSound(-1, 0, sfx, listener_origin, fvol, attenuation);
993 // Free the sfx if the file didn't exist
995 S_FreeSfx (sfx, false);
997 channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;
1004 S_Play_Common (1.0f, 1.0f);
1009 S_Play_Common (1.0f, 0.0f);
1012 void S_PlayVol(void)
1014 S_Play_Common (-1.0f, 0.0f);
1017 void S_SoundList(void)
1024 for (sfx = known_sfx, i = 0; sfx != NULL; sfx = sfx->next, i++)
1026 if (sfx->fetcher != NULL)
1028 size = sfx->mempool->totalsize;
1030 Con_Printf ("%c%c%c%c(%2db, %6s) %8i : %s\n",
1031 (sfx->loopstart >= 0) ? 'L' : ' ',
1032 (sfx->flags & SFXFLAG_STREAMED) ? 'S' : ' ',
1033 (sfx->locks > 0) ? 'K' : ' ',
1034 (sfx->flags & SFXFLAG_PERMANENTLOCK) ? 'P' : ' ',
1035 sfx->format.width * 8,
1036 (sfx->format.channels == 1) ? "mono" : "stereo",
1041 Con_Printf (" ( unknown ) unloaded : %s\n", sfx->name);
1043 Con_Printf("Total resident: %i\n", total);
1047 qboolean S_LocalSound (const char *sound)
1052 if (!snd_initialized.integer || nosound.integer)
1055 sfx = S_PrecacheSound (sound, true, false);
1058 Con_Printf("S_LocalSound: can't precache %s\n", sound);
1062 // Local sounds must not be freed
1063 sfx->flags |= SFXFLAG_PERMANENTLOCK;
1065 ch_ind = S_StartSound (cl.viewentity, 0, sfx, vec3_origin, 1, 1);
1069 channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;