Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SoundManager.cpp
Go to the documentation of this file.
1  /* Copyright (C) 2013 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "precompiled.h"
19 
20 #include "ISoundManager.h"
21 #include "SoundManager.h"
22 
23 #include "ps/Filesystem.h"
24 
30 #include "ps/CLogger.h"
31 #include "ps/CStr.h"
32 #include "ps/Profiler2.h"
33 
35 
36 #define SOURCE_NUM 64
37 
38 #if CONFIG2_AUDIO
39 
41 {
43 
44 public:
46  {
47  m_Items = new ItemsList;
48  m_DeadItems = new ItemsList;
49  m_Shutdown = false;
50  m_Enabled = false;
51 
52  int ret = pthread_create(&m_WorkerThread, NULL, &RunThread, this);
53  ENSURE(ret == 0);
54  }
55 
57  {
58  delete m_Items;
59  CleanupItems();
60  delete m_DeadItems;
61  }
62 
63  void SetEnabled(bool enabled)
64  {
66  if (enabled != m_Enabled)
67  {
68  m_Enabled = enabled;
69  }
70  }
71 
72  bool Shutdown()
73  {
74  {
76 
77  m_Shutdown = true;
78  m_Enabled = false;
79 
80  ItemsList::iterator lstr = m_Items->begin();
81  while (lstr != m_Items->end())
82  {
83  delete *lstr;
84  ++lstr;
85  }
86 
87  }
88 
90 
91  return true;
92  }
93 
94  void addItem( ISoundItem* anItem )
95  {
97  m_Items->push_back( anItem );
98  }
99 
101  {
103  AL_CHECK
104  ItemsList::iterator deadItems = m_DeadItems->begin();
105  while (deadItems != m_DeadItems->end())
106  {
107  delete *deadItems;
108  ++deadItems;
109 
110  AL_CHECK
111  }
112  m_DeadItems->clear();
113  }
114 
115 private:
116  static void* RunThread(void* data)
117  {
118  debug_SetThreadName("CSoundManagerWorker");
119  g_Profiler2.RegisterCurrentThread("soundmanager");
120 
121  static_cast<CSoundManagerWorker*>(data)->Run();
122 
123  return NULL;
124  }
125 
126  void Run()
127  {
128  while ( true )
129  {
130  g_Profiler2.RecordRegionLeave("semaphore wait");
131 
132  // Handle shutdown requests as soon as possible
133  if (GetShutdown())
134  return;
135 
136  // If we're not enabled, ignore this wakeup
137  if (!GetEnabled())
138  continue;
139 
140  int pauseTime = 500;
141  if ( g_SoundManager->InDistress() )
142  pauseTime = 50;
143 
144  {
146 
147  ItemsList::iterator lstr = m_Items->begin();
148  ItemsList* nextItemList = new ItemsList;
149 
150 
151  while (lstr != m_Items->end()) {
152 
153  AL_CHECK
154  if ((*lstr)->IdleTask())
155  {
156  if ( (pauseTime == 1000) && (*lstr)->IsFading() )
157  pauseTime = 100;
158 
159  nextItemList->push_back(*lstr);
160  }
161  else
162  {
164  m_DeadItems->push_back(*lstr);
165  }
166  ++lstr;
167 
168  AL_CHECK
169  }
170 
171  delete m_Items;
172  m_Items = nextItemList;
173 
174  AL_CHECK
175  }
176  SDL_Delay( pauseTime );
177  }
178  }
179 
180  bool GetEnabled()
181  {
183  return m_Enabled;
184  }
185 
186  bool GetShutdown()
187  {
189  return m_Shutdown;
190  }
191 
192 
193 
194 private:
195  // Thread-related members:
199 
200  // Shared by main thread and worker thread:
201  // These variables are all protected by a mutexes
204 
205  bool m_Enabled;
207 
209 };
210 
212 {
213  if ( !g_SoundManager )
214  g_SoundManager = new CSoundManager();
215 }
216 
217 void ISoundManager::SetEnabled(bool doEnable)
218 {
219  if ( g_SoundManager && !doEnable )
220  {
221  SAFE_DELETE(g_SoundManager);
222  }
223  else if ( !g_SoundManager && doEnable )
224  {
226  }
227 }
229 {
230  if ( CSoundManager* aSndMgr = (CSoundManager*)g_SoundManager )
231  aSndMgr->SetAmbientItem( NULL );
232 }
233 
234 void CSoundManager::al_ReportError(ALenum err, const char* caller, int line)
235 {
236  LOGERROR(L"OpenAL error: %hs; called from %hs (line %d)\n", alGetString(err), caller, line);
237 }
238 
239 void CSoundManager::al_check(const char* caller, int line)
240 {
241  ALenum err = alGetError();
242  if (err != AL_NO_ERROR)
243  al_ReportError(err, caller, line);
244 }
245 
247 {
248 // LOGERROR(L"GUI file '%ls' changed - reloading page", path.string().c_str());
249 
250  return INFO::OK;
251 }
252 
253 /*static*/ Status CSoundManager::ReloadChangedFileCB(void* param, const VfsPath& path)
254 {
255  return static_cast<CSoundManager*>(param)->ReloadChangedFiles(path);
256 }
257 
259 {
260  m_CurrentEnvirons = 0;
261  m_ALSourceBuffer = NULL;
262  m_Device = NULL;
263  m_Context = NULL;
264  m_Worker = NULL;
265  m_PlayListItems = NULL;
266  m_CurrentTune = 0;
267  m_Gain = 1;
268  m_MusicGain = 1;
269  m_AmbientGain = 1;
270  m_ActionGain = 1;
271  m_UIGain = 1;
272  m_BufferCount = 50;
273  m_BufferSize = 98304;
274  m_SoundEnabled = true;
275  m_MusicEnabled = true;
276  m_MusicPaused = false;
277  m_AmbientPaused = false;
278  m_ActionPaused = false;
279 
280  m_DistressTime = 0;
281  m_DistressErrCount = 0;
282 
283  m_PlayingPlaylist = false;
284  m_LoopingPlaylist = false;
285  m_RunningPlaylist = false;
286  m_PlaylistGap = 0;
287 
288  m_Enabled = false;
289  AlcInit();
290 
291  if ( m_Enabled )
292  {
293  InitListener();
294 
296 
298  m_Worker->SetEnabled( true );
299  }
300 
302 }
303 
305 {
307 
308  if (m_Worker )
309  {
310  AL_CHECK
311  m_Worker->Shutdown();
312  AL_CHECK
314  AL_CHECK
315 
316  delete m_Worker;
317  }
318  AL_CHECK
319 
320  for (std::map<std::wstring, CSoundGroup*>::iterator it = m_SoundGroups.begin(); it != m_SoundGroups.end(); ++it)
321  delete it->second;
322  m_SoundGroups.clear();
323 
324  if ( m_PlayListItems )
325  delete m_PlayListItems;
326 
327  if ( m_ALSourceBuffer != NULL )
328  delete[] m_ALSourceBuffer;
329 
330  if ( m_Context )
331  alcDestroyContext(m_Context);
332 
333  if ( m_Device )
334  alcCloseDevice(m_Device);
335 }
336 
337 
338 
340 {
341  Status ret = INFO::OK;
342 
343  m_Device = alcOpenDevice(NULL);
344  if (m_Device)
345  {
346  ALCint attribs[] = {ALC_STEREO_SOURCES, 16, 0};
347  m_Context = alcCreateContext(m_Device, &attribs[0]);
348 
349  if (m_Context)
350  {
351  alcMakeContextCurrent(m_Context);
353  ALuint* sourceList = new ALuint[SOURCE_NUM];
354 
355  alGenSources( SOURCE_NUM, sourceList);
356  ALCenum err = alcGetError(m_Device);
357 
358 
359  if ( err == ALC_NO_ERROR )
360  {
361  for ( int x=0; x<SOURCE_NUM;x++)
362  {
363  m_ALSourceBuffer[x].ALSource = sourceList[x];
364  m_ALSourceBuffer[x].SourceItem = NULL;
365 
366  }
367  m_Enabled = true;
368  }
369  else
370  {
371  LOGERROR(L"error in gensource = %d", err);
372  }
373  delete[] sourceList;
374  }
375  }
376 
377  // check if init succeeded.
378  // some OpenAL implementations don't indicate failure here correctly;
379  // we need to check if the device and context pointers are actually valid.
380  ALCenum err = alcGetError(m_Device);
381  const char* dev_name = (const char*)alcGetString(m_Device, ALC_DEVICE_SPECIFIER);
382 
383  if(err == ALC_NO_ERROR && m_Device && m_Context)
384  debug_printf(L"Sound: AlcInit success, using %hs\n", dev_name);
385  else
386  {
387  LOGERROR(L"Sound: AlcInit failed, m_Device=%p m_Context=%p dev_name=%hs err=%d\n", m_Device, m_Context, dev_name, err);
388 
389 
390 
391 // FIXME Hack to get around exclusive access to the sound device
392 #if OS_UNIX
393  ret = INFO::OK;
394 #else
395  ret = ERR::FAIL;
396 #endif // !OS_UNIX
397  }
398 
399  return ret;
400 }
401 
403 {
405 
406  if ( m_DistressTime == 0 )
407  return false;
408  else if ( (timer_Time() - m_DistressTime) > 10 )
409  {
410  m_DistressTime = 0;
411 // Coming out of distress mode
412  m_DistressErrCount = 0;
413  return false;
414  }
415 
416  return true;
417 }
418 
420 {
422 
423 // Going into distress for normal reasons
424 
426 }
427 
429 {
431 
432 // Going into distress due to unknown error
433 
436 }
437 
438 
439 
441 {
442  for ( int x=0; x<SOURCE_NUM;x++)
443  {
444  if ( ! m_ALSourceBuffer[x].SourceItem )
445  {
446  m_ALSourceBuffer[x].SourceItem = anItem;
447  return m_ALSourceBuffer[x].ALSource;
448  }
449  }
451  return 0;
452 }
453 
454 void CSoundManager::ReleaseALSource(ALuint theSource)
455 {
456  for ( int x=0; x<SOURCE_NUM;x++)
457  {
458  if ( m_ALSourceBuffer[x].ALSource == theSource )
459  {
460  m_ALSourceBuffer[x].SourceItem = NULL;
461  return;
462  }
463  }
464 }
465 
467 {
468  return m_BufferCount;
469 }
471 {
472  return m_BufferSize;
473 }
474 
476 {
477  m_PlayListItems->push_back(itemPath);
478 }
479 
481 {
482  if ( m_PlayingPlaylist )
483  SetMusicItem( NULL );
484 
485  m_PlayingPlaylist = false;
486  m_LoopingPlaylist = false;
487  m_RunningPlaylist = false;
488 
489  m_PlayListItems->clear();
490 }
491 
492 void CSoundManager::StartPlayList( bool doLoop )
493 {
494  if ( m_MusicEnabled )
495  {
496  if ( m_PlayListItems->size() > 0 )
497  {
498  m_PlayingPlaylist = true;
499  m_LoopingPlaylist = doLoop;
500  m_RunningPlaylist = false;
501 
502  ISoundItem* aSnd = LoadItem( (m_PlayListItems->at( 0 )) );
503  if ( aSnd )
504  SetMusicItem( aSnd );
505  else
506  {
507  SetMusicItem( NULL );
508  }
509  }
510  }
511 }
512 
514 {
515  if ( m_Enabled )
516  {
517  m_Gain = gain;
518  alListenerf( AL_GAIN, m_Gain);
519  AL_CHECK
520  }
521 }
522 
524 {
525  m_MusicGain = gain;
526 }
528 {
529  m_AmbientGain = gain;
530 }
532 {
533  m_ActionGain = gain;
534 }
535 void CSoundManager::SetUIGain(float gain)
536 {
537  m_UIGain = gain;
538 }
539 
540 
542 {
543  AL_CHECK
544 
545  if ( m_Enabled )
546  {
547  CSoundData* itemData = CSoundData::SoundDataFromFile(itemPath);
548 
549  AL_CHECK
550  if ( itemData )
551  return CSoundManager::ItemForData( itemData );
552  }
553 
554  return NULL;
555 }
556 
558 {
559  AL_CHECK
560  ISoundItem* answer = NULL;
561 
562  AL_CHECK
563 
564  if ( m_Enabled && (itemData != NULL) )
565  {
566  if (itemData->IsOneShot())
567  {
568  if (itemData->GetBufferCount() == 1)
569  answer = new CSoundItem(itemData);
570  else
571  answer = new CBufferItem(itemData);
572  }
573  else
574  {
575  answer = new CStreamItem(itemData);
576  }
577 
578  if ( answer && m_Worker )
579  m_Worker->addItem( answer );
580  }
581 
582 
583  return answer;
584 }
585 
587 {
588  if ( m_Enabled )
589  {
590  if (m_CurrentTune)
591  {
594  {
595  if ( m_CurrentTune->Finished() )
596  {
597  if ( m_PlaylistGap == 0 )
598  {
599  m_PlaylistGap = timer_Time() + 15;
600  }
601  else if ( m_PlaylistGap < timer_Time() )
602  {
603  m_PlaylistGap = 0;
604  PlayList::iterator it = find (m_PlayListItems->begin(), m_PlayListItems->end(), *(m_CurrentTune->GetName()) );
605  if ( it != m_PlayListItems->end() )
606  {
607  ++it;
608 
609  Path nextPath;
610  if ( it == m_PlayListItems->end() )
611  nextPath = m_PlayListItems->at( 0 );
612  else
613  nextPath = *it;
614 
615  ISoundItem* aSnd = LoadItem( nextPath );
616  if ( aSnd )
617  SetMusicItem( aSnd );
618  }
619  }
620  }
621  }
622  }
623 
624  if (m_CurrentEnvirons)
626 
627  if (m_Worker)
629 
630  }
631 }
632 
634 {
635  ISoundItem* currentItem = NULL;
636 
637  if ( m_Enabled )
638  currentItem = ItemForData( sndData );
639 
640  return currentItem;
641 }
642 
643 
645 {
646  ALfloat listenerPos[]={0.0,0.0,0.0};
647  ALfloat listenerVel[]={0.0,0.0,0.0};
648  ALfloat listenerOri[]={0.0,0.0,-1.0, 0.0,1.0,0.0};
649 
650  alListenerfv(AL_POSITION,listenerPos);
651  alListenerfv(AL_VELOCITY,listenerVel);
652  alListenerfv(AL_ORIENTATION,listenerOri);
653 
654  alDistanceModel(AL_LINEAR_DISTANCE);
655 }
656 
657 void CSoundManager::PlayGroupItem(ISoundItem* anItem, ALfloat groupGain )
658 {
659  if (anItem)
660  {
661  if (m_Enabled && (m_ActionGain > 0)) {
662  anItem->SetGain(m_ActionGain * groupGain);
663  anItem->PlayAndDelete();
664  AL_CHECK
665  }
666  }
667 }
668 
669 void CSoundManager::SetMusicEnabled (bool isEnabled)
670 {
671  LOGERROR(L"entering enabled area", isEnabled);
672 
673  if (m_CurrentTune && !isEnabled)
674  {
676  m_CurrentTune = 0L;
677  }
678  LOGERROR(L"exiting enabled area", isEnabled);
679  m_MusicEnabled = isEnabled;
680 }
681 
682 void CSoundManager::PlayAsGroup(const VfsPath& groupPath, CVector3D sourcePos, entity_id_t source, bool ownedSound)
683 {
684  // Make sure the sound group is loaded
685  CSoundGroup* group;
686  if (m_SoundGroups.find(groupPath.string()) == m_SoundGroups.end())
687  {
688  group = new CSoundGroup();
689  if (!group->LoadSoundGroup(L"audio/" + groupPath.string() ))
690  {
691  LOGERROR(L"Failed to load sound group '%ls'", groupPath.string().c_str());
692  delete group;
693  group = NULL;
694  }
695  // Cache the sound group (or the null, if it failed)
696  m_SoundGroups[groupPath.string()] = group;
697  }
698  else
699  {
700  group = m_SoundGroups[groupPath.string()];
701  }
702 
703  // Failed to load group -> do nothing
704  if ( group && ( ownedSound || !group->TestFlag( eOwnerOnly ) ) )
705  group->PlayNext(sourcePos, source);
706 }
707 
708 void CSoundManager::PlayAsMusic( const VfsPath& itemPath, bool looping )
709 {
710  UNUSED2( looping );
711 
712  ISoundItem* aSnd = LoadItem(itemPath);
713  if (aSnd != NULL)
714  SetMusicItem( aSnd );
715 }
716 
717 void CSoundManager::PlayAsAmbient( const VfsPath& itemPath, bool looping )
718 {
719  UNUSED2( looping );
720  ISoundItem* aSnd = LoadItem(itemPath);
721  if (aSnd != NULL)
722  SetAmbientItem( aSnd );
723 }
724 
725 
726 void CSoundManager::PlayAsUI(const VfsPath& itemPath, bool looping)
727 {
728  IdleTask();
729 
730  if ( ISoundItem* anItem = LoadItem(itemPath) )
731  {
732  if (m_Enabled && (m_UIGain > 0))
733  {
734  anItem->SetGain(m_UIGain);
735  anItem->SetLooping( looping );
736  anItem->PlayAndDelete();
737  }
738  }
739  AL_CHECK
740 }
741 
742 
743 void CSoundManager::Pause(bool pauseIt)
744 {
745  PauseMusic(pauseIt);
746  PauseAmbient(pauseIt);
747  PauseAction(pauseIt);
748 }
749 
750 void CSoundManager::PauseMusic (bool pauseIt)
751 {
752  if (m_CurrentTune && pauseIt && !m_MusicPaused )
753  {
754  m_CurrentTune->FadeAndPause( 1.0 );
755  }
756  else if ( m_CurrentTune && m_MusicPaused && !pauseIt && m_MusicEnabled )
757  {
761  }
762  m_MusicPaused = pauseIt;
763 }
764 
765 void CSoundManager::PauseAmbient (bool pauseIt)
766 {
767  if (m_CurrentEnvirons && pauseIt)
769  else if ( m_CurrentEnvirons )
771 
772  m_AmbientPaused = pauseIt;
773 }
774 
775 void CSoundManager::PauseAction (bool pauseIt)
776 {
777  m_ActionPaused = pauseIt;
778 }
779 
781 {
782  AL_CHECK
783  if (m_CurrentTune)
784  {
786  m_CurrentTune = 0L;
787  }
788 
789  IdleTask();
790 
791  if (anItem)
792  {
793  if (m_MusicEnabled && m_Enabled)
794  {
795  m_CurrentTune = anItem;
797 
798  if ( m_PlayingPlaylist )
799  {
800  m_RunningPlaylist = true;
801  m_CurrentTune->Play();
802  }
803  else
805 
806  m_MusicPaused = false;
808  }
809  else
810  {
811  anItem->StopAndDelete();
812  }
813  }
814  AL_CHECK
815 }
816 
818 {
819  if (m_CurrentEnvirons)
820  {
822  m_CurrentEnvirons = 0L;
823  }
824  IdleTask();
825 
826  if (anItem)
827  {
828  if (m_Enabled && (m_AmbientGain > 0))
829  {
830  m_CurrentEnvirons = anItem;
834  }
835  }
836  AL_CHECK
837 }
838 #else // CONFIG2_AUDIO
839 
841 void ISoundManager::SetEnabled(bool UNUSED(doEnable)){}
843 
844 #endif // CONFIG2_AUDIO
845 
#define AL_CHECK
Definition: SoundManager.h:40
virtual void FadeAndPause(double fadeTime)=0
virtual bool Finished()=0
ISoundItem * ItemForData(CSoundData *itemData)
void PlayGroupItem(ISoundItem *anItem, ALfloat groupGain)
ALuint ALSource
Title of the column.
Definition: SoundManager.h:45
bool m_LoopingPlaylist
Definition: SoundManager.h:89
void Pause(bool pauseIt)
Status AlcInit()
void SetDistressThroughShortage()
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
virtual bool InDistress()=0
virtual void FadeToIn(float newVolume, double fadeDuration)=0
virtual void Pause()=0
float m_AmbientGain
Definition: SoundManager.h:75
const Status OK
Definition: status.h:386
#define LOGERROR
Definition: CLogger.h:35
void SDL_Delay(Uint32 ms)
Definition: wsdl.cpp:1457
virtual void StopAndDelete()=0
SoundGroupMap m_SoundGroups
Definition: SoundManager.h:71
std::vector< ISoundItem * > ItemsList
Definition: SoundManager.h:50
bool m_SoundEnabled
Definition: SoundManager.h:82
ISoundManager * g_SoundManager
bool m_MusicPaused
Definition: SoundManager.h:84
long GetBufferSize()
ALCdevice * m_Device
Definition: SoundManager.h:65
ALCcontext * m_Context
Definition: SoundManager.h:64
void ClearPlayListItems()
PlayList * m_PlayListItems
Definition: SoundManager.h:70
Locks a CMutex over this object&#39;s lifetime.
Definition: ThreadUtil.h:73
void SetMusicGain(float gain)
CMutex m_DistressMutex
Definition: SoundManager.h:69
virtual void FadeAndDelete(double fadeTime)=0
void PlayAsUI(const VfsPath &itemPath, bool looping)
CSoundManagerWorker(ISoundManager *other)
static void CloseGame()
ALuint GetALSource(ISoundItem *anItem)
long m_DistressErrCount
Definition: SoundManager.h:92
ISoundItem * m_CurrentEnvirons
Definition: SoundManager.h:67
void SetAmbientGain(float gain)
A non-recursive mutual exclusion lock.
Definition: ThreadUtil.h:45
NONCOPYABLE(CSoundManagerWorker)
static CSoundData * SoundDataFromFile(const VfsPath &itemPath)
Definition: SoundData.cpp:68
void addItem(ISoundItem *anItem)
virtual void Play()=0
LIB_API void debug_SetThreadName(const char *name)
inform the debugger of the current thread&#39;s name.
Definition: bdbg.cpp:126
bool LoadSoundGroup(const VfsPath &pathnameXML)
Definition: SoundGroup.cpp:283
virtual ~CSoundManager()
void SetMusicEnabled(bool isEnabled)
#define ENSURE(expr)
ensure the expression &lt;expr&gt; evaluates to non-zero.
Definition: debug.h:282
#define UNUSED2(param)
mark a function local variable or parameter as unused and avoid the corresponding compiler warning...
ItemsList * m_DeadItems
virtual void PlayAndDelete()=0
void PauseMusic(bool pauseIt)
CSoundManagerWorker * m_Worker
Definition: SoundManager.h:68
int pthread_create(pthread_t *thread_id, const void *attr, void *(*func)(void *), void *arg)
Definition: wpthread.cpp:636
static Status ReloadChangedFileCB(void *param, const VfsPath &path)
void SetDistressThroughError()
bool m_RunningPlaylist
Definition: SoundManager.h:87
CProfiler2 g_Profiler2
Definition: Profiler2.cpp:35
void UnregisterFileReloadFunc(FileReloadFunc func, void *obj)
delete a callback function registered with RegisterFileReloadFunc (removes any with the same func and...
Definition: Filesystem.cpp:44
void RegisterFileReloadFunc(FileReloadFunc func, void *obj)
register a callback function to be called by ReloadChangedFiles
Definition: Filesystem.cpp:39
void PlayAsGroup(const VfsPath &groupPath, CVector3D sourcePos, entity_id_t source, bool ownedSound)
Definition: path.h:75
New profiler (complementing the older CProfileManager)
void RegisterCurrentThread(const std::string &name)
Call in any thread to enable the profiler in that thread.
Definition: Profiler2.cpp:241
const String & string() const
Definition: path.h:123
void SetAmbientItem(ISoundItem *anItem)
void SetMusicItem(ISoundItem *anItem)
virtual int GetBufferCount()
Definition: SoundData.cpp:117
virtual void EnsurePlay()=0
ISoundItem * SourceItem
Definition: SoundManager.h:46
#define SAFE_DELETE(p)
delete memory ensuing from new and set the pointer to zero (thus making double-frees safe / a no-op) ...
std::vector< VfsPath > PlayList
Definition: SoundManager.h:49
virtual void SetGain(float gain)=0
bool m_MusicEnabled
Definition: SoundManager.h:81
long m_DistressTime
Definition: SoundManager.h:93
i64 Status
Error handling system.
Definition: status.h:171
void StartPlayList(bool doLoop)
static void al_check(const char *caller, int line)
double timer_Time()
Definition: timer.cpp:98
void SetMasterGain(float gain)
void PauseAction(bool pauseIt)
void SetEnabled(bool enabled)
virtual Path * GetName()=0
virtual void Resume()=0
ISoundItem * ItemForEntity(entity_id_t source, CSoundData *sndData)
void PauseAmbient(bool pauseIt)
void PlayAsMusic(const VfsPath &itemPath, bool looping)
static void al_ReportError(ALenum err, const char *caller, int line)
uintptr_t pthread_t
Definition: wpthread.h:63
static void SetEnabled(bool doEnable)
ISoundItem * m_CurrentTune
Definition: SoundManager.h:66
void PlayAsAmbient(const VfsPath &itemPath, bool looping)
virtual void PlayLoop()=0
virtual bool IsOneShot()
Definition: SoundData.cpp:93
float m_MusicGain
Definition: SoundManager.h:74
long m_PlaylistGap
Definition: SoundManager.h:91
bool m_PlayingPlaylist
Definition: SoundManager.h:88
ISoundItem * LoadItem(const VfsPath &itemPath)
const Status FAIL
Definition: status.h:406
void AddPlayListItem(const VfsPath &itemPath)
void RecordRegionLeave(const char *id)
Definition: Profiler2.h:320
float m_ActionGain
Definition: SoundManager.h:76
#define SOURCE_NUM
static void CreateSoundManager()
int pthread_join(pthread_t thread, void **value_ptr)
Definition: wpthread.cpp:679
void ReleaseALSource(ALuint theSource)
long GetBufferCount()
void SetUIGain(float gain)
Status ReloadChangedFiles(const VfsPath &path)
u32 entity_id_t
Entity ID type.
Definition: Entity.h:24
bool TestFlag(int flag)
Definition: SoundGroup.h:107
bool m_ActionPaused
Definition: SoundManager.h:86
static void * RunThread(void *data)
bool m_AmbientPaused
Definition: SoundManager.h:85
ALSourceHolder * m_ALSourceBuffer
Definition: SoundManager.h:95
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
Definition: debug.cpp:142
void PlayNext(const CVector3D &position, entity_id_t source)
Definition: SoundGroup.cpp:233
void SetActionGain(float gain)