Skip to content

Commit eeb7110

Browse files
committed
fix build w/o audio
1 parent c50aafc commit eeb7110

8 files changed

Lines changed: 44 additions & 5 deletions

File tree

Binary file not shown.

src/OpenCOVER/plugins/drivingsim/SteeringWheel/EngineSound.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using namespace opencover::audio;
1212

1313
SoundStep::SoundStep(Player *p, float umin)
1414
{
15+
#ifdef HAVE_AUDIO
1516
player = p;
1617
speed = umin;
1718
if (p != NULL)
@@ -27,6 +28,7 @@ SoundStep::SoundStep(Player *p, float umin)
2728
source->setIntensity(0.0);
2829
}
2930
}
31+
#endif
3032
playing = false;
3133
}
3234

@@ -38,19 +40,23 @@ void SoundStep::stop()
3840
{
3941
if (playing)
4042
{
43+
#ifdef HAVE_AUDIO
4144
//source->stop();
4245
if (source)
4346
source->setIntensity(0);
47+
#endif
4448
playing = false;
4549
}
4650
}
4751
void SoundStep::start()
4852
{
4953
if (!playing)
5054
{
55+
#ifdef HAVE_AUDIO
5156
//source->play();
5257
if (source)
5358
source->setIntensity(1);
59+
#endif
5460
playing = true;
5561
}
5662
}
@@ -179,6 +185,7 @@ void EngineSound::setSpeed(float s)
179185
else
180186
{
181187
sounds[i]->start();
188+
#ifdef HAVE_AUDIO
182189
if (s < sounds[i]->speed - (SPEED_STEP)) // einblenden
183190
{
184191
if (sounds[i]->source)
@@ -199,6 +206,7 @@ void EngineSound::setSpeed(float s)
199206
}
200207
if (sounds[i]->source)
201208
sounds[i]->source->setPitch(22000.0 + ((s - sounds[i]->speed) / (float)SPEED_STEP) * pitchValues[i]);
209+
#endif
202210
static int oldSample = -1;
203211
currentSample = i;
204212
if (currentSample != oldSample)

src/OpenCOVER/plugins/drivingsim/SteeringWheel/EngineSound.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@
99
#define _EngineSound_H
1010

1111
#include <string>
12-
#include <audio/Player.h>
1312
#include <cover/coVRTui.h>
14-
using namespace opencover;
13+
14+
namespace opencover
15+
{
16+
namespace audio
17+
{
18+
class Player;
19+
class Source;
20+
}
21+
}
22+
#ifdef HAVE_AUDIO
23+
#include <audio/Player.h>
24+
#endif
1525
using namespace opencover::audio;
26+
27+
using namespace opencover;
1628
using namespace covise;
1729

1830
#define NUM_SPEEDS 30
@@ -25,16 +37,16 @@ class SoundStep
2537
virtual ~SoundStep();
2638
void stop();
2739
void start();
28-
std::shared_ptr<Source> source;
2940
float speed;
3041
bool playing;
31-
Player *player;
42+
std::shared_ptr<Source> source;
43+
Player *player = nullptr;
3244
};
3345

3446
class EngineSound : public coTUIListener
3547
{
3648
public:
37-
Player *player;
49+
Player *player = nullptr;
3850

3951
EngineSound(Player *p);
4052
virtual ~EngineSound();

src/OpenCOVER/plugins/drivingsim/SteeringWheel/InputDevice.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ InputDeviceMotionPlatform::InputDeviceMotionPlatform()
604604
ccSpeed = 0;
605605
ccActive = false;
606606
#ifndef USE_CAR_SOUND
607+
#ifdef HAVE_AUDIO
607608
anlasserSource = nullptr;
608609
Audio *anlasserAudio = new Audio("AnlasserInnen.wav");
609610
if (player)
@@ -616,6 +617,7 @@ InputDeviceMotionPlatform::InputDeviceMotionPlatform()
616617
anlasserSource->setIntensity(1.0);
617618
}
618619
}
620+
#endif
619621
#endif
620622

621623
if (coVRMSController::instance()->isMaster())

