MCPcopy Create free account
hub / github.com/JACoders/OpenJK / S_StartSound

Function S_StartSound

code/client/snd_dma.cpp:1520–1636  ·  view source on GitHub ↗

==================== S_StartSound Validates the parms and ques the sound up if pos is NULL, the sound will be dynamically sourced from the entity Entchannel 0 will never override a playing sound ==================== */

Source from the content-addressed store, hash-verified

1518====================
1519*/
1520void S_StartSound(const vec3_t origin, int entityNum, soundChannel_t entchannel, sfxHandle_t sfxHandle )
1521{
1522 channel_t *ch;
1523 /*const*/ sfx_t *sfx;
1524
1525 if ( !s_soundStarted || s_soundMuted ) {
1526 return;
1527 }
1528
1529 if ( !origin && ( entityNum < 0 || entityNum >= MAX_GENTITIES ) ) {
1530 Com_Error( ERR_DROP, "S_StartSound: bad entitynum %i", entityNum );
1531 }
1532
1533 if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) {
1534 Com_Error( ERR_DROP, "S_StartSound: handle %i out of range", sfxHandle );
1535 }
1536
1537 sfx = &s_knownSfx[ sfxHandle ];
1538 if (sfx->bInMemory == qfalse){
1539 S_memoryLoad(sfx);
1540 }
1541 SND_TouchSFX(sfx);
1542
1543 if ( s_show->integer == 1 ) {
1544 Com_Printf( "%i : %s for ent %d, chan=%d\n", s_paintedtime, sfx->sSoundName, entityNum, entchannel );
1545 }
1546#ifdef USE_OPENAL
1547 if (s_UseOpenAL)
1548 {
1549 int i;
1550 if (entchannel == CHAN_VOICE)
1551 {
1552 // Make howlers and sand_creature VOICE effects use the normal fall-off (they will still be affected
1553 // by the Voice Volume)
1554 if ((strstr(sfx->sSoundName, "sand_creature")!=NULL) || (strstr(sfx->sSoundName, "howler")!=NULL))
1555 {
1556 entchannel = CHAN_VOICE_ATTEN;
1557 }
1558 }
1559 if (entchannel == CHAN_WEAPON)
1560 {
1561 // Check if we are playing a 'charging' sound, if so, stop it now ..
1562 ch = s_channels + 1;
1563 for (i = 1; i < s_numChannels; i++, ch++)
1564 {
1565 if ((ch->entnum == entityNum) && (ch->entchannel == CHAN_WEAPON) && (ch->thesfx) && (strstr(ch->thesfx->sSoundName, "altcharge") != NULL))
1566 {
1567 // Stop this sound
1568 alSourceStop(ch->alSource);
1569 alSourcei(ch->alSource, AL_BUFFER, NULL);
1570 ch->bPlaying = false;
1571 ch->thesfx = NULL;
1572 break;
1573 }
1574 }
1575 }
1576 else
1577 {

Callers 2

S_StartLocalSoundFunction · 0.70
CL_CgameSystemCallsFunction · 0.70

Calls 6

VectorCopyFunction · 0.85
S_memoryLoadFunction · 0.70
SND_TouchSFXFunction · 0.70
S_PickChannelFunction · 0.70
Com_ErrorFunction · 0.50
Com_PrintfFunction · 0.50

Tested by

no test coverage detected