VANetClientImpl.cpp 47.5 KB
Newer Older
Jonas Stienen's avatar
Jonas Stienen committed
1
/*
2
 *  --------------------------------------------------------------------------------------------
Jonas Stienen's avatar
Jonas Stienen committed
3
 *
4
5
6
7
8
9
 *    VVV        VVV A           Virtual Acoustics (VA) | http://www.virtualacoustics.org
 *     VVV      VVV AAA          Licensed under the Apache License, Version 2.0
 *      VVV    VVV   AAA
 *       VVV  VVV     AAA        Copyright 2015-2017
 *        VVVVVV       AAA       Institute of Technical Acoustics (ITA)
 *         VVVV         AAA      RWTH Aachen University
Jonas Stienen's avatar
Jonas Stienen committed
10
 *
11
 *  --------------------------------------------------------------------------------------------
Jonas Stienen's avatar
Jonas Stienen committed
12
 */
13

Jonas Stienen's avatar
Jonas Stienen committed
14
15
16
17
#include "VANetClientImpl.h"
#include "VANetNetworkProtocol.h"
#include "VANetVistaCompatibility.h"

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
18
#include <VA.h>
Jonas Stienen's avatar
Jonas Stienen committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

// ViSTA includes
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaInterProcComm/Concurrency/VistaMutex.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
#include <VistaBase/VistaDefaultTimerImp.h>
#include <VistaBase/VistaExceptionBase.h>
#include <VistaBase/VistaSerializingToolset.h>
#include <VistaBase/VistaTimerImp.h>

#include <algorithm>
#include <cassert>


// Ensures that any possible call to the client
// is executed stricly serial. No two commands may
// be entered at the same time. This ensures that
// multiple client thread can use the client safely.
#define VA_MUTAL_EXCLUDE VistaMutexLock oLock( m_oCommandMutex )

// State checking macro
#define VA_REQUIRE_CONNECTED { if( m_pParent->IsConnected() == false) VA_EXCEPT2(MODAL_ERROR, "Not connected."); }


////////////////////////////////////////////////
/////// NetworkedVACore                 ////////
////////////////////////////////////////////////

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
47
class CVANetClientImpl::CNetworkedVACore : public IVAInterface
48
{
Jonas Stienen's avatar
Jonas Stienen committed
49
public:
50
	inline CNetworkedVACore( CVANetNetworkProtocol* pProtocol, CVANetClientImpl* pParent, VistaConnectionIP* pCommandChannel, VistaConnectionIP* pHeadChannel )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
51
		: IVAInterface()
52
53
54
55
		, m_pParent( pParent )
		, m_pCommandChannel( pCommandChannel )
		, m_pHeadChannel( pHeadChannel )
		, m_pProtocol( pProtocol )
Jonas Stienen's avatar
Jonas Stienen committed
56
57
58
59
60
	{
		if( m_pHeadChannel )
			m_pHeadMutex = new VistaMutex;
		else
			m_pHeadMutex = &m_oCommandMutex;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
61
	};
Jonas Stienen's avatar
Jonas Stienen committed
62

63
	inline ~CNetworkedVACore()
Jonas Stienen's avatar
Jonas Stienen committed
64
65
66
	{
		if( m_pHeadChannel )
			delete m_pHeadMutex;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
67
	};
Jonas Stienen's avatar
Jonas Stienen committed
68

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
69
70
71
72
	inline VistaMutex* GetCommandMutex()
	{
		return &m_oCommandMutex;
	};
Jonas Stienen's avatar
Jonas Stienen committed
73

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
74
75
76
77
	inline VistaMutex* GetHeadMutex()
	{
		return m_pHeadMutex;
	};
Jonas Stienen's avatar
Jonas Stienen committed
78

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
79
	inline void GetVersionInfo( CVAVersionInfo* pVersionInfo ) const
80
	{
Jonas Stienen's avatar
Jonas Stienen committed
81
82
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
83
		return m_pProtocol->ClientGetVersionInfo( pVersionInfo );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
84
	};
Jonas Stienen's avatar
Jonas Stienen committed
85

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
86
	inline void SetDebugStream( std::ostream* )
87
	{
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
88
89
		VA_EXCEPT_NOT_IMPLEMENTED;
	};
Jonas Stienen's avatar
Jonas Stienen committed
90

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
91
	inline int GetState() const
92
	{
Jonas Stienen's avatar
Jonas Stienen committed
93
94
95
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetState();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
96
	};
Jonas Stienen's avatar
Jonas Stienen committed
97

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
98
	inline void Initialize()
99
	{
Jonas Stienen's avatar
Jonas Stienen committed
100
101
102
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientInitialize();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
103
	};
Jonas Stienen's avatar
Jonas Stienen committed
104

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
105
	inline void Finalize()
106
	{
Jonas Stienen's avatar
Jonas Stienen committed
107
108
109
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientFinalize();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
110
	};
Jonas Stienen's avatar
Jonas Stienen committed
111

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
112
	inline void Reset()
113
	{
Jonas Stienen's avatar
Jonas Stienen committed
114
115
116
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientReset();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
117
	};
Jonas Stienen's avatar
Jonas Stienen committed
118

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
119
	inline void AttachCoreEventHandler( IVAEventHandler* pEventHandler )
120
	{
Jonas Stienen's avatar
Jonas Stienen committed
121
122
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
123
124
		m_pParent->AttachCoreEventHandler( pEventHandler );
	};
Jonas Stienen's avatar
Jonas Stienen committed
125

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
126
	inline void DetachCoreEventHandler( IVAEventHandler* pEventHandler )
127
	{
Jonas Stienen's avatar
Jonas Stienen committed
128
129
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
130
131
		m_pParent->DetachCoreEventHandler( pEventHandler );
	};
Jonas Stienen's avatar
Jonas Stienen committed
132
133


Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
134
135
	inline void GetModules( std::vector< CVAModuleInfo >& viModuleInfos ) const
	{
Jonas Stienen's avatar
Jonas Stienen committed
136
137
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
138
139
		m_pProtocol->ClientGetModules( viModuleInfos );
	};
Jonas Stienen's avatar
Jonas Stienen committed
140

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
141
	inline CVAStruct CallModule( const std::string& sModuleName, const CVAStruct& oArgs )
Jonas Stienen's avatar
Jonas Stienen committed
142
143
144
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
145
146
		return m_pProtocol->ClientCallModule( sModuleName, oArgs );
	};
