Skip to content

Commit edfb052

Browse files
committed
xrSound: add to Linux build
1 parent 84782a2 commit edfb052

21 files changed

+193
-28
lines changed

Externals/openal/include/openal/alc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,10 @@ typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, A
272272
}
273273
#endif
274274

275+
#if defined(_WIN32) && !defined(_XBOX)
275276
typedef void __cdecl log_fn_ptr_type(char*);
276277
extern ALC_API log_fn_ptr_type* pLog ;
277-
278+
#endif
278279
void AlLog(char* format, ...);
279280

280281
#endif /* AL_ALC_H */

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ add_subdirectory(xrCore)
1010
#add_subdirectory(xrParticles)
1111
#add_subdirectory(xrPhysics)
1212
add_subdirectory(xrScriptEngine)
13-
#add_subdirectory(xrSound)
13+
add_subdirectory(xrSound)

src/xrServerEntities/ai_sounds.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
enum ESoundTypes
1515
{
16+
#if defined(WINDOWS)
1617
SOUND_TYPE_NO_SOUND = 0x00000000ui32,
1718

1819
SOUND_TYPE_WEAPON = 0x80000000ui32,
@@ -45,6 +46,40 @@ enum ESoundTypes
4546
SOUND_TYPE_OBJECT_COLLIDING = 0x00000200ui32,
4647
SOUND_TYPE_OBJECT_EXPLODING = 0x00000100ui32,
4748
SOUND_TYPE_AMBIENT = 0x00000080ui32,
49+
#elif defined(LINUX)
50+
SOUND_TYPE_NO_SOUND = 0x00000000,
51+
52+
SOUND_TYPE_WEAPON = 0x80000000,
53+
SOUND_TYPE_ITEM = 0x40000000,
54+
SOUND_TYPE_MONSTER = 0x20000000,
55+
SOUND_TYPE_ANOMALY = 0x10000000,
56+
SOUND_TYPE_WORLD = 0x08000000,
57+
58+
SOUND_TYPE_PICKING_UP = 0x04000000,
59+
SOUND_TYPE_DROPPING = 0x02000000,
60+
SOUND_TYPE_HIDING = 0x01000000,
61+
SOUND_TYPE_TAKING = 0x00800000,
62+
SOUND_TYPE_USING = 0x00400000,
63+
64+
SOUND_TYPE_SHOOTING = 0x00200000,
65+
SOUND_TYPE_EMPTY_CLICKING = 0x00100000,
66+
SOUND_TYPE_BULLET_HIT = 0x00080000,
67+
SOUND_TYPE_RECHARGING = 0x00040000,
68+
69+
SOUND_TYPE_DYING = 0x00020000,
70+
SOUND_TYPE_INJURING = 0x00010000,
71+
SOUND_TYPE_STEP = 0x00008000,
72+
SOUND_TYPE_TALKING = 0x00004000,
73+
SOUND_TYPE_ATTACKING = 0x00002000,
74+
SOUND_TYPE_EATING = 0x00001000,
75+
76+
SOUND_TYPE_IDLE = 0x00000800,
77+
78+
SOUND_TYPE_OBJECT_BREAKING = 0x00000400,
79+
SOUND_TYPE_OBJECT_COLLIDING = 0x00000200,
80+
SOUND_TYPE_OBJECT_EXPLODING = 0x00000100,
81+
SOUND_TYPE_AMBIENT = 0x00000080,
82+
#endif
4883

4984
SOUND_TYPE_ITEM_PICKING_UP = SOUND_TYPE_ITEM | SOUND_TYPE_PICKING_UP,
5085
SOUND_TYPE_ITEM_DROPPING = SOUND_TYPE_ITEM | SOUND_TYPE_DROPPING,

src/xrSound/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
project(xrSound)
2+
3+
list(APPEND DIRS
4+
"."
5+
)
6+
7+
add_dir("${DIRS}")
8+
9+
include_directories(
10+
${CMAKE_CURRENT_SOURCE_DIR}/..
11+
${CMAKE_CURRENT_SOURCE_DIR}/../xrEngine
12+
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/libvorbis/include
13+
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/libogg/include
14+
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/openal/include
15+
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
16+
)
17+
18+
list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./xr_cda.cpp")
19+
list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./MusicStream.cpp")
20+
list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./xr_cda.h")
21+
list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./MusicStream.h")
22+
23+
24+
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
25+
26+
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
27+
target_link_libraries(${PROJECT_NAME} xrCore ogg vorbis vorbisfile openal xrAPI xrCDB)

src/xrSound/MusicStream.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#include "MusicStream.h"
77
#include "xr_streamsnd.h"
88

9+
#if defined(WINDOWS)
910
#include "x_ray.h"
11+
#endif
1012
#include "GameFont.h"
1113

1214
//////////////////////////////////////////////////////////////////////

src/xrSound/OpenALDeviceList.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
#include "OpenALDeviceList.h"
2727
#include "xrCore/xr_token.h"
2828

29+
#if defined(WINDOWS)
2930
#pragma warning(push)
3031
#pragma warning(disable : 4995)
3132
#include <objbase.h>
3233
#pragma warning(pop)
34+
#endif
3335

3436
#ifdef _EDITOR
3537
log_fn_ptr_type* pLog = nullptr;
@@ -38,7 +40,9 @@ log_fn_ptr_type* pLog = nullptr;
3840
void __cdecl al_log(char* msg) { Log(msg); }
3941
ALDeviceList::ALDeviceList()
4042
{
43+
#if defined(WINDOWS)
4144
pLog = al_log;
45+
#endif
4246
snd_device_id = (u32)-1;
4347
Enumerate();
4448
}
@@ -66,7 +70,9 @@ void ALDeviceList::Enumerate()
6670
// -- empty all the lists and reserve space for 10 devices
6771
m_devices.clear();
6872

73+
#if defined(WINDOWS)
6974
CoUninitialize();
75+
#endif
7076
// grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices
7177
if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"))
7278
{
@@ -86,11 +92,13 @@ void ALDeviceList::Enumerate()
8692
// Also we assume that if "Generic Hardware" exists, than "Generic Software" is also exists
8793
// Maybe wrong
8894

95+
#if defined(WINDOWS) //Maybe in Linux this not?
8996
if (0 == xr_stricmp(m_defaultDeviceName, AL_GENERIC_HARDWARE))
9097
{
9198
xr_strcpy(m_defaultDeviceName, AL_GENERIC_SOFTWARE);
9299
Msg("SOUND: OpenAL: default SndDevice name set to %s", m_defaultDeviceName);
93100
}
101+
#endif
94102

95103
index = 0;
96104
// go through device list (each device terminated with a single NULL, list terminated with double NULL)
@@ -169,8 +177,10 @@ void ALDeviceList::Enumerate()
169177
GetDeviceDesc(j).props.eax, GetDeviceDesc(j).props.efx ? "yes" : "no",
170178
GetDeviceDesc(j).props.xram ? "yes" : "no");
171179
}
180+
#if defined(WINDOWS)
172181
if (!strstr(GetCommandLine(), "-weather"))
173182
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
183+
#endif
174184
}
175185

