Changeset View
Changeset View
Standalone View
Standalone View
source/soundmanager/SoundManager.h
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 34 Lines | struct ALSourceHolder | ||||
ALuint ALSource; | ALuint ALSource; | ||||
ISoundItem* SourceItem; | ISoundItem* SourceItem; | ||||
}; | }; | ||||
typedef std::vector<VfsPath> PlayList; | typedef std::vector<VfsPath> PlayList; | ||||
typedef std::vector<ISoundItem*> ItemsList; | typedef std::vector<ISoundItem*> ItemsList; | ||||
typedef std::map<entity_id_t, ISoundItem*> ItemsMap; | typedef std::map<entity_id_t, ISoundItem*> ItemsMap; | ||||
typedef std::map<std::wstring, CSoundGroup*> SoundGroupMap; | typedef std::map<std::wstring, CSoundGroup*> SoundGroupMap; | ||||
typedef std::vector<VfsPath> ReloadList; | |||||
vladislavbelov: `using` instead of `typedef`. `ReloadList` is a too common name for the global namespace… | |||||
class CSoundManagerWorker; | class CSoundManagerWorker; | ||||
class CSoundManager : public ISoundManager | class CSoundManager : public ISoundManager | ||||
{ | { | ||||
NONCOPYABLE(CSoundManager); | NONCOPYABLE(CSoundManager); | ||||
protected: | protected: | ||||
ALCcontext* m_Context; | ALCcontext* m_Context; | ||||
ALCdevice* m_Device; | ALCdevice* m_Device; | ||||
ALSourceHolder* m_ALSourceBuffer; | ALSourceHolder* m_ALSourceBuffer; | ||||
ISoundItem* m_CurrentTune; | ISoundItem* m_CurrentTune; | ||||
ISoundItem* m_CurrentEnvirons; | ISoundItem* m_CurrentEnvirons; | ||||
CSoundManagerWorker* m_Worker; | CSoundManagerWorker* m_Worker; | ||||
std::mutex m_DistressMutex; | std::mutex m_DistressMutex; | ||||
std::mutex m_HotloadingMutex; | |||||
PlayList* m_PlayListItems; | PlayList* m_PlayListItems; | ||||
SoundGroupMap m_SoundGroups; | SoundGroupMap m_SoundGroups; | ||||
ReloadList m_ReloadList; | |||||
float m_Gain; | float m_Gain; | ||||
float m_MusicGain; | float m_MusicGain; | ||||
float m_AmbientGain; | float m_AmbientGain; | ||||
float m_ActionGain; | float m_ActionGain; | ||||
float m_UIGain; | float m_UIGain; | ||||
bool m_Enabled; | bool m_Enabled; | ||||
long m_BufferSize; | long m_BufferSize; | ||||
int m_BufferCount; | int m_BufferCount; | ||||
bool m_SoundEnabled; | bool m_SoundEnabled; | ||||
bool m_MusicEnabled; | bool m_MusicEnabled; | ||||
bool m_MusicPaused; | bool m_MusicPaused; | ||||
bool m_AmbientPaused; | bool m_AmbientPaused; | ||||
bool m_ActionPaused; | bool m_ActionPaused; | ||||
bool m_RunningPlaylist; | bool m_RunningPlaylist; | ||||
bool m_PlayingPlaylist; | bool m_PlayingPlaylist; | ||||
bool m_LoopingPlaylist; | bool m_LoopingPlaylist; | ||||
long m_PlaylistGap; | long m_PlaylistGap; | ||||
long m_DistressErrCount; | long m_DistressErrCount; | ||||
long m_DistressTime; | long m_DistressTime; | ||||
bool m_Hotloading; | |||||
public: | public: | ||||
CSoundManager(); | CSoundManager(); | ||||
virtual ~CSoundManager(); | virtual ~CSoundManager(); | ||||
void StartWorker(); | void StartWorker(); | ||||
ISoundItem* LoadItem(const VfsPath& itemPath); | ISoundItem* LoadItem(const VfsPath& itemPath); | ||||
ISoundItem* ItemForData(CSoundData* itemData); | ISoundItem* ItemForData(CSoundData* itemData); | ||||
ISoundItem* ItemForEntity(entity_id_t source, CSoundData* sndData); | ISoundItem* ItemForEntity(entity_id_t source, CSoundData* sndData); | ||||
CSoundGroup* LoadGroup(const VfsPath& groupPath); | |||||
void ReloadGroup(const VfsPath& groupPath); | |||||
Status ReloadChangedFiles(const VfsPath& path); | Status ReloadChangedFiles(const VfsPath& path); | ||||
void HotloadSoundGroup(const VfsPath& path); | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsWhat's the difference between HotloadSmth, LoadSmth and ReloadSmth? vladislavbelov: What's the difference between `HotloadSmth`, `LoadSmth` and `ReloadSmth`? | |||||
void HotloadOggFile(const VfsPath& path); | |||||
void Hotloader(); | |||||
void ClearPlayListItems(); | void ClearPlayListItems(); | ||||
void StartPlayList(bool doLoop); | void StartPlayList(bool doLoop); | ||||
void AddPlayListItem(const VfsPath& itemPath); | void AddPlayListItem(const VfsPath& itemPath); | ||||
static void CreateSoundManager(); | static void CreateSoundManager(); | ||||
static void SetEnabled(bool doEnable); | static void SetEnabled(bool doEnable); | ||||
static Status ReloadChangedFileCB(void* param, const VfsPath& path); | static Status ReloadChangedFileCB(void* param, const VfsPath& path); | ||||
Show All 9 Lines | public: | ||||
ALuint GetALSource(ISoundItem* anItem); | ALuint GetALSource(ISoundItem* anItem); | ||||
void ReleaseALSource(ALuint theSource); | void ReleaseALSource(ALuint theSource); | ||||
ISoundItem* ItemFromData(CSoundData* itemData); | ISoundItem* ItemFromData(CSoundData* itemData); | ||||
ISoundItem* ItemFromWAV(VfsPath& fname); | ISoundItem* ItemFromWAV(VfsPath& fname); | ||||
ISoundItem* ItemFromOgg(VfsPath& fname); | ISoundItem* ItemFromOgg(VfsPath& fname); | ||||
ISoundItem* GetSoundItem(unsigned long itemRow); | ISoundItem* GetSoundItem(unsigned long itemRow); | ||||
ALSourceHolder* GetSourceHolder(const VfsPath& itemPath); | |||||
ALSourceHolder* GetSourceHolder(ISoundItem* theItem); | |||||
unsigned long Count(); | unsigned long Count(); | ||||
void IdleTask(); | void IdleTask(); | ||||
void SetMemoryUsage(long bufferSize, int bufferCount); | void SetMemoryUsage(long bufferSize, int bufferCount); | ||||
long GetBufferCount(); | long GetBufferCount(); | ||||
long GetBufferSize(); | long GetBufferSize(); | ||||
void PlayAsMusic(const VfsPath& itemPath, bool looping); | void PlayAsMusic(const VfsPath& itemPath, bool looping); | ||||
void PlayAsAmbient(const VfsPath& itemPath, bool looping); | void PlayAsAmbient(const VfsPath& itemPath, bool looping); | ||||
void PlayAsUI(const VfsPath& itemPath, bool looping); | void PlayAsUI(const VfsPath& itemPath, bool looping); | ||||
void PlayAsGroup(const VfsPath& groupPath, const CVector3D& sourcePos, entity_id_t source, bool ownedSound); | void PlayAsGroup(const VfsPath& groupPath, const CVector3D& sourcePos, entity_id_t source, bool ownedSound); | ||||
void PlayGroupItem(ISoundItem* anItem, ALfloat groupGain); | void PlayGroupItem(ISoundItem* anItem, ALfloat groupGain); | ||||
bool InDistress(); | bool InDistress(); | ||||
bool InHotloading(); | |||||
void SetDistressThroughShortage(); | void SetDistressThroughShortage(); | ||||
void SetDistressThroughError(); | void SetDistressThroughError(); | ||||
void SetHotloading(bool hotloading); | |||||
void Pause(bool pauseIt); | void Pause(bool pauseIt); | ||||
void PauseMusic(bool pauseIt); | void PauseMusic(bool pauseIt); | ||||
void PauseAmbient(bool pauseIt); | void PauseAmbient(bool pauseIt); | ||||
void PauseAction(bool pauseIt); | void PauseAction(bool pauseIt); | ||||
void SetAmbientItem(ISoundItem* anItem); | void SetAmbientItem(ISoundItem* anItem); | ||||
void SetMasterGain(float gain); | void SetMasterGain(float gain); | ||||
void SetMusicGain(float gain); | void SetMusicGain(float gain); | ||||
void SetAmbientGain(float gain); | void SetAmbientGain(float gain); | ||||
void SetActionGain(float gain); | void SetActionGain(float gain); | ||||
void SetUIGain(float gain); | void SetUIGain(float gain); | ||||
bool IsCurrentAmbient(ISoundItem* anItem); | |||||
vladislavbelovUnsubmitted Not Done Inline ActionsShould be const I suppose. vladislavbelov: Should be `const` I suppose. | |||||
bool IsCurrentMusic(ISoundItem* anItem); | |||||
protected: | protected: | ||||
void InitListener(); | void InitListener(); | ||||
Status AlcInit(); | Status AlcInit(); | ||||
void SetMusicItem(ISoundItem* anItem); | void SetMusicItem(ISoundItem* anItem); | ||||
private: | private: | ||||
CSoundManager(CSoundManager* UNUSED(other)){}; | CSoundManager(CSoundManager* UNUSED(other)){}; | ||||
}; | }; | ||||
Show All 9 Lines |
Wildfire Games · Phabricator
using instead of typedef. ReloadList is a too common name for the global namespace, should be inside the class or should be in a named namespace.
What's the most frequent operation with the list: iteration or search?