Jonas Stienen's avatar
Jonas Stienen committed
147
148


Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
149
150
	inline int CreateDirectivityFromParameters( const CVAStruct& oParams, const std::string& sName /* = "" */ )
	{
Jonas Stienen's avatar
Jonas Stienen committed
151
152
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
153
154
		return m_pProtocol->ClientCreateDirectivityFromParameters( oParams, sName );
	};
Jonas Stienen's avatar
Jonas Stienen committed
155

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
156
157
	inline bool DeleteDirectivity( const int iID )
	{
Jonas Stienen's avatar
Jonas Stienen committed
158
159
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
160
161
		return m_pProtocol->ClientDeleteDirectivity( iID );
	};
Jonas Stienen's avatar
Jonas Stienen committed
162

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
163
164
	inline CVADirectivityInfo GetDirectivityInfo( const int iDirID ) const
	{
Jonas Stienen's avatar
Jonas Stienen committed
165
166
167
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetDirectivityInfo( iDirID );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
168
	};
Jonas Stienen's avatar
Jonas Stienen committed
169

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
170
171
	inline void GetDirectivityInfos( std::vector<CVADirectivityInfo>& vdiDest ) const
	{
Jonas Stienen's avatar
Jonas Stienen committed
172
173
174
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientGetDirectivityInfos( vdiDest );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
175
	};
Jonas Stienen's avatar
Jonas Stienen committed
176

177

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
178
179
	inline std::string CreateSignalSourceBufferFromParameters( const CVAStruct& oParams, const std::string& sName /* = "" */ )
	{
Jonas Stienen's avatar
Jonas Stienen committed
180
181
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
182
		return m_pProtocol->ClientCreateSignalSourceBufferFromParameters( oParams, sName );
183
184
	};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
185
	inline std::string CreateTextToSpeechSignalSource( const std::string& sName = "" )
186
187
188
189
190
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientCreateTextToSpeechSignalSource( sName );
	};
Jonas Stienen's avatar
Jonas Stienen committed
191

192
193
	virtual inline std::string CreateSequencerSignalSource( const std::string& sName = "" )
	{
Jonas Stienen's avatar
Jonas Stienen committed
194
195
196
197
198
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientCreateSequencerSignalSource( sName );
	}

199
200
201
	virtual std::string CreateNetworkStreamSignalSource( const std::string& sInterface,
		int iPort,
		const std::string& sName = "" ) {
Jonas Stienen's avatar
Jonas Stienen committed
202
203
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
204
		return m_pProtocol->ClientCreateNetworkStreamSignalSource( sInterface, iPort, sName );
Jonas Stienen's avatar
Jonas Stienen committed
205
206
	}

207
	virtual std::string CreateEngineSignalSource( const std::string& sName = "" )
Jonas Stienen's avatar
Jonas Stienen committed
208
209
210
211
212
213
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientCreateEngineSignalSource( sName );
	}

214
	virtual std::string CreateMachineSignalSource( const std::string& sName = "" )
Jonas Stienen's avatar
Jonas Stienen committed
215
216
217
218
219
220
221
222
223
224
225
226
227
228
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;

		return m_pProtocol->ClientCreateMachineSignalSource( sName );
	}

	virtual bool DeleteSignalSource( const std::string& sID )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientDeleteSignalSource( sID );
	}

229
230
231
	inline virtual std::string RegisterSignalSource( IVAAudioSignalSource*, const std::string& )
	{
		VA_EXCEPT2( NOT_IMPLEMENTED, "This function is not available when operating on a remote server" );
Jonas Stienen's avatar
Jonas Stienen committed
232
233
	}

234
235
236
	virtual bool UnregisterSignalSource( IVAAudioSignalSource* )
	{
		VA_EXCEPT2( NOT_IMPLEMENTED, "This function is not available when operating on a remote server" );
Jonas Stienen's avatar
Jonas Stienen committed
237
238
	}

239
240
	virtual CVASignalSourceInfo GetSignalSourceInfo( const std::string& sSignalSourceID ) const
	{
Jonas Stienen's avatar
Jonas Stienen committed
241
242
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
243
		return m_pProtocol->ClientGetSignalSourceInfo( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
244
245
	}

246
	virtual void GetSignalSourceInfos( std::vector<CVASignalSourceInfo>& vssiDest ) const {
Jonas Stienen's avatar
Jonas Stienen committed
247
248
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
249
		return m_pProtocol->ClientGetSignalSourceInfos( vssiDest );
Jonas Stienen's avatar
Jonas Stienen committed
250
251
	}

252
	virtual int GetAudiofileSignalSourcePlaybackState( const std::string& sSignalSourceID ) const {
Jonas Stienen's avatar
Jonas Stienen committed
253
254
255
256
257
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetAudiofileSignalSourcePlaybackState( sSignalSourceID );
	}

258
	virtual void SetAudiofileSignalSourcePlaybackAction( const std::string& sSignalSourceID, int iPlayState ) {
Jonas Stienen's avatar
Jonas Stienen committed
259
260
261
262
263
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetAudiofileSignalSourcePlaybackAction( sSignalSourceID, iPlayState );
	}

264
	virtual void SetAudiofileSignalSourcePlaybackPosition( const std::string& sSignalSourceID, double dPlaybackPosition ) {
Jonas Stienen's avatar
Jonas Stienen committed
265
266
267
268
269
270
271
272
273
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetAudiofileSignalSourcePlaybackPosition( sSignalSourceID, dPlaybackPosition );
	}

	virtual bool GetAudiofileSignalSourceIsLooping( const std::string& sSignalSourceID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
274
		return m_pProtocol->ClientGetSignalSourceBufferLooping( sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
275
276
	}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
277
	virtual void SetSignalSourceBufferLooping( const std::string& sSignalSourceID, const bool bLooping )
Jonas Stienen's avatar
Jonas Stienen committed
278
279
280
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
281
282
		m_pProtocol->ClientSetSignalSourceBufferLooping( sSignalSourceID, bLooping );
	};
Jonas Stienen's avatar
Jonas Stienen committed
283
284
285
286
287
288

	virtual void SetSignalSourceParameters( const std::string& sSignalSourceID, const CVAStruct& oParams )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetSignalSourceParameters( sSignalSourceID, oParams );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
289
	};
Jonas Stienen's avatar
Jonas Stienen committed
290
291
292
293
294
295

	virtual CVAStruct GetSignalSourceParameters( const std::string& sSignalSourceID, const CVAStruct& oParams ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSignalSourceParameters( sSignalSourceID, oParams );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
296
	};
