#include <proxy_sound_manager.h>
Public Member Functions | |
ProxySoundManager (SoundManagerSingleton *smg, std::unique_ptr< SoundFallbackPathProvider > fallback_path_provider) | |
~ProxySoundManager () override | |
void | step (f32 dtime) override |
Removes finished sounds, steps streamed sounds, and does similar tasks. | |
void | pauseAll () override |
Pause all sound playback. | |
void | resumeAll () override |
Resume sound playback after pause. | |
void | updateListener (const v3f &pos_, const v3f &vel_, const v3f &at_, const v3f &up_) override |
void | setListenerGain (f32 gain) override |
bool | loadSoundFile (const std::string &name, const std::string &filepath) override |
Adds a sound to load from a file (only OggVorbis). | |
bool | loadSoundData (const std::string &name, std::string &&filedata) override |
Same as loadSoundFile , but reads the OggVorbis file from memory. | |
void | addSoundToGroup (const std::string &sound_name, const std::string &group_name) override |
Adds sound with name sound_name to group group_name . | |
void | playSound (sound_handle_t id, const SoundSpec &spec) override |
Plays a random sound from a sound group (position-less). | |
void | playSoundAt (sound_handle_t id, const SoundSpec &spec, const v3f &pos_, const v3f &vel_) override |
Same as playSound , but at a position. | |
void | stopSound (sound_handle_t sound) override |
Request the sound to be stopped. | |
void | fadeSound (sound_handle_t soundid, f32 step, f32 target_gain) override |
void | updateSoundPosVel (sound_handle_t sound, const v3f &pos_, const v3f &vel_) override |
Update position and velocity of positional sound. | |
Public Member Functions inherited from ISoundManager | |
virtual | ~ISoundManager ()=default |
std::vector< sound_handle_t > | pollRemovedSounds () |
Get and reset the list of sounds that were stopped. | |
sound_handle_t | allocateId (u32 num_owners) |
Returns a positive id. | |
void | freeId (sound_handle_t id, u32 num_owners=1) |
Free an id allocated via allocateId. | |
Private Types | |
enum class | MsgResult { Ok , Empty , Stopped } |
Private Member Functions | |
void | send (SoundManagerMsgToMgr msg) |
MsgResult | handleMsg (SoundManagerMsgToProxy &&msg) |
Private Attributes | |
OpenALSoundManager | m_sound_manager |
std::unordered_set< std::string > | m_known_sound_names |
Additional Inherited Members | |
Protected Member Functions inherited from ISoundManager | |
void | reportRemovedSound (sound_handle_t id) |
|
strongprivate |
|
inline |
|
override |
References handleMsg(), Thread::isRunning(), sound::OpenALSoundManager::m_queue_to_proxy, m_sound_manager, MutexedQueue< T >::pop_frontNoEx(), SANITY_CHECK, send(), Thread::stop(), Stopped, and Thread::wait().
|
overridevirtual |
Adds sound with name sound_name to group group_name
.
Creates the group if non-existent.
sound_name | The name of the sound, as used in loadSoundData . |
group_name | The name of the sound group. |
Implements ISoundManager.
References send().
|
overridevirtual |
|
private |
References Empty, Ok, ISoundManager::reportRemovedSound(), and Stopped.
Referenced by ~ProxySoundManager(), and step().
|
overridevirtual |
Same as loadSoundFile
, but reads the OggVorbis file from memory.
Implements ISoundManager.
References m_known_sound_names, and send().
|
overridevirtual |
Adds a sound to load from a file (only OggVorbis).
name | The name of the sound. Must be unique, otherwise call fails. |
filepath | The path for |
Implements ISoundManager.
References fs::IsFile(), m_known_sound_names, and send().
|
overridevirtual |
Pause all sound playback.
Implements ISoundManager.
References send().
|
overridevirtual |
Plays a random sound from a sound group (position-less).
id | Id for new sound. Move semantics apply if id > 0. |
Implements ISoundManager.
References ISoundManager::allocateId(), and send().
|
overridevirtual |
Same as playSound
, but at a position.
pos | In node-space. |
vel | In node-space. |
Implements ISoundManager.
References ISoundManager::allocateId(), and send().
|
overridevirtual |
Resume sound playback after pause.
Implements ISoundManager.
References send().
|
inlineprivate |
References sound::OpenALSoundManager::m_queue_to_mgr, m_sound_manager, and MutexedQueue< T >::push_back().
Referenced by ~ProxySoundManager(), addSoundToGroup(), fadeSound(), loadSoundData(), loadSoundFile(), pauseAll(), playSound(), playSoundAt(), resumeAll(), setListenerGain(), stopSound(), updateListener(), and updateSoundPosVel().
|
overridevirtual |
|
overridevirtual |
Removes finished sounds, steps streamed sounds, and does similar tasks.
Should not be called while paused.
dtime | In seconds. |
Implements ISoundManager.
References Empty, handleMsg(), sound::OpenALSoundManager::m_queue_to_proxy, m_sound_manager, MutexedQueue< T >::pop_frontNoEx(), and Stopped.
Referenced by fadeSound().
|
overridevirtual |
Request the sound to be stopped.
The id should be freed afterwards.
Implements ISoundManager.
References send().
|
overridevirtual |
pos | In node-space. |
vel | In node-space. |
at | Vector in node-space pointing forwards. |
up | Vector in node-space pointing upwards, orthogonal to at . |
Implements ISoundManager.
References send().
|
overridevirtual |
Update position and velocity of positional sound.
pos | In node-space. |
vel | In node-space. |
Implements ISoundManager.
References send().
|
private |
Referenced by loadSoundData(), and loadSoundFile().
|
private |
Referenced by ProxySoundManager(), ~ProxySoundManager(), send(), and step().