176186
pcstr ALDeviceList::GetDeviceName(u32 index) const { return snd_devices_token[index].name; }

src/xrSound/SoundRender.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "Sound.h"
3+
#include "sound.h"
44

55
class CSoundRender_Core;
66
class CSoundRender_Source;

src/xrSound/SoundRender_Core.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
#include "SoundRender_Core.h"
66
#include "SoundRender_Source.h"
77
#include "SoundRender_Emitter.h"
8+
#if defined(WINDOWS)
89
#pragma warning(push)
910
#pragma warning(disable : 4995)
1011
#include <eax/eax.h>
1112
#pragma warning(pop)
13+
#endif
1214

1315
int psSoundTargets = 32;
1416
Flags32 psSoundFlags = {ss_Hardware | ss_EAX};
@@ -473,7 +475,7 @@ void CSoundRender_Core::env_apply()
473475
}
474476

475477
void CSoundRender_Core::update_listener(const Fvector& P, const Fvector& D, const Fvector& N, float dt) {}
476-
478+
#if defined(WINDOWS)
477479
void CSoundRender_Core::i_eax_listener_set(CSound_environment* _E)
478480
{
479481
VERIFY(bEAX);
@@ -538,13 +540,16 @@ void CSoundRender_Core::i_eax_listener_get(CSound_environment* _E)
538540
E->EnvironmentDiffusion = (float)ep.flEnvironmentDiffusion;
539541
E->AirAbsorptionHF = (float)ep.flAirAbsorptionHF;
540542
}
543+
#endif
541544