Jonas Stienen's avatar
Jonas Stienen committed
297

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
298
299
	virtual bool IsSceneLocked() const
	{
Jonas Stienen's avatar
Jonas Stienen committed
300
301
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
302
303
		return m_pProtocol->ClientGetUpdateLocked();
	};
Jonas Stienen's avatar
Jonas Stienen committed
304
305
306
307

	virtual void LockScene() {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
308
		m_pProtocol->ClientLockUpdate();
Jonas Stienen's avatar
Jonas Stienen committed
309
310
311
312
313
314
315
316
317
318
319
320
321
322
	}

	virtual int UnlockScene() {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientUnlockScene();
	}

	/* +----------------------------------------------------------+ *
	 * |                                                          | *
	 * |   Sound sources                                          | *
	 * |                                                          | *
	 * +----------------------------------------------------------+ */

323
	virtual void GetSoundSourceIDs( std::vector<int>& vSoundSourceIDs ) {
Jonas Stienen's avatar
Jonas Stienen committed
324
325
326
327
328
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSoundSourceIDs( vSoundSourceIDs );
	}

329
330
331
332
333
334
	virtual int CreateSoundSource( const std::string& sName,
		int iAuralizationMode = VA_AURAMODE_ALL,
		double dVolume = 1.0 ) {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientCreateSoundSource( sName, iAuralizationMode, dVolume );
Jonas Stienen's avatar
Jonas Stienen committed
335
336
337
338
	}

	virtual int CreateSoundSourceExplicitRenderer( const std::string& sName, const std::string& sRendererID )
	{
339
340
341
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientCreateSoundSourceExplicitRenderer( sName, sRendererID );
Jonas Stienen's avatar
Jonas Stienen committed
342
343
	}

344
	virtual int DeleteSoundSource( int iSoundSourceID ) {
Jonas Stienen's avatar
Jonas Stienen committed
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientDeleteSoundSource( iSoundSourceID );
	}

	virtual void SetSoundSourceEnabled( int iSoundSourceID, bool bEnabled )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientSetSoundSourceEnabled( iSoundSourceID, bEnabled );
	}

	virtual bool GetSoundSourceEnabled( int iSoundSourceID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSoundSourceEnabled( iSoundSourceID );
	}

