Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
sound::ProxySoundManager Class Referencefinal

#include <proxy_sound_manager.h>

+ Inheritance diagram for sound::ProxySoundManager:
+ Collaboration diagram for sound::ProxySoundManager:

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_tpollRemovedSounds ()
 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)
 

Member Enumeration Documentation

◆ MsgResult

enum class sound::ProxySoundManager::MsgResult
strongprivate
Enumerator
Ok 
Empty 
Stopped 

Constructor & Destructor Documentation

◆ ProxySoundManager()

sound::ProxySoundManager::ProxySoundManager ( SoundManagerSingleton * smg,
std::unique_ptr< SoundFallbackPathProvider > fallback_path_provider )
inline

References m_sound_manager, and Thread::start().

+ Here is the call graph for this function:

◆ ~ProxySoundManager()

sound::ProxySoundManager::~ProxySoundManager ( )
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().

+ Here is the call graph for this function:

Member Function Documentation

◆ addSoundToGroup()

void sound::ProxySoundManager::addSoundToGroup ( const std::string & sound_name,
const std::string & group_name )
overridevirtual

Adds sound with name sound_name to group group_name.

Creates the group if non-existent.

Parameters
sound_nameThe name of the sound, as used in loadSoundData.
group_nameThe name of the sound group.

Implements ISoundManager.

References send().

+ Here is the call graph for this function:

◆ fadeSound()

void sound::ProxySoundManager::fadeSound ( sound_handle_t soundid,
f32 step,
f32 target_gain )
overridevirtual

Implements ISoundManager.

References send(), and step().

+ Here is the call graph for this function:

◆ handleMsg()

ProxySoundManager::MsgResult sound::ProxySoundManager::handleMsg ( SoundManagerMsgToProxy && msg)
private

References Empty, Ok, ISoundManager::reportRemovedSound(), and Stopped.

Referenced by ~ProxySoundManager(), and step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadSoundData()

bool sound::ProxySoundManager::loadSoundData ( const std::string & name,
std::string && filedata )
overridevirtual

Same as loadSoundFile, but reads the OggVorbis file from memory.

Implements ISoundManager.

References m_known_sound_names, and send().

+ Here is the call graph for this function:

◆ loadSoundFile()

bool sound::ProxySoundManager::loadSoundFile ( const std::string & name,
const std::string & filepath )
overridevirtual

Adds a sound to load from a file (only OggVorbis).

Parameters
nameThe name of the sound. Must be unique, otherwise call fails.
filepathThe path for
Returns
true on success, false on failure (ie. sound was already added or file does not exist).

Implements ISoundManager.

References fs::IsFile(), m_known_sound_names, and send().

+ Here is the call graph for this function:

◆ pauseAll()

void sound::ProxySoundManager::pauseAll ( )
overridevirtual

Pause all sound playback.

Implements ISoundManager.

References send().

+ Here is the call graph for this function:

◆ playSound()

void sound::ProxySoundManager::playSound ( sound_handle_t id,
const SoundSpec & spec )
overridevirtual

Plays a random sound from a sound group (position-less).

Parameters
idId for new sound. Move semantics apply if id > 0.

Implements ISoundManager.

References ISoundManager::allocateId(), and send().

+ Here is the call graph for this function:

◆ playSoundAt()

void sound::ProxySoundManager::playSoundAt ( sound_handle_t id,
const SoundSpec & spec,
const v3f & pos,
const v3f & vel )
overridevirtual

Same as playSound, but at a position.

Parameters
posIn node-space.
velIn node-space.

Implements ISoundManager.

References ISoundManager::allocateId(), and send().

+ Here is the call graph for this function:

◆ resumeAll()

void sound::ProxySoundManager::resumeAll ( )
overridevirtual

Resume sound playback after pause.

Implements ISoundManager.

References send().

+ Here is the call graph for this function:

◆ send()

void sound::ProxySoundManager::send ( SoundManagerMsgToMgr msg)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setListenerGain()

void sound::ProxySoundManager::setListenerGain ( f32 gain)
overridevirtual

Implements ISoundManager.

References send().

+ Here is the call graph for this function:

◆ step()

void sound::ProxySoundManager::step ( f32 dtime)
overridevirtual

Removes finished sounds, steps streamed sounds, and does similar tasks.

Should not be called while paused.

Parameters
dtimeIn seconds.

Implements ISoundManager.

References Empty, handleMsg(), sound::OpenALSoundManager::m_queue_to_proxy, m_sound_manager, MutexedQueue< T >::pop_frontNoEx(), and Stopped.

Referenced by fadeSound().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stopSound()

void sound::ProxySoundManager::stopSound ( sound_handle_t sound)
overridevirtual

Request the sound to be stopped.

The id should be freed afterwards.

Implements ISoundManager.

References send().

+ Here is the call graph for this function:

◆ updateListener()

void sound::ProxySoundManager::updateListener ( const v3f & pos,
const v3f & vel,
const v3f & at,
const v3f & up )
overridevirtual
Parameters
posIn node-space.
velIn node-space.
atVector in node-space pointing forwards.
upVector in node-space pointing upwards, orthogonal to at.

Implements ISoundManager.

References send().

+ Here is the call graph for this function:

◆ updateSoundPosVel()

void sound::ProxySoundManager::updateSoundPosVel ( sound_handle_t sound,
const v3f & pos,
const v3f & vel )
overridevirtual

Update position and velocity of positional sound.

Parameters
posIn node-space.
velIn node-space.

Implements ISoundManager.

References send().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_known_sound_names

std::unordered_set<std::string> sound::ProxySoundManager::m_known_sound_names
private

Referenced by loadSoundData(), and loadSoundFile().

◆ m_sound_manager

OpenALSoundManager sound::ProxySoundManager::m_sound_manager
private

The documentation for this class was generated from the following files: