18 #include "precompiled.h"
80 ItemsList::iterator lstr =
m_Items->begin();
104 ItemsList::iterator deadItems =
m_DeadItems->begin();
147 ItemsList::iterator lstr =
m_Items->begin();
151 while (lstr !=
m_Items->end()) {
154 if ((*lstr)->IdleTask())
156 if ( (pauseTime == 1000) && (*lstr)->IsFading() )
159 nextItemList->push_back(*lstr);
213 if ( !g_SoundManager )
219 if ( g_SoundManager && !doEnable )
223 else if ( !g_SoundManager && doEnable )
231 aSndMgr->SetAmbientItem( NULL );
236 LOGERROR(L
"OpenAL error: %hs; called from %hs (line %d)\n", alGetString(err), caller, line);
241 ALenum err = alGetError();
242 if (err != AL_NO_ERROR)
346 ALCint attribs[] = {ALC_STEREO_SOURCES, 16, 0};
356 ALCenum err = alcGetError(
m_Device);
359 if ( err == ALC_NO_ERROR )
371 LOGERROR(L
"error in gensource = %d", err);
380 ALCenum err = alcGetError(
m_Device);
381 const char* dev_name = (
const char*)alcGetString(
m_Device, ALC_DEVICE_SPECIFIER);
384 debug_printf(L
"Sound: AlcInit success, using %hs\n", dev_name);
518 alListenerf( AL_GAIN,
m_Gain);
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};
650 alListenerfv(AL_POSITION,listenerPos);
651 alListenerfv(AL_VELOCITY,listenerVel);
652 alListenerfv(AL_ORIENTATION,listenerOri);
654 alDistanceModel(AL_LINEAR_DISTANCE);
671 LOGERROR(L
"entering enabled area", isEnabled);
678 LOGERROR(L
"exiting enabled area", isEnabled);
691 LOGERROR(L
"Failed to load sound group '%ls'", groupPath.
string().c_str());
735 anItem->SetLooping( looping );
736 anItem->PlayAndDelete();
838 #else // CONFIG2_AUDIO
844 #endif // CONFIG2_AUDIO
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.
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
void SDL_Delay(Uint32 ms)
virtual void StopAndDelete()=0
SoundGroupMap m_SoundGroups
std::vector< ISoundItem * > ItemsList
ISoundManager * g_SoundManager
void ClearPlayListItems()
PlayList * m_PlayListItems
Locks a CMutex over this object's lifetime.
void SetMusicGain(float gain)
virtual void FadeAndDelete(double fadeTime)=0
void PlayAsUI(const VfsPath &itemPath, bool looping)
CSoundManagerWorker(ISoundManager *other)
ALuint GetALSource(ISoundItem *anItem)
ISoundItem * m_CurrentEnvirons
void SetAmbientGain(float gain)
A non-recursive mutual exclusion lock.
NONCOPYABLE(CSoundManagerWorker)
static CSoundData * SoundDataFromFile(const VfsPath &itemPath)
void addItem(ISoundItem *anItem)
LIB_API void debug_SetThreadName(const char *name)
inform the debugger of the current thread's name.
bool LoadSoundGroup(const VfsPath &pathnameXML)
void SetMusicEnabled(bool isEnabled)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
#define UNUSED2(param)
mark a function local variable or parameter as unused and avoid the corresponding compiler warning...
virtual void PlayAndDelete()=0
void PauseMusic(bool pauseIt)
CSoundManagerWorker * m_Worker
int pthread_create(pthread_t *thread_id, const void *attr, void *(*func)(void *), void *arg)
static Status ReloadChangedFileCB(void *param, const VfsPath &path)
void SetDistressThroughError()
void UnregisterFileReloadFunc(FileReloadFunc func, void *obj)
delete a callback function registered with RegisterFileReloadFunc (removes any with the same func and...
void RegisterFileReloadFunc(FileReloadFunc func, void *obj)
register a callback function to be called by ReloadChangedFiles
void PlayAsGroup(const VfsPath &groupPath, CVector3D sourcePos, entity_id_t source, bool ownedSound)
New profiler (complementing the older CProfileManager)
void RegisterCurrentThread(const std::string &name)
Call in any thread to enable the profiler in that thread.
const String & string() const
void SetAmbientItem(ISoundItem *anItem)
void SetMusicItem(ISoundItem *anItem)
virtual int GetBufferCount()
virtual void EnsurePlay()=0
#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
virtual void SetGain(float gain)=0
i64 Status
Error handling system.
void StartPlayList(bool doLoop)
static void al_check(const char *caller, int line)
void SetMasterGain(float gain)
void PauseAction(bool pauseIt)
void SetEnabled(bool enabled)
virtual Path * GetName()=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)
static void SetEnabled(bool doEnable)
ISoundItem * m_CurrentTune
void PlayAsAmbient(const VfsPath &itemPath, bool looping)
virtual void PlayLoop()=0
ISoundItem * LoadItem(const VfsPath &itemPath)
void AddPlayListItem(const VfsPath &itemPath)
void RecordRegionLeave(const char *id)
static void CreateSoundManager()
int pthread_join(pthread_t thread, void **value_ptr)
void ReleaseALSource(ALuint theSource)
void SetUIGain(float gain)
Status ReloadChangedFiles(const VfsPath &path)
u32 entity_id_t
Entity ID type.
static void * RunThread(void *data)
ALSourceHolder * m_ALSourceBuffer
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
void PlayNext(const CVector3D &position, entity_id_t source)
void SetActionGain(float gain)