364
	virtual std::string GetSoundSourceName( int iSoundSourceID ) const{
Jonas Stienen's avatar
Jonas Stienen committed
365
366
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
367
		return m_pProtocol->ClientGetSoundSourceName( iSoundSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
368
369
	}

370
	virtual void SetSoundSourceName( int iSoundSourceID, const std::string& sName ) {
Jonas Stienen's avatar
Jonas Stienen committed
371
372
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
373
		m_pProtocol->ClientSetSoundSourceName( iSoundSourceID, sName );
Jonas Stienen's avatar
Jonas Stienen committed
374
375
	}

376
	virtual std::string GetSoundSourceSignalSource( int iSoundSourceID ) const{
Jonas Stienen's avatar
Jonas Stienen committed
377
378
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
379
		return m_pProtocol->ClientGetSoundSourceSignalSource( iSoundSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
380
381
	}

382
	virtual void SetSoundSourceSignalSource( int iSoundSourceID, const std::string& sSignalSourceID ) {
Jonas Stienen's avatar
Jonas Stienen committed
383
384
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
385
		m_pProtocol->ClientSetSoundSourceSignalSource( iSoundSourceID, sSignalSourceID );
Jonas Stienen's avatar
Jonas Stienen committed
386
387
	}

388
	virtual int GetSoundSourceAuralizationMode( int iSoundSourceID ) const{
Jonas Stienen's avatar
Jonas Stienen committed
389
390
391
392
393
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSoundSourceAuralizationMode( iSoundSourceID );
	}

394
	virtual void SetSoundSourceAuralizationMode( int iSoundSourceID, int iAuralizationMode ) {
Jonas Stienen's avatar
Jonas Stienen committed
395
396
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
397
		m_pProtocol->ClientSetSoundSourceAuralizationMode( iSoundSourceID, iAuralizationMode );
Jonas Stienen's avatar
Jonas Stienen committed
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
	}

	virtual CVAStruct GetSoundSourceParameters( int iID, const CVAStruct& oArgs ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSoundSourceParameters( iID, oArgs );
	}

	virtual void SetSoundSourceParameters( int iID, const CVAStruct& oParams )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetSoundSourceParameters( iID, oParams );
	}

414
	virtual int GetSoundSourceDirectivity( int iSoundSourceID ) const {
Jonas Stienen's avatar
Jonas Stienen committed
415
416
417
418
419
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSoundSourceDirectivity( iSoundSourceID );
	}

420
	virtual void SetSoundSourceDirectivity( int iSoundSourceID, int iDirectivityID ) {
Jonas Stienen's avatar
Jonas Stienen committed
421
422
423
424
425
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientSetSoundSourceDirectivity( iSoundSourceID, iDirectivityID );
	}

426
	virtual double GetSoundSourceVolume( int iSoundSourceID ) const{
Jonas Stienen's avatar
Jonas Stienen committed
427
428
429
430
431
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSoundSourceVolume( iSoundSourceID );
	}

432
	virtual void SetSoundSourceVolume( int iSoundSourceID, double dGain ) {
Jonas Stienen's avatar
Jonas Stienen committed
433
434
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
435
		m_pProtocol->ClientSetSoundSourceVolume( iSoundSourceID, dGain );
Jonas Stienen's avatar
Jonas Stienen committed
436
437
	}

438
	virtual bool IsSoundSourceMuted( int iSoundSourceID ) const{
Jonas Stienen's avatar
Jonas Stienen committed
439
440
441
442
443
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientIsSoundSourceMuted( iSoundSourceID );
	}

444
	virtual void SetSoundSourceMuted( int iSoundSourceID, bool bMuted ) {
Jonas Stienen's avatar
Jonas Stienen committed
445
446
447
448
449
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetSoundSourceMuted( iSoundSourceID, bMuted );
	}

450
451
	virtual void GetSoundSourcePosition( int iSoundSourceID,
		double& x, double& y, double& z ) {
Jonas Stienen's avatar
Jonas Stienen committed
452
453
454
455
456
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientGetSoundSourcePosition( iSoundSourceID, x, y, z );
	}

457
458
	virtual void GetSoundSourceOrientationYPR( int iSoundSourceID,
		double& yaw, double& pitch, double& roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
459
460
461
462
463
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientGetSoundSourceOrientationYPR( iSoundSourceID, yaw, pitch, roll );
	}

464
465
466
	virtual void GetSoundSourceOrientationVU( int iSoundSourceID,
		double& vx, double& vy, double& vz,
		double& ux, double& uy, double& uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
467
468
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
469
		m_pProtocol->ClientGetSoundSourceOrientationVU( iSoundSourceID, vx, vy, vz, ux, uy, uz );
Jonas Stienen's avatar
Jonas Stienen committed
470
471
	}

472
473
474
	virtual void GetSoundSourcePositionOrientationYPR( int iSoundSourceID,
		double& x, double& y, double& z,
		double& yaw, double& pitch, double& roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
475
476
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
477
		m_pProtocol->ClientGetSoundSourcePositionOrientationYPR( iSoundSourceID, x, y, z, yaw, pitch, roll );
Jonas Stienen's avatar
Jonas Stienen committed
478
479
	}

480
481
482
483
	virtual void GetSoundSourcePositionOrientationVU( int iSoundSourceID,
		double& px, double& py, double& pz,
		double& vx, double& vy, double& vz,
		double& ux, double& uy, double& uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
484
485
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
486
		m_pProtocol->ClientGetSoundSourcePositionOrientationVU( iSoundSourceID, px, py, pz, vx, vy, vz, ux, uy, uz );
Jonas Stienen's avatar
Jonas Stienen committed
487
488
	}

489
490
491
492
	virtual void GetSoundSourcePositionOrientationVelocityYPR( int iSoundSourceID,
		double& dPosX, double& dPosY, double& dPosZ,
		double& dYaw, double& dPitch, double& dRoll,
		double& dVelocityX, double& dVelocityY, double& dVelocityZ ) {
Jonas Stienen's avatar
Jonas Stienen committed
493
494
495
496
497
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientGetSoundSourcePositionOrientationVelocityYPR( iSoundSourceID, dPosX, dPosY, dPosZ, dYaw, dPitch, dRoll, dVelocityX, dVelocityY, dVelocityZ );
	}

498
499
500
501
502
503
	virtual void GetSoundSourcePositionOrientationVelocityVU( int iSoundSourceID,
		double& dPosX, double& dPosY, double& dPosZ,
		double& dViewX, double& dViewY, double& dViewZ,
		double& dUpX, double& dUpY, double& dUpZ,
		double& dVelocityX, double& dVelocityY, double& dVelocityZ ) {
		VA_REQUIRE_CONNECTED;
Jonas Stienen's avatar
Jonas Stienen committed
504
		VA_MUTAL_EXCLUDE;
505
		m_pProtocol->ClientGetSoundSourcePositionOrientationVelocityVU( iSoundSourceID, dPosX, dPosY, dPosZ, dViewX, dViewY, dViewZ, dUpX, dUpY, dUpZ, dVelocityX, dVelocityY, dVelocityZ );
Jonas Stienen's avatar
Jonas Stienen committed
506
507
	}

508
509
	virtual void SetSoundSourcePosition( int iSoundSourceID,
		double x, double y, double z ) {
Jonas Stienen's avatar
Jonas Stienen committed
510
511
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
512
		m_pProtocol->ClientSetSoundSourcePosition( iSoundSourceID, x, y, z );
Jonas Stienen's avatar
Jonas Stienen committed
513
514
	}

515
516
	virtual void SetSoundSourceOrientationYPR( int iSoundSourceID,
		double yaw, double pitch, double roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
517
518
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
519
		m_pProtocol->ClientSetSoundSourceOrientationYPR( iSoundSourceID, yaw, pitch, roll );
Jonas Stienen's avatar
Jonas Stienen committed
520
521
	}

522
523
524
	virtual void SetSoundSourceOrientationVU( int iSoundSourceID,
		double vx, double vy, double vz,
		double ux, double uy, double uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
525
526
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
527
		m_pProtocol->ClientSetSoundSourceOrientationVU( iSoundSourceID, vx, vy, vz, ux, uy, uz );
Jonas Stienen's avatar
Jonas Stienen committed
528
529
	}

530
531
532
	virtual void SetSoundSourcePositionOrientationYPR( int iSoundSourceID,
		double x, double y, double z,
		double yaw, double pitch, double roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
533
534
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
535
		m_pProtocol->ClientSetSoundSourcePositionOrientationYPR( iSoundSourceID, x, y, z, yaw, pitch, roll );
Jonas Stienen's avatar
Jonas Stienen committed
536
537
	}

538
539
540
541
	virtual void SetSoundSourcePositionOrientationVU( int iSoundSourceID,
		double px, double py, double pz,
		double vx, double vy, double vz,
		double ux, double uy, double uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
542
543
544
545
546
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetSoundSourcePositionOrientationVU( iSoundSourceID, px, py, pz, vx, vy, vz, ux, uy, uz );
	}

547
548
549
550
	virtual void SetSoundSourcePositionOrientationVelocityYPR( int iSoundSourceID,
		double dPosX, double dPosY, double dPosZ,
		double dYaw, double dPitch, double dRoll,
		double dVelocityX, double dVelocityY, double dVelocityZ ) {
Jonas Stienen's avatar
Jonas Stienen committed
551
552
553
554
555
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetSoundSourcePositionOrientationVelocityYPR( iSoundSourceID, dPosX, dPosY, dPosZ, dYaw, dPitch, dRoll, dVelocityX, dVelocityY, dVelocityZ );
	}

556
557
558
559
560
	virtual void SetSoundSourcePositionOrientationVelocityVU( int iSoundSourceID,
		double dPosX, double dPosY, double dPosZ,
		double dViewX, double dViewY, double dViewZ,
		double dUpX, double dUpY, double dUpZ,
		double dVelocityX, double dVelocityY, double dVelocityZ ) {
Jonas Stienen's avatar
Jonas Stienen committed
561
562
563
564
565
566
567
568
569
570
571
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetSoundSourcePositionOrientationVelocityVU( iSoundSourceID, dPosX, dPosY, dPosZ, dViewX, dViewY, dViewZ, dUpX, dUpY, dUpZ, dVelocityX, dVelocityY, dVelocityZ );
	}

	/* +----------------------------------------------------------+ *
	 * |                                                          | *
	 * |   Listeners                                              | *
	 * |                                                          | *
	 * +----------------------------------------------------------+ */

572
	virtual void GetListenerIDs( std::vector<int>& vListenerIDs ) {
Jonas Stienen's avatar
Jonas Stienen committed
573
574
575
576
577
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientGetListenerIDs( vListenerIDs );
	}

578
579
580
581
582
583
	virtual int CreateListener( const std::string& sName,
		int iAuralizationMode = VA_AURAMODE_ALL,
		int iHRIRDatasetID = -1 ) {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientCreateListener( sName, iAuralizationMode, iHRIRDatasetID );
Jonas Stienen's avatar
Jonas Stienen committed
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
	}

	virtual int CreateListenerExplicitRenderer( const std::string& sName, const std::string& sRendererID )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientCreateListenerExplicitRenderer( sName, sRendererID );
	}

	virtual void SetActiveListenerExplicitRenderer( int iListenerID, const std::string& sRendererID )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientSetActiveListenerExplicitRenderer( iListenerID, sRendererID );
	}

	virtual int GetActiveListenerExplicitRenderer( const std::string& sRendererID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetActiveListenerExplicitRenderer( sRendererID );
	}

