Skip to content

Commit d4c02af

Browse files
committed
Move sound manager to xrAPI
Renamed CSound_manager_interface -> ISoundManager and moved it into GEnv
1 parent 81635ed commit d4c02af

34 files changed

+105
-105
lines changed

src/Include/xrAPI/xrAPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class CGameMtlLibrary;
1010
class CRender;
1111
class CScriptEngine;
1212
class AISpaceBase;
13+
class ISoundManager;
1314

1415
class XRAPI_API EngineGlobalEnvironment
1516
{
@@ -27,6 +28,7 @@ class XRAPI_API EngineGlobalEnvironment
2728
IRenderFactory* RenderFactory;
2829
CScriptEngine* ScriptEngine;
2930
AISpaceBase* AISpace;
31+
ISoundManager* Sound;
3032

3133
bool isDedicatedServer;
3234
};

src/editors/ECore/Editor/SoundManager.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int CSoundManager::GetGameSounds(FS_FileSet& files)
3030
int CSoundManager::GetSoundEnvs(AStringVec& items)
3131
{
3232
/*
33-
SoundEnvironment_LIB* Lib = Sound->get_env_library();
33+
SoundEnvironment_LIB* Lib = GEnv.Sound->get_env_library();
3434
if (Lib){
3535
for (SoundEnvironment_LIB::SE_IT it=Lib->Library().begin(); it!=Lib->Library().end(); it++)
3636
items.push_back(*(*it)->name);
@@ -44,16 +44,15 @@ bool CSoundManager::OnCreate()
4444
{
4545
//. psSoundFreq = sf_44K;
4646
// psSoundFlags.set (ssHardware,FALSE);
47-
CSound_manager_interface::_create(0);
48-
CSound_manager_interface::_create(1);
47+
ISoundManager::_create();
4948
return true;
5049
}
5150

52-
void CSoundManager::OnDestroy() { CSound_manager_interface::_destroy(); }
51+
void CSoundManager::OnDestroy() { ISoundManager::_destroy(); }
5352
void CSoundManager::OnFrame()
5453
{
5554
::psSoundVEffects = psDeviceFlags.is(rsMuteSounds) ? 0.f : 1.f;
56-
Sound->update(EDevice.m_Camera.GetPosition(), EDevice.m_Camera.GetDirection(), EDevice.m_Camera.GetNormal());
55+
GEnv.Sound->update(EDevice.m_Camera.GetPosition(), EDevice.m_Camera.GetDirection(), EDevice.m_Camera.GetNormal());
5756
}
5857

5958
void CSoundManager::MuteSounds(BOOL bVal)
@@ -95,7 +94,7 @@ void CSoundManager::RenameSound(LPCSTR nm0, LPCSTR nm1, EItemType type)
9594
strcat(fn1, ".ogg");
9695
FS.file_rename(fn0, fn1, false);
9796

98-
Sound->refresh_sources();
97+
GEnv.Sound->refresh_sources();
9998
}
10099
}
101100

@@ -121,7 +120,7 @@ BOOL CSoundManager::RemoveSound(LPCSTR fname, EItemType type)
121120
FS.file_delete(_sounds_, thm_name.c_str());
122121
// game
123122
FS.file_delete(_game_sounds_, game_name.c_str());
124-
Sound->refresh_sources();
123+
GEnv.Sound->refresh_sources();
125124
return TRUE;
126125
}
127126
}
@@ -436,7 +435,7 @@ void CSoundManager::RefreshSounds(bool bSync)
436435
SynchronizeSounds(true, true, false, 0, 0);
437436
CleanupSounds();
438437
}
439-
Sound->refresh_sources();
438+
GEnv.Sound->refresh_sources();
440439
UI->SetStatus("");
441440
}
442441
else

src/editors/LevelEditor/Edit/SoundManager_LE.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void CLevelSoundManager::RealRefreshEnvGeometry()
4444
if ( MakeEnvGeometry(F, false) )
4545
{
4646
IReader R( F.pointer(), F.size() );
47-
::Sound->set_geometry_env( &R );
47+
GEnv.Sound->set_geometry_env( &R );
4848
}
4949
}
5050
@@ -130,7 +130,7 @@ void CLevelSoundManager::OnFrame()
130130
/*
131131
void CLevelSoundManager::RefreshEnvLibrary()
132132
{
133-
Sound->refresh_env_library();
133+
GEnv.Sound->refresh_env_library();
134134
RefreshEnvGeometry ();
135135
}
136136
*/

src/editors/LevelEditor/Edit/UI_LevelMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,9 @@ CCommandVar CommandRefreshSnapObjects(CCommandVar p1, CCommandVar p2)
975975
/*
976976
CCommandVar CommandRefreshSoundEnvs(CCommandVar p1, CCommandVar p2)
977977
{
978-
::Sound->refresh_env_library();
978+
GEnv.Sound->refresh_env_library();
979979
return TRUE;
980-
// ::Sound->_restart();
980+
// GEnv.Sound->_restart();
981981
}
982982
*/
983983

src/editors/ShaderEditor/SHSoundEnvTools.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,14 @@ void __fastcall CSHSoundEnvTools::OnEnvSizeChange(PropValue *sender)
326326
test_env.Reverb = m_EnvSrc.Reverb;
327327
test_env.ReverbDelay = m_EnvSrc.ReverbDelay;
328328
CSound_environment *E = m_Env;
329-
Sound->set_environment_size(&test_env, &E);
329+
GEnv.Sound->set_environment_size(&test_env, &E);
330330
ExecCommand(COMMAND_UPDATE_PROPERTIES);
331331
}
332332
333333
void __fastcall CSHSoundEnvTools::OnEnvChange(PropValue *sender)
334334
{
335335
CSound_environment *E = m_Env;
336-
Sound->set_environment(m_Env->Environment, &E);
336+
GEnv.Sound->set_environment(m_Env->Environment, &E);
337337
m_EnvSrc = *m_Env;
338338
ExecCommand(COMMAND_UPDATE_PROPERTIES);
339339
}