src/OpenCOVER/plugins/drivingsim/SteeringWheel/Vehicle.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ osg::Matrix *VrmlNodeVehicle::getCarTransMatrix()
304304
void VrmlNodeVehicle::init()
305305
{
306306
#ifndef USE_CAR_SOUND
307+
#ifdef HAVE_AUDIO
307308
source = nullptr;
308309
gearSound = nullptr;
309310
hornSound = nullptr;
@@ -341,6 +342,7 @@ void VrmlNodeVehicle::init()
341342
hornSound->setIntensity(1.0);
342343
}
343344
}
345+
#endif
344346
#else
345347
carSound = CarSound::instance();
346348
#endif

src/OpenCOVER/plugins/drivingsim/SteeringWheel/Vehicle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636

3737
#include <util/coTypes.h>
3838

39+
#ifdef HAVE_AUDIO
3940
#include <audio/Player.h>
41+
#endif
4042
#include <vrml97/vrml/config.h>
4143
#include <vrml97/vrml/VrmlNodeType.h>
4244
#include <vrml97/vrml/coEventQueue.h>

src/OpenCOVER/plugins/hlrs/JSBSim/JSBSim.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ JSBSimPlugin::JSBSimPlugin()
5353
fprintf(stderr, "JSBSimPlugin::JSBSimPlugin\n");
5454
geometryTrans = new osg::MatrixTransform();
5555

56+
#ifdef HAVE_AUDIO
5657
audio::Player *player = cover->getPlayer();
5758
if (coVRMSController::instance()->isMaster() && player)
5859
{
@@ -72,6 +73,7 @@ JSBSimPlugin::JSBSimPlugin()
7273
engineSource->play();
7374
windSource->play();
7475
}
76+
#endif
7577
plugin = this;
7678
udp = 0;
7779
}
@@ -907,6 +909,7 @@ bool JSBSimPlugin::update()
907909
float vSpeed = location.vUVW(3);
908910
VzLabel->setText("Vz: " + std::to_string(vSpeed));
909911
VLabel->setText("V: " + std::to_string(location.vUVW.Entry(1)) + " ; " + std::to_string(location.vUVW.Entry(2)) + " ; " + std::to_string(location.vUVW.Entry(3)));
912+
#ifdef HAVE_AUDIO
910913
float pitch = -vSpeed / 10.0;
911914
if (pitch < -1)
912915
pitch = -1;
@@ -926,6 +929,7 @@ bool JSBSimPlugin::update()
926929
varioSource->setIntensity(vol);
927930
if (vol > 1.0)
928931
vol = 1.0;
932+
#endif
929933

930934
Winds->SetWindNED(currentVelocity.y(), currentVelocity.x(), -currentVelocity.z());
931935
Winds->SetTurbGain(currentTurbulence);
@@ -979,6 +983,10 @@ void JSBSimPlugin::setEnabled(bool flag)
979983
if (flag)
980984
{
981985
reset();
986+
}
987+
#ifdef HAVE_AUDIO
988+
if (flag)
989+
{
982990
varioSource->play();
983991
windSource->play();
984992
engineSource->play();
@@ -989,6 +997,7 @@ void JSBSimPlugin::setEnabled(bool flag)
989997
windSource->stop();
990998
engineSource->stop();
991999
}
1000+
#endif
9921001
if (udp)
9931002
{
9941003
if (flag)

src/OpenCOVER/plugins/hlrs/JSBSim/JSBSim.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
#include <config/CoviseConfig.h>
2828
#include <util/byteswap.h>
2929
#include <net/covise_connect.h>
30+
#ifdef HAVE_AUDIO
3031
#include <audio/Audio.h>
3132
#include <audio/Player.h>
33+
#endif
3234

3335
#include <initialization/FGTrim.h>
3436
#include <FGFDMExec.h>
@@ -201,12 +203,14 @@ class JSBSimPlugin : public coVRPlugin, public ui::Owner, public opencover::coVR
201203
osg::Vec3 targetVelocity;
202204
float targetTurbulence;
203205

206+
#ifdef HAVE_AUDIO
204207
audio::Audio engineAudio;
205208
audio::Audio varioAudio;
206209
audio::Audio windAudio;
207210
std::shared_ptr<audio::Source> engineSource;
208211
std::shared_ptr<audio::Source> varioSource;
209212
std::shared_ptr<audio::Source> windSource;
213+
#endif
210214

211215
std::string host;
212216
unsigned short serverPort;

0 commit comments

Comments
 (0)