607
	virtual int DeleteListener( int iListenerID ) {
Jonas Stienen's avatar
Jonas Stienen committed
608
609
610
611
612
613
614
615
616
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientDeleteListener( iListenerID );
	}

	virtual void SetListenerEnabled( int iListenerID, bool bEnabled )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
617
		return m_pProtocol->ClientSetSoundReceiverEnabled( iListenerID, bEnabled );
Jonas Stienen's avatar
Jonas Stienen committed
618
619
620
621
622
623
624
625
626
	}

	virtual bool GetListenerEnabled( int iListenerID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetListenerEnabled( iListenerID );
	}

627
	virtual std::string GetListenerName( int iListenerID ) const{
Jonas Stienen's avatar
Jonas Stienen committed
628
629
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
630
		return m_pProtocol->ClientGetSoundReceiverName( iListenerID );
Jonas Stienen's avatar
Jonas Stienen committed
631
632
	}

633
	virtual void SetListenerName( int iListenerID, const std::string& sName ) {
Jonas Stienen's avatar
Jonas Stienen committed
634
635
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
636
		m_pProtocol->ClientSetSoundReceiverName( iListenerID, sName );
Jonas Stienen's avatar
Jonas Stienen committed
637
638
	}

639
	virtual int GetListenerAuralizationMode( int iListenerID ) const{
Jonas Stienen's avatar
Jonas Stienen committed
640
641
642
643
644
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetListenerAuralizationMode( iListenerID );
	}

645
	virtual void SetListenerAuralizationMode( int iListenerID, int iAuralizationMode ) {
Jonas Stienen's avatar
Jonas Stienen committed
646
647
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
648
		m_pProtocol->ClientSetListenerAuralizationMode( iListenerID, iAuralizationMode );
Jonas Stienen's avatar
Jonas Stienen committed
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
	}

	virtual CVAStruct GetListenerParameters( int iID, const CVAStruct& oArgs ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetListenerParameters( iID, oArgs );
	}

	virtual void SetListenerParameters( int iID, const CVAStruct& oParams )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetListenerParameters( iID, oParams );
	}

665
	virtual int GetListenerHRIRDataset( int iListenerID ) const {
Jonas Stienen's avatar
Jonas Stienen committed
666
667
668
669
670
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetListenerHRIRDataset( iListenerID );
	}

671
	virtual void SetListenerHRIRDataset( int iListenerID, int iHRIRDatasetID ) {
Jonas Stienen's avatar
Jonas Stienen committed
672
673
674
675
676
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetListenerHRIRDataset( iListenerID, iHRIRDatasetID );
	}

677
678
	virtual void GetListenerPosition( int iListenerID,
		double& x, double& y, double& z ) {
Jonas Stienen's avatar
Jonas Stienen committed
679
680
681
682
683
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientGetListenerPosition( iListenerID, x, y, z );
	}

684
685
	virtual void GetListenerOrientationYPR( int iListenerID,
		double& yaw, double& pitch, double& roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
686
687
688
689
690
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientGetListenerOrientationYPR( iListenerID, yaw, pitch, roll );
	}

691
692
693
	virtual void GetListenerOrientationVU( int iListenerID,
		double& vx, double& vy, double& vz,
		double& ux, double& uy, double& uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
694
695
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
696
		m_pProtocol->ClientGetListenerOrientationVU( iListenerID, vx, vy, vz, ux, uy, uz );
Jonas Stienen's avatar
Jonas Stienen committed
697
698
	}

699
700
701
	virtual void GetListenerPositionOrientationYPR( int iListenerID,
		double& x, double& y, double& z,
		double& yaw, double& pitch, double& roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
702
703
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
704
		m_pProtocol->ClientGetListenerPositionOrientationYPR( iListenerID, x, y, z, yaw, pitch, roll );
Jonas Stienen's avatar
Jonas Stienen committed
705
706
	}

707
708
709
710
	virtual void GetListenerPositionOrientationVU( int iListenerID,
		double& px, double& py, double& pz,
		double& vx, double& vy, double& vz,
		double& ux, double& uy, double& uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
711
712
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
713
		m_pProtocol->ClientGetListenerPositionOrientationVU( iListenerID, px, py, pz, vx, vy, vz, ux, uy, uz );
Jonas Stienen's avatar
Jonas Stienen committed
714
715
	}

716
717
718
719
	virtual void GetListenerPositionOrientationVelocityYPR( int iListenerID,
		double& dPosX, double& dPosY, double& dPosZ,
		double& dYaw, double& dPitch, double& dRoll,
		double& dVelocityX, double& dVelocityY, double& dVelocityZ ) {
Jonas Stienen's avatar
Jonas Stienen committed
720
721
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
722
		m_pProtocol->ClientGetListenerPositionOrientationVelocityYPR( iListenerID, dPosX, dPosY, dPosZ, dYaw, dPitch, dRoll, dVelocityX, dVelocityY, dVelocityZ );
Jonas Stienen's avatar
Jonas Stienen committed
723
724
	}

725
726
727
728
729
	virtual void GetListenerPositionOrientationVelocityVU( int iListenerID,
		double& dPosX, double& dPosY, double& dPosZ,
		double& dViewX, double& dViewY, double& dViewZ,
		double& dUpX, double& dUpY, double& dUpZ,
		double& dVelocityX, double& dVelocityY, double& dVelocityZ ) {
Jonas Stienen's avatar
Jonas Stienen committed
730
731
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
732
		m_pProtocol->ClientGetListenerPositionOrientationVelocityVU( iListenerID, dPosX, dPosY, dPosZ, dViewX, dViewY, dViewZ, dUpX, dUpY, dUpZ, dVelocityX, dVelocityY, dVelocityZ );
Jonas Stienen's avatar
Jonas Stienen committed
733
734
	}