545+
#if defined(WINDOWS)
542546
void CSoundRender_Core::i_eax_commit_setting()
543547
{
544548
// commit eax
545549
if (bDeferredEAX)
546550
i_eax_set(&DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_COMMITDEFERREDSETTINGS, nullptr, 0);
547551
}
552+
#endif
548553

549554
void CSoundRender_Core::object_relcase(IGameObject* obj)
550555
{
@@ -600,6 +605,7 @@ void CSoundRender_Core::set_environment_size(CSound_environment* src_env, CSound
600605
{
601606
CSoundRender_Environment* SE = static_cast<CSoundRender_Environment*>(src_env);
602607
CSoundRender_Environment* DE = static_cast<CSoundRender_Environment*>(*dst_env);
608+
#if defined(WINDOWS)
603609
// set environment
604610
i_eax_set(&DSPROPSETID_EAX_ListenerProperties,
605611
DSPROPERTY_EAXLISTENER_IMMEDIATE | DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE, &SE->EnvironmentSize,
@@ -610,16 +616,19 @@ void CSoundRender_Core::set_environment_size(CSound_environment* src_env, CSound
610616
DSPROPERTY_EAXLISTENER_IMMEDIATE | DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE, &DE->EnvironmentSize,
611617
sizeof(DE->EnvironmentSize));
612618
i_eax_listener_get(DE);
619+
#endif
613620
}
614621
}
615622
void CSoundRender_Core::set_environment(u32 id, CSound_environment** dst_env)
616623
{
617624
if (bEAX)
618625
{
619626
CSoundRender_Environment* DE = static_cast<CSoundRender_Environment*>(*dst_env);
627+
#if defined(WINDOWS)
620628
// set environment
621629
i_eax_set(&DSPROPSETID_EAX_ListenerProperties,
622630
DSPROPERTY_EAXLISTENER_IMMEDIATE | DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE, &id, sizeof(id));
623631
i_eax_listener_get(DE);
632+
#endif
624633
}
625634
}

src/xrSound/SoundRender_Core.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ class CSoundRender_Core : public ISoundManager
7171
u32 cache_bytes_per_line;
7272

7373
protected:
74+
#if defined(WINDOWS)
7475
virtual void i_eax_set(const GUID* guid, u32 prop, void* val, u32 sz) = 0;
7576
virtual void i_eax_get(const GUID* guid, u32 prop, void* val, u32 sz) = 0;
77+
#endif
7678

7779
public:
7880
CSoundRender_Core();
@@ -111,11 +113,12 @@ class CSoundRender_Core : public ISoundManager
111113
// listener
112114
// virtual const Fvector& listener_position ( )=0;
113115
virtual void update_listener(const Fvector& P, const Fvector& D, const Fvector& N, float dt) = 0;
116+
#if defined(WINDOWS)
114117
// eax listener
115118
void i_eax_commit_setting();
116119
void i_eax_listener_set(CSound_environment* E);
117120
void i_eax_listener_get(CSound_environment* E);
118-
121+
#endif
119122
virtual SoundEnvironment_LIB* get_env_library() { return s_environment; }
120123
virtual void refresh_env_library();
121124
virtual void set_user_env(CSound_environment* E);

src/xrSound/SoundRender_CoreA.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ CSoundRender_CoreA::CSoundRender_CoreA() : CSoundRender_Core()
1111
pDevice = nullptr;
1212
pDeviceList = nullptr;
1313
pContext = nullptr;
14+
#if defined(WINDOWS)
1415
eaxSet = nullptr;
1516
eaxGet = nullptr;
17+
#endif
1618
}
1719

1820
CSoundRender_CoreA::~CSoundRender_CoreA() {}
19-
21+
#if defined(WINDOWS)
2022
bool CSoundRender_CoreA::EAXQuerySupport(bool isDeferred, const GUID* guid, u32 prop, void* val, u32 sz)
2123
{
2224
if (AL_NO_ERROR != eaxGet(guid, prop, 0, val, sz))
@@ -67,6 +69,7 @@ bool CSoundRender_CoreA::EAXTestSupport(bool isDeferred)
6769
return false;
6870
return true;
6971
}
72+
#endif
7073

7174
void CSoundRender_CoreA::_restart() { inherited::_restart(); }
7275
void CSoundRender_CoreA::_initialize()
@@ -115,9 +118,9 @@ void CSoundRender_CoreA::_initialize()
115118
A_CHK(alListener3f(AL_POSITION, 0.f, 0.f, 0.f));
116119
A_CHK(alListener3f(AL_VELOCITY, 0.f, 0.f, 0.f));
117120
Fvector orient[2] = {{0.f, 0.f, 1.f}, {0.f, 1.f, 0.f}};
118-
A_CHK(alListenerfv(AL_ORIENTATION, &orient[0].x));
121+
A_CHK(alListenerfv(AL_ORIENTATION, (const ALfloat*)&orient[0].x));
119122
A_CHK(alListenerf(AL_GAIN, 1.f));
120-
123+
#if defined(WINDOWS)
121124
// Check for EAX extension
122125
bEAX = deviceDesc.props.eax && !deviceDesc.props.eax_unwanted;
123126

@@ -133,7 +136,7 @@ void CSoundRender_CoreA::_initialize()
133136
bDeferredEAX = EAXTestSupport(true);
134137
bEAX = EAXTestSupport(false);
135138
}
136-
139+
#endif
137140
inherited::_initialize();
138141

