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

Function S_RegisterSound

code/client/snd_dma.cpp:1006–1053  ·  view source on GitHub ↗

================== S_RegisterSound Creates a default buzz sound if the file can't be loaded ================== */

Source from the content-addressed store, hash-verified

1004==================
1005*/
1006sfxHandle_t S_RegisterSound( const char *name)
1007{
1008 sfx_t *sfx;
1009
1010 if (!s_soundStarted) {
1011 return 0;
1012 }
1013
1014 if ( strlen( name ) >= MAX_QPATH ) {
1015 Com_Printf( S_COLOR_RED"Sound name exceeds MAX_QPATH - %s\n", name );
1016 return 0;
1017 }
1018
1019 sfx = S_FindName( name );
1020
1021 SND_TouchSFX(sfx);
1022
1023 if ( sfx->bDefaultSound )
1024 return 0;
1025
1026#ifdef USE_OPENAL
1027 if (s_UseOpenAL)
1028 {
1029 if ((sfx->pSoundData) || (sfx->Buffer))
1030 return sfx - s_knownSfx;
1031 }
1032 else
1033#endif
1034 {
1035 if ( sfx->pSoundData )
1036 {
1037 return sfx - s_knownSfx;
1038 }
1039 }
1040
1041 sfx->bInMemory = false;
1042
1043 S_memoryLoad(sfx);
1044
1045 if ( sfx->bDefaultSound ) {
1046#ifndef FINAL_BUILD
1047 Com_DPrintf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->sSoundName );
1048#endif
1049 return 0;
1050 }
1051
1052 return sfx - s_knownSfx;
1053}
1054
1055void S_memoryLoad(sfx_t *sfx)
1056{

Callers 8

AS_GetSubWavesFunction · 0.70
AS_GetLoopedWaveFunction · 0.70
CIN_PlayCinematicFunction · 0.70
CL_UISystemCallsFunction · 0.70
S_BeginRegistrationFunction · 0.70
S_Play_fFunction · 0.70
CL_CgameSystemCallsFunction · 0.70
trap_S_RegisterSoundFunction · 0.50

Calls 5

S_FindNameFunction · 0.70
SND_TouchSFXFunction · 0.70
S_memoryLoadFunction · 0.70
Com_PrintfFunction · 0.50
Com_DPrintfFunction · 0.50

Tested by

no test coverage detected