735
736
	virtual void SetListenerPosition( int iListenerID,
		double x, double y, double z ) {
Jonas Stienen's avatar
Jonas Stienen committed
737
738
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
739
		m_pProtocol->ClientSetListenerPosition( iListenerID, x, y, z );
Jonas Stienen's avatar
Jonas Stienen committed
740
741
	}

742
743
	virtual void SetListenerOrientationYPR( int iListenerID,
		double yaw, double pitch, double roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
744
745
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
746
		m_pProtocol->ClientSetListenerOrientationYPR( iListenerID, yaw, pitch, roll );
Jonas Stienen's avatar
Jonas Stienen committed
747
748
	}

749
750
751
	virtual void SetListenerOrientationVU( int iListenerID,
		double vx, double vy, double vz,
		double ux, double uy, double uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
752
753
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
754
		m_pProtocol->ClientSetListenerOrientationVU( iListenerID, vx, vy, vz, ux, uy, uz );
Jonas Stienen's avatar
Jonas Stienen committed
755
756
	}

757
758
759
	virtual void SetListenerPositionOrientationYPR( int iListenerID,
		double x, double y, double z,
		double yaw, double pitch, double roll ) {
Jonas Stienen's avatar
Jonas Stienen committed
760
761
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
762
		m_pProtocol->ClientSetListenerPositionOrientationYPR( iListenerID, x, y, z, yaw, pitch, roll );
Jonas Stienen's avatar
Jonas Stienen committed
763
764
	}

765
766
767
768
	virtual void SetListenerPositionOrientationVU( int iListenerID,
		double px, double py, double pz,
		double vx, double vy, double vz,
		double ux, double uy, double uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
769
770
771
772
773
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
		m_pProtocol->ClientSetListenerPositionOrientationVU( iListenerID, px, py, pz, vx, vy, vz, ux, uy, uz );
	}

774
775
776
777
	virtual void SetListenerPositionOrientationVelocityYPR( int iListenerID,
		double dPosX, double dPosY, double dPosZ,
		double dYaw, double dPitch, double dRoll,
		double dVelocityX, double dVelocityY, double dVelocityZ ) {
Jonas Stienen's avatar
Jonas Stienen committed
778
779
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
780
		m_pProtocol->ClientSetListenerPositionOrientationVelocityYPR( iListenerID, dPosX, dPosY, dPosZ, dYaw, dPitch, dRoll, dVelocityX, dVelocityY, dVelocityZ );
Jonas Stienen's avatar
Jonas Stienen committed
781
782
	}

783
784
785
786
787
	virtual void SetListenerPositionOrientationVelocityVU( int iListenerID,
		double dPosX, double dPosY, double dPosZ,
		double dViewX, double dViewY, double dViewZ,
		double dUpX, double dUpY, double dUpZ,
		double dVelocityX, double dVelocityY, double dVelocityZ ) {
Jonas Stienen's avatar
Jonas Stienen committed
788
789
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
790
		m_pProtocol->ClientSetListenerPositionOrientationVelocityVU( iListenerID, dPosX, dPosY, dPosZ, dViewX, dViewY, dViewZ, dUpX, dUpY, dUpZ, dVelocityX, dVelocityY, dVelocityZ );
Jonas Stienen's avatar
Jonas Stienen committed
791
792
	}

793
794
795
796
	virtual void GetListenerRealWorldHeadPositionOrientationVU( int iListenerID,
		double& px, double& py, double& pz,
		double& vx, double& vy, double& vz,
		double& ux, double& uy, double& uz ) const {
Jonas Stienen's avatar
Jonas Stienen committed
797
798
799
800
801
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
		m_pProtocol->ClientGetListenerRealWorldHeadPositionOrientationVU( iListenerID, px, py, pz, vx, vy, vz, ux, uy, uz );
	}

802
803
804
805
	virtual void SetListenerRealWorldHeadPositionOrientationVU( int iListenerID,
		double px, double py, double pz,
		double vx, double vy, double vz,
		double ux, double uy, double uz ) {
Jonas Stienen's avatar
Jonas Stienen committed
806
807
808
809
810
811
812
813
814
815
816
		VA_REQUIRE_CONNECTED;
		VistaMutexLock oLock( *m_pHeadMutex );
		m_pProtocol->ClientSetListenerRealWorldHeadPositionOrientationVU( iListenerID, px, py, pz, vx, vy, vz, ux, uy, uz );
	}

	/* +----------------------------------------------------------+ *
	 * |                                                          | *
	 * |   Scene                                                  | *
	 * |                                                          | *
	 * +----------------------------------------------------------+ */

817
	virtual void LoadScene( const std::string& sFilename ) {
Jonas Stienen's avatar
Jonas Stienen committed
818
819
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
820
		m_pProtocol->ClientLoadScene( sFilename );
Jonas Stienen's avatar
Jonas Stienen committed
821
822
823
824
825
826
827
828
829
830
831
832
833
834
	}

	virtual bool IsSceneLoaded() const {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientIsSceneLoaded();
	}

	virtual CVASceneInfo GetSceneInfo() const {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetSceneInfo();
	}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
835
836
	inline void GetPortalIDs( std::vector<int>& viIDs )
	{
Jonas Stienen's avatar
Jonas Stienen committed
837
838
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
839
		m_pProtocol->ClientGetPortalIDs( viIDs );
Jonas Stienen's avatar
Jonas Stienen committed
840
841
	}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
842
843
	inline std::string GetPortalName( const int iID ) const
	{
Jonas Stienen's avatar
Jonas Stienen committed
844
845
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
846
		return m_pProtocol->ClientGetPortalName( iID );
Jonas Stienen's avatar
Jonas Stienen committed
847
848
	}

849
	virtual void SetPortalName( int iPortalID, const std::string& sName ) {
Jonas Stienen's avatar
Jonas Stienen committed
850
851
852
853
854
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetPortalName( iPortalID, sName );
	}

855
	virtual double GetPortalState( int iPortalID ) const {
Jonas Stienen's avatar
Jonas Stienen committed
856
857
858
859
860
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetPortalState( iPortalID );
	}

861
	virtual void SetPortalState( int iPortalID, double dState ) {
Jonas Stienen's avatar
Jonas Stienen committed
862
863
864
865
866
867
868
869
870
871
872
873
874
875
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetPortalState( iPortalID, dState );
	}

	/* +----------------------------------------------------------+ *
	 * |                                                          | *
	 * |   Globals functions                                      | *
	 * |                                                          | *
	 * +----------------------------------------------------------+ */

	virtual bool IsInputMuted() const {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
876
		return m_pProtocol->ClientGetInputMuted();
Jonas Stienen's avatar
Jonas Stienen committed
877
878
	}