src/editors/ShaderEditor/SHSoundEnvTools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CSHSoundEnvTools: public ISHTools
4040
4141
void UseEnvironment()
4242
{
43-
Sound->set_user_env(m_Env);
43+
GEnv.Sound->set_user_env(m_Env);
4444
}
4545
4646
public:

src/xrCDB/xr_area.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ CObjectSpace::CObjectSpace()
3434
CObjectSpace::~CObjectSpace()
3535
{
3636
// moved to ~IGameLevel
37-
// Sound->set_geometry_occ (NULL);
38-
// Sound->set_handler (NULL);
37+
// GEnv.Sound->set_geometry_occ (NULL);
38+
// GEnv.Sound->set_handler (NULL);
3939
//
4040
#ifdef DEBUG
4141
// sh_debug.destroy ();
@@ -114,8 +114,8 @@ void CObjectSpace::Create(Fvector* verts, CDB::TRI* tris, const hdrCFORM& H, CDB
114114
m_BoundingVolume.set(H.aabb);
115115
g_SpatialSpace->initialize(m_BoundingVolume);
116116
g_SpatialSpacePhysic->initialize(m_BoundingVolume);
117-
// Sound->set_geometry_occ ( &Static );
118-
// Sound->set_handler ( _sound_event );
117+
// GEnv.Sound->set_geometry_occ ( &Static );
118+
// GEnv.Sound->set_handler ( _sound_event );
119119
}
120120

121121
//----------------------------------------------------------------------

src/xrEngine/IGame_Level.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ IGame_Level::~IGame_Level()
4242
Device.seqFrame.Remove(this);
4343
CCameraManager::ResetPP();
4444
///////////////////////////////////////////
45-
Sound->set_geometry_occ(NULL);
46-
Sound->set_handler(NULL);
45+
GEnv.Sound->set_geometry_occ(nullptr);
46+
GEnv.Sound->set_handler(nullptr);
4747
Device.DumpResourcesMemoryUsage();
4848

4949
u32 m_base = 0, c_base = 0, m_lmaps = 0, c_lmaps = 0;
@@ -101,9 +101,9 @@ bool IGame_Level::Load(u32 dwNum)
101101
// g_pGamePersistent->LoadTitle ("st_loading_cform");
102102
g_pGamePersistent->LoadTitle();
103103
ObjectSpace.Load(build_callback);
104-
// Sound->set_geometry_occ ( &Static );
105-
Sound->set_geometry_occ(ObjectSpace.GetStaticModel());
106-
Sound->set_handler(_sound_event);
104+
// GEnv.Sound->set_geometry_occ ( &Static );
105+
GEnv.Sound->set_geometry_occ(ObjectSpace.GetStaticModel());
106+
GEnv.Sound->set_handler(_sound_event);
107107

108108
pApp->LoadSwitch();
109109

@@ -264,7 +264,7 @@ void IGame_Level::SoundEvent_Register(ref_sound_data_ptr S, float range)
264264
Fvector snd_position = p->position;
265265
if (S->feedback->is_2D())
266266
{
267-
snd_position.add(Sound->listener_position());
267+
snd_position.add(GEnv.Sound->listener_position());
268268
}
269269

270270
VERIFY(p && _valid(range));
@@ -299,7 +299,7 @@ void IGame_Level::SoundEvent_Register(ref_sound_data_ptr S, float range)
299299
VERIFY(_valid(Power));
300300
if (Power > EPS_S)
301301
{
302-
float occ = Sound->get_occlusion_to(it->GetSpatialData().sphere.P, snd_position);
302+
float occ = GEnv.Sound->get_occlusion_to(it->GetSpatialData().sphere.P, snd_position);
303303
VERIFY(_valid(occ));
304304
Power *= occ;
305305
if (Power > EPS_S)

src/xrEngine/Stats.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void CStats::Show()
145145
font.OutSet(200, 0);
146146
GEnv.Render->DumpStatistics(font, alertPtr);
147147
font.OutSkip();
148-
Sound->DumpStatistics(font, alertPtr);
148+
GEnv.Sound->DumpStatistics(font, alertPtr);
149149
font.OutSkip();
150150
pInput->DumpStatistics(font, alertPtr);
151151
font.OutSkip();
@@ -216,7 +216,7 @@ void CStats::OnRender()
216216
if (g_stats_flags.is(st_sound))
217217
{
218218
CSound_stats_ext snd_stat_ext;
219-
::Sound->statistic(0, &snd_stat_ext);
219+
GEnv.Sound->statistic(0, &snd_stat_ext);
220220
auto _I = snd_stat_ext.items.begin();
221221
auto _E = snd_stat_ext.items.end();
222222
for (; _I != _E; _I++)

src/xrEngine/device.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void CRenderDevice::End(void)
7171
#endif // #ifdef INGAME_EDITOR
7272
if (dwPrecacheFrame)
7373
{
74-
::Sound->set_master_volume(0.f);
74+
GEnv.Sound->set_master_volume(0.f);
7575
dwPrecacheFrame--;
7676
if (!dwPrecacheFrame)
7777
{
@@ -84,7 +84,7 @@ void CRenderDevice::End(void)
8484
precache_light->set_active(false);
8585
precache_light.destroy();
8686
}
87-
::Sound->set_master_volume(1.f);
87+
GEnv.Sound->set_master_volume(1.f);
8888
GEnv.Render->ResourcesDestroyNecessaryTextures();
8989
Memory.mem_compact();
9090
Msg("* MEMORY USAGE: %d K", Memory.mem_usage() / 1024);
@@ -420,8 +420,8 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
420420
TimerGlobal.Pause(FALSE);
421421
#endif
422422
}
423-
if (bSound && ::Sound)
424-
snd_emitters_ = ::Sound->pause_emitters(true);
423+
if (bSound && GEnv.Sound)
424+
snd_emitters_ = GEnv.Sound->pause_emitters(true);
425425
}
426426
else
427427
{
@@ -433,11 +433,11 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
433433
if (bSound)
434434
{
435435
if (snd_emitters_ > 0) // avoid crash
436-
snd_emitters_ = ::Sound->pause_emitters(false);
436+
snd_emitters_ = GEnv.Sound->pause_emitters(false);
437437
else
438438
{
439439
#ifdef DEBUG
440-
Log("Sound->pause_emitters underflow");
440+
Log("GEnv.Sound->pause_emitters underflow");
441441
#endif
442442
}
443443
}

0 commit comments

Comments
 (0)