139142
// Pre-create targets
@@ -182,8 +185,10 @@ void CSoundRender_CoreA::_clear()
182185
xr_delete(pDeviceList);
183186
}
184187

188+
#if defined(WINDOWS)
185189
void CSoundRender_CoreA::i_eax_set(const GUID* guid, u32 prop, void* val, u32 sz) { eaxSet(guid, prop, 0, val, sz); }
186190
void CSoundRender_CoreA::i_eax_get(const GUID* guid, u32 prop, void* val, u32 sz) { eaxGet(guid, prop, 0, val, sz); }
191+
#endif
187192
void CSoundRender_CoreA::update_listener(const Fvector& P, const Fvector& D, const Fvector& N, float dt)
188193
{
189194
inherited::update_listener(P, D, N, dt);
@@ -198,5 +203,5 @@ void CSoundRender_CoreA::update_listener(const Fvector& P, const Fvector& D, con
198203

199204
A_CHK(alListener3f(AL_POSITION, Listener.position.x, Listener.position.y, -Listener.position.z));
200205
A_CHK(alListener3f(AL_VELOCITY, 0.f, 0.f, 0.f));
201-
A_CHK(alListenerfv(AL_ORIENTATION, &Listener.orientation[0].x));
206+
A_CHK(alListenerfv(AL_ORIENTATION, (const ALfloat*)&Listener.orientation[0].x));
202207
}

0 commit comments

Comments
 (0)