879
	virtual void SetInputMuted( bool bMuted ) {
Jonas Stienen's avatar
Jonas Stienen committed
880
881
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
882
		m_pProtocol->ClientSetInputMuted( bMuted );
Jonas Stienen's avatar
Jonas Stienen committed
883
884
885
886
887
888
889
890
	}

	virtual double GetInputGain() const{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetInputGain();
	}

891
	virtual void SetInputGain( double dGain ) {
Jonas Stienen's avatar
Jonas Stienen committed
892
893
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
894
		m_pProtocol->ClientSetInputGain( dGain );
Jonas Stienen's avatar
Jonas Stienen committed
895
896
897
898
899
900
901
	}

	virtual double GetOutputGain() const{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetOutputGain();
	}
902
903

	virtual void SetOutputGain( double dGain ) {
Jonas Stienen's avatar
Jonas Stienen committed
904
905
906
907
908
909
910
911
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetOutputGain( dGain );
	}

	virtual bool IsOutputMuted() const{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
912
		return m_pProtocol->ClientGetOutputMuted();
Jonas Stienen's avatar
Jonas Stienen committed
913
914
	}

915
	virtual void SetOutputMuted( bool bMuted ) {
Jonas Stienen's avatar
Jonas Stienen committed
916
917
918
919
920
921
922
923
924
925
926
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetOutputMuted( bMuted );
	}

	virtual int GetGlobalAuralizationMode() const{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetGlobalAuralizationMode();
	}

927
	virtual void SetGlobalAuralizationMode( int iAuralizationMode ) {
Jonas Stienen's avatar
Jonas Stienen committed
928
929
930
931
932
933
934
935
936
937
938
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetGlobalAuralizationMode( iAuralizationMode );
	}

	virtual int GetActiveListener() const{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetActiveListener();
	}

939
	virtual void SetActiveListener( int iListenerID ) {
Jonas Stienen's avatar
Jonas Stienen committed
940
941
942
943
944
945
946
947
948
949
950
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetActiveListener( iListenerID );
	}

	virtual double GetCoreClock() const {
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetCoreClock();
	}

951
	virtual void SetCoreClock( double dSeconds ) {
Jonas Stienen's avatar
Jonas Stienen committed
952
953
954
955
956
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetCoreClock( dSeconds );
	}

957
	virtual std::string SubstituteMacros( const std::string& sStr ) const {
Jonas Stienen's avatar
Jonas Stienen committed
958
959
960
961
962
963
964
965
966
967
968
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientSubstituteMacros( sStr );
	}

	/* +----------------------------------------------------------+ *
	 * |                                                          | *
	 * |   Rendering and reproduction                             | *
	 * |                                                          | *
	 * +----------------------------------------------------------+ */

969
	virtual void GetRenderingModules( std::vector< CVAAudioRendererInfo >& voRenderer, bool bFilterEnabled ) const
Jonas Stienen's avatar
Jonas Stienen committed
970
971
972
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
973
		m_pProtocol->ClientGetRenderingModuleInfos( voRenderer, bFilterEnabled );
Jonas Stienen's avatar
Jonas Stienen committed
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
	}

	virtual void SetRenderingModuleMuted( const std::string& sModuleID, bool bMuted )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetRenderingModuleMuted( sModuleID, bMuted );
	}

	virtual bool IsRenderingModuleMuted( const std::string& sModuleID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientIsRenderingModuleMuted( sModuleID );
	}

	virtual void SetRenderingModuleGain( const std::string& sModuleID, double dGain )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetRenderingModuleGain( sModuleID, dGain );
	}

	virtual double GetRenderingModuleGain( const std::string& sModuleID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetRenderingModuleGain( sModuleID );
	}

1004
	virtual void GetReproductionModules( std::vector< CVAAudioReproductionInfo >& voRepros, bool bFilterEnabled ) const
Jonas Stienen's avatar
Jonas Stienen committed
1005
1006
1007
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
1008
		m_pProtocol->ClientGetReproductionModuleInfos( voRepros, bFilterEnabled );
Jonas Stienen's avatar
Jonas Stienen committed
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
	}

	virtual void SetReproductionModuleMuted( const std::string& sModuleID, bool bMuted )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetReproductionModuleMuted( sModuleID, bMuted );
	}

	virtual bool IsReproductionModuleMuted( const std::string& sModuleID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientIsReproductionModuleMuted( sModuleID );
	}

	virtual void SetReproductionModuleGain( const std::string& sModuleID, double dGain )
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		m_pProtocol->ClientSetReproductionModuleGain( sModuleID, dGain );
	}

	virtual double GetReproductionModuleGain( const std::string& sModuleID ) const
	{
		VA_REQUIRE_CONNECTED;
		VA_MUTAL_EXCLUDE;
		return m_pProtocol->ClientGetReproductionModuleGain( sModuleID );
	}

protected:
	CVANetClientImpl*			m_pParent;
	VistaConnectionIP*			m_pCommandChannel;
	VistaConnectionIP*			m_pHeadChannel;
	CVANetNetworkProtocol*		m_pProtocol;

	mutable VistaMutex			m_oCommandMutex;
	VistaMutex*					m_pHeadMutex;
};


/* +----------------------------------------------------------+ *
 * |                                                          | *
 * |   Class CEventReceiver                                   | *
 * |                                                          | *
 * +----------------------------------------------------------+ */


