/* * SF_Init */ bool SF_Init( void *hwnd, int maxEntities, bool verbose ) { soundpool = S_MemAllocPool( "OpenAL sound module" ); s_num_ent_spats = 0; #ifdef OPENAL_RUNTIME if( !QAL_Init( ALDRIVER, verbose ) ) { #ifdef ALDRIVER_ALT if( !QAL_Init( ALDRIVER_ALT, verbose ) ) #endif { Com_Printf( "Failed to load OpenAL library: %s\n", ALDRIVER ); return false; } } #endif s_volume = trap_Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE ); s_musicvolume = trap_Cvar_Get( "s_musicvolume", "0.15", CVAR_ARCHIVE ); s_doppler = trap_Cvar_Get( "s_doppler", "1.0", CVAR_ARCHIVE ); s_sound_velocity = trap_Cvar_Get( "s_sound_velocity", "10976", CVAR_DEVELOPER ); s_stereo2mono = trap_Cvar_Get ( "s_stereo2mono", "0", CVAR_ARCHIVE ); s_globalfocus = trap_Cvar_Get( "s_globalfocus", "0", CVAR_ARCHIVE ); #ifdef ENABLE_PLAY trap_Cmd_AddCommand( "play", SF_Play_f ); #endif trap_Cmd_AddCommand( "music", SF_Music_f ); trap_Cmd_AddCommand( "stopmusic", SF_StopBackgroundTrack ); trap_Cmd_AddCommand( "prevmusic", SF_PrevBackgroundTrack ); trap_Cmd_AddCommand( "nextmusic", SF_NextBackgroundTrack ); trap_Cmd_AddCommand( "pausemusic", SF_PauseBackgroundTrack ); trap_Cmd_AddCommand( "soundlist", SF_SoundList_f ); trap_Cmd_AddCommand( "s_devices", SF_ListDevices_f ); s_cmdPipe = S_CreateSoundCmdPipe(); if( !s_cmdPipe ) { return false; } s_backThread = trap_Thread_Create( S_BackgroundUpdateProc, s_cmdPipe ); S_IssueInitCmd( s_cmdPipe, hwnd, maxEntities, verbose ); S_FinishSoundCmdPipe( s_cmdPipe ); if( !alContext ) { return false; } S_InitBuffers(); return true; }
/* * SF_Init */ bool SF_Init( void *hwnd, int maxEntities, bool verbose ) { soundpool = S_MemAllocPool( "QF Sound Module" ); developer = trap_Cvar_Get( "developer", "0", 0 ); s_volume = trap_Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE ); s_musicvolume = trap_Cvar_Get( "s_musicvolume", "0.2", CVAR_ARCHIVE ); s_khz = trap_Cvar_Get( "s_khz", "44", CVAR_ARCHIVE|CVAR_LATCH_SOUND ); s_mixahead = trap_Cvar_Get( "s_mixahead", "0.14", CVAR_ARCHIVE ); s_show = trap_Cvar_Get( "s_show", "0", CVAR_CHEAT ); s_testsound = trap_Cvar_Get( "s_testsound", "0", 0 ); s_swapstereo = trap_Cvar_Get( "s_swapstereo", "0", CVAR_ARCHIVE ); s_vorbis = trap_Cvar_Get( "s_vorbis", "1", CVAR_ARCHIVE ); s_pseudoAcoustics = trap_Cvar_Get( "s_pseudoAcoustics", "0", CVAR_ARCHIVE ); s_separationDelay = trap_Cvar_Get( "s_separationDelay", "1.0", CVAR_ARCHIVE ); s_globalfocus = trap_Cvar_Get( "s_globalfocus", "0", CVAR_ARCHIVE ); #ifdef ENABLE_PLAY trap_Cmd_AddCommand( "play", SF_Play_f ); #endif trap_Cmd_AddCommand( "music", SF_Music_f ); trap_Cmd_AddCommand( "stopsound", SF_StopAllSounds_f ); trap_Cmd_AddCommand( "stopmusic", SF_StopBackgroundTrack ); trap_Cmd_AddCommand( "prevmusic", SF_PrevBackgroundTrack ); trap_Cmd_AddCommand( "nextmusic", SF_NextBackgroundTrack ); trap_Cmd_AddCommand( "pausemusic", SF_PauseBackgroundTrack ); trap_Cmd_AddCommand( "soundlist", SF_SoundList_f ); trap_Cmd_AddCommand( "soundinfo", SF_SoundInfo_f ); num_sfx = 0; s_num_ent_spats = 0; s_registration_sequence = 1; s_registering = false; s_cmdPipe = S_CreateSoundCmdPipe(); if( !s_cmdPipe ) { return false; } s_backThread = trap_Thread_Create( S_BackgroundUpdateProc, s_cmdPipe ); S_IssueInitCmd( s_cmdPipe, hwnd, maxEntities, verbose ); S_FinishSoundCmdPipe( s_cmdPipe ); if( !dma.buffer ) return false; SF_SetAttenuationModel( S_DEFAULT_ATTENUATION_MODEL, S_DEFAULT_ATTENUATION_MAXDISTANCE, S_DEFAULT_ATTENUATION_REFDISTANCE ); return true; }