class CVANetClientImpl::CEventReceiver : public VistaThreadLoop
{
public:
1060
1061
1062
1063
1064
1065
	inline CEventReceiver( CVANetClientImpl* pParent, CVANetNetworkProtocol* pProtocol, VistaConnectionIP* pConnection, VistaMutex* pEventChannelLock )
		: VistaThreadLoop()
		, m_pParent( pParent )
		, m_pProtocol( pProtocol )
		, m_pEventChannel( pConnection )
		, m_pEventChannelLock( pEventChannelLock )
Jonas Stienen's avatar
Jonas Stienen committed
1066
1067
1068
1069
	{
		SetThreadName( "VA-Server Connection Observer" );
	}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1070
	inline void AttachCoreEventHandler( IVAEventHandler* pCoreEventHandler )
Jonas Stienen's avatar
Jonas Stienen committed
1071
1072
	{
		VistaMutexLock oLock( m_oHandlerListLock );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1073
		std::list<IVAEventHandler*>::iterator itEntry = std::find( m_liCoreEventHandlers.begin(), m_liCoreEventHandlers.end(), pCoreEventHandler );
Jonas Stienen's avatar
Jonas Stienen committed
1074
1075
		if( itEntry != m_liCoreEventHandlers.end() )
			return;
1076

Jonas Stienen's avatar
Jonas Stienen committed
1077
		m_liCoreEventHandlers.push_back( pCoreEventHandler );
1078
1079
	};

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1080
	inline void DetachCoreEventHandler( IVAEventHandler* pCoreEventHandler )
Jonas Stienen's avatar
Jonas Stienen committed
1081
1082
	{
		VistaMutexLock oLock( m_oHandlerListLock );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1083
		std::list<IVAEventHandler*>::iterator itEntry = std::find( m_liCoreEventHandlers.begin(), m_liCoreEventHandlers.end(), pCoreEventHandler );
Jonas Stienen's avatar
Jonas Stienen committed
1084
1085
		if( itEntry == m_liCoreEventHandlers.end() )
			return;
1086

Jonas Stienen's avatar
Jonas Stienen committed
1087
		m_liCoreEventHandlers.erase( itEntry );
1088
	};
Jonas Stienen's avatar
Jonas Stienen committed
1089

1090
	inline virtual bool LoopBody()
Jonas Stienen's avatar
Jonas Stienen committed
1091
1092
1093
1094
1095
1096
1097
	{
		try
		{
			// to allow external stopping of this thread, we only block for at most
			// 100ms
			if( m_pEventChannel->WaitForIncomingData( 100 ) == ~0 )
				return false;
1098

Jonas Stienen's avatar
Jonas Stienen committed
1099
1100
			VistaMutexLock oListLock( m_oHandlerListLock );
			VistaMutexLock oChannelLock( *m_pEventChannelLock );
1101
			if( m_pProtocol->ClientProcessEventMessageFromServer( m_pEventChannel, m_liCoreEventHandlers ) == CVANetNetworkProtocol::VA_EVENT_FAIL )
Jonas Stienen's avatar
Jonas Stienen committed
1102
1103
1104
1105
1106
			{
				oListLock.Unlock();
				oChannelLock.Unlock();
				IndicateLoopEnd();
				m_pParent->ProcessEventChannelError();
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1107
			}
Jonas Stienen's avatar
Jonas Stienen committed
1108
		}
1109
#ifdef VANET_CLIENT_VERBOSE
Jonas Stienen's avatar
Jonas Stienen committed
1110
1111
		catch( VistaExceptionBase& oException )
		{
1112
			std::cout << "VANetClient: EventReceiver encountered connection error - " << oException.GetExceptionText() << std::endl;
1113
1114
1115
#else
		catch( VistaExceptionBase& )
		{
Jonas Stienen's avatar
Jonas Stienen committed
1116
#endif
1117
			IndicateLoopEnd();
Jonas Stienen's avatar
Jonas Stienen committed
1118
1119
			m_pParent->ProcessEventChannelError();
		}
1120
#ifdef VANET_CLIENT_VERBOSE
Jonas Stienen's avatar
Jonas Stienen committed
1121
1122
		catch( CVAException& oException )
		{
1123
			std::cout << "VANetClient: EventReceiver encountered connection error - " << oException.ToString() << std::endl;
1124
1125
1126
#else
		catch( CVAException& )
		{
Jonas Stienen's avatar
Jonas Stienen committed
1127
1128
1129
1130
1131
#endif
			IndicateLoopEnd();
			m_pParent->ProcessEventChannelError();
		}
		return false;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1132
	};
Jonas Stienen's avatar
Jonas Stienen committed
1133

1134
1135
1136
	inline virtual void PreLoop()
	{
#ifdef VANET_CLIENT_VERBOSE
Jonas Stienen's avatar
Jonas Stienen committed
1137
1138
		std::cout << "VANetClient: Starting Event Observer" << std::endl;
#endif
1139
	};
Jonas Stienen's avatar
Jonas Stienen committed
1140

1141
	inline virtual void PostRun()
Jonas Stienen's avatar
Jonas Stienen committed
1142
	{
1143
#ifdef VANET_CLIENT_VERBOSE
Jonas Stienen's avatar
Jonas Stienen committed
1144
1145
		std::cout << "VANetClient: Stopping Event Observer" << std::endl;
#endif
1146
	};
Jonas Stienen's avatar
Jonas Stienen committed
1147
1148
1149
1150
1151

private:
	CVANetClientImpl*						m_pParent;
	VistaConnectionIP*						m_pEventChannel;
	CVANetNetworkProtocol*					m_pProtocol;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1152
	std::list<IVAEventHandler*>			m_liCoreEventHandlers;
Jonas Stienen's avatar
Jonas Stienen committed
1153
1154
	VistaMutex								m_oHandlerListLock;
	VistaMutex*								m_pEventChannelLock;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1155
};
Jonas Stienen's avatar
Jonas Stienen committed
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166



/* +----------------------------------------------------------+ *
 * |                                                          | *
 * |   Class CVANetClientImpl                                 | *
 * |                                                          | *
 * +----------------------------------------------------------+ */


CVANetClientImpl::CVANetClientImpl()
1167
1168
1169
1170
1171
1172
1173
1174
1175
	: m_pCommandChannel( NULL )
	, m_pEventChannel( NULL )
	, m_pHeadChannel( NULL )
	, m_pVACore( NULL )
	, m_pProtocol( NULL )
	, m_pEventReceiver( NULL )
	, m_bConnected( false )
	, m_pEventChannelLock( new VistaMutex )
	, m_bShutdownFlag( false )
Jonas Stienen's avatar
Jonas Stienen committed
1176
1177
1178
{
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1179
1180
CVANetClientImpl::~CVANetClientImpl()
{
Jonas Stienen's avatar
Jonas Stienen committed
1181
1182
1183
1184
	Disconnect();
	Cleanup();
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1185
1186
IVAInterface* CVANetClientImpl::GetCoreInstance() const
{
Jonas Stienen's avatar
Jonas Stienen committed
1187
1188
1189
	return m_pVACore;
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1190
1191
bool CVANetClientImpl::IsConnected() const
{
Jonas Stienen's avatar
Jonas Stienen committed
1192
1193
	if( m_bShutdownFlag == true )
	{
1194
		const_cast< CVANetClientImpl* >( this )->Disconnect();
Jonas Stienen's avatar
Jonas Stienen committed
1195
1196
1197
1198
1199
		return false;
	}
	return ( m_bConnected && m_pCommandChannel && m_pCommandChannel->GetIsConnected() );
}

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
1200
1201
std::string CVANetClientImpl::GetServerAddress() const
{