Isle
Loading...
Searching...
No Matches
MxSoundManager Class Reference

[AI] Manages DirectSound-based sound playback, implementing volume, resource, and device management. More...

#include <mxsoundmanager.h>

Inheritance diagram for MxSoundManager:
Collaboration diagram for MxSoundManager:

Public Member Functions

 MxSoundManager ()
 [AI] Constructs a new MxSoundManager instance. More...
 
 ~MxSoundManager () override
 [AI] Destructor for MxSoundManager. More...
 
void Destroy () override
 [AI] Releases sound resources and unregisters from tickle system. More...
 
void SetVolume (MxS32 p_volume) override
 [AI] Sets the global audio output volume for all managed sound presenters. More...
 
virtual MxResult Create (MxU32 p_frequencyMS, MxBool p_createThread)
 [AI] Initializes and sets up the DirectSound environment. More...
 
virtual void Pause ()
 [AI] Pauses all currently playing wave presenters. More...
 
virtual void Resume ()
 [AI] Resumes all previously paused wave presenters. More...
 
LPDIRECTSOUND GetDirectSound ()
 [AI] Gets pointer to internal DirectSound interface. More...
 
MxS32 GetAttenuation (MxU32 p_volume)
 [AI] Maps a percentage volume (1-100) to a DirectSound-specific attenuation value. More...
 
MxPresenterFUN_100aebd0 (const MxAtomId &p_atomId, MxU32 p_objectId)
 [AI] Finds a presenter matching a specific atom ID and object ID. More...
 
- Public Member Functions inherited from MxAudioManager
 MxAudioManager ()
 [AI] Constructs the audio manager and initializes default volume. More...
 
 ~MxAudioManager () override
 [AI] Destructs the audio manager and handles cleanup of resources. More...
 
MxResult Create () override
 [AI] Initializes audio subsystem resources and registers an instance for global audio management. More...
 
void Destroy () override
 [AI] Tears down the audio subsystem instance and unregisters it from global management. More...
 
virtual MxS32 GetVolume ()
 [AI] Gets the current global audio volume. More...
 
virtual void SetVolume (MxS32 p_volume)
 [AI] Sets the current global audio volume. More...
 
- Public Member Functions inherited from MxMediaManager
 MxMediaManager ()
 [AI] Constructor. More...
 
 ~MxMediaManager () override
 [AI] Destructor. More...
 
MxResult Tickle () override
 [AI] Called by the tickle manager to step through and update all presenters, and process their output data. More...
 
virtual MxResult Create ()
 [AI] Allocates and initializes the internal presenter list for this manager, ensuring thread safety. More...
 
virtual void Destroy ()
 [AI] Destroys all registered presenters and resets the internal state, ensuring safe resource disposal. More...
 
virtual void RegisterPresenter (MxPresenter &p_presenter)
 [AI] Register a new presenter for tickle management and playback coordination. More...
 
virtual void UnregisterPresenter (MxPresenter &p_presenter)
 [AI] Remove a presenter from tickle and managed output lists. More...
 
virtual void StopPresenters ()
 [AI] Stops/ends the action on all registered presenters, typically halting all playback and output. More...
 
MxResult Init ()
 [AI] Initializes all internal members to their default values. More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Protected Member Functions

void Init ()
 [AI] Internal initialization routine for member variables and DirectSound pointers. More...
 
void Destroy (MxBool p_fromDestructor)
 [AI] Internal destroy logic for use both in destructor and standard resource reset. More...
 
- Protected Member Functions inherited from MxAudioManager
void Init ()
 [AI] Initializes audio manager state, setting default volume and other relevant fields. More...
 

Protected Attributes

LPDIRECTSOUND m_directSound
 [AI] Pointer to main DirectSound interface. Needed for all DirectSound operations. More...
 
LPDIRECTSOUNDBUFFER m_dsBuffer
 [AI] Primary DirectSound buffer interface for setting output format/volume. More...
 
undefined m_unk0x38 [4]
 [AI] Unknown, reserved/unused memory or opaque data per binary compatibility. [AI_SUGGESTED_NAME: reserved] [AI] More...
 
- Protected Attributes inherited from MxAudioManager
MxS32 m_volume
 [AI] Holds the current global audio volume for the game. More...
 
- Protected Attributes inherited from MxMediaManager
MxPresenterListm_presenters
 [AI] Pointer to list of currently registered (active) presenters. More...
 
MxThreadm_thread
 [AI] Optional pointer to a worker thread used for media dispatch/IO (if multi-threaded operation is used, otherwise NULL). More...
 
MxCriticalSection m_criticalSection
 [AI] Critical section object used for guarding access to the presenter list and internal members for thread safety. More...
 

Detailed Description

[AI] Manages DirectSound-based sound playback, implementing volume, resource, and device management.

[AI] Forward declaration for the global DirectSound or software-mixer manager for sound FX and voice.

[AI] MxSoundManager provides sound output by controlling DirectSound device and primary buffer. It creates, manages, and destroys relevant resources, integrating with the main tickle/timer system for updating sound playback, volume, and pausing/resuming playback, including compatibility with both standard and 3D audio. It is thread-safe for sound playback through critical section management.

Definition at line 18 of file mxsoundmanager.h.

Constructor & Destructor Documentation

◆ MxSoundManager()

MxSoundManager::MxSoundManager ( )

[AI] Constructs a new MxSoundManager instance.

[AI] Initializes all DirectSound pointers and internal state to a safe default.

Definition at line 26 of file mxsoundmanager.cpp.

◆ ~MxSoundManager()

MxSoundManager::~MxSoundManager ( )
override

[AI] Destructor for MxSoundManager.

[AI] Releases all DirectSound resources and unregisters from tickle managers if necessary.

Definition at line 32 of file mxsoundmanager.cpp.

Member Function Documentation

◆ Create()

MxResult MxSoundManager::Create ( MxU32  p_frequencyMS,
MxBool  p_createThread 
)
virtual

[AI] Initializes and sets up the DirectSound environment.

Parameters
p_frequencyMSTickle/update frequency in milliseconds for updating sound playback. [AI]
p_createThreadIf true, runs the tickle loop in a dedicated thread, otherwise uses the tickle manager. [AI]
Returns
SUCCESS if initialization succeeded, otherwise FAILURE.

[AI] Creates the DirectSound interface, sets the cooperative level, and configures the primary buffer (for 3D or regular sound according to the application's setting). Registers for tickle updates either via a thread or the global tickle manager.

Reimplemented in LegoSoundManager.

Definition at line 71 of file mxsoundmanager.cpp.

◆ Destroy() [1/2]

void MxSoundManager::Destroy ( )
overridevirtual

[AI] Releases sound resources and unregisters from tickle system.

[AI] Used to safely clean up all managed resources, either explicitly or from destruction.

Reimplemented from MxAudioManager.

Definition at line 159 of file mxsoundmanager.cpp.

◆ Destroy() [2/2]

void MxSoundManager::Destroy ( MxBool  p_fromDestructor)
protected

[AI] Internal destroy logic for use both in destructor and standard resource reset.

Parameters
p_fromDestructorSet true if called from destructor to avoid recursive destruction of base classes. [AI]

[AI] Releases DirectSound resources, primary buffer, and manages tickle registration/threads as appropriate. Optionally cascades to parent class destroy.

Definition at line 45 of file mxsoundmanager.cpp.

◆ FUN_100aebd0()

MxPresenter * MxSoundManager::FUN_100aebd0 ( const MxAtomId p_atomId,
MxU32  p_objectId 
)

[AI] Finds a presenter matching a specific atom ID and object ID.

Parameters
p_atomIdThe atom ID corresponding to a resource (audio object identifier). [AI]
p_objectIdUnique object instance identifier used to distinguish between multiple sounds of the same type. [AI]
Returns
A pointer to the matching MxPresenter, or NULL if no match is found.

[AI] Used to locate a currently-active sound presenter for a given asset/object pair.

Definition at line 182 of file mxsoundmanager.cpp.

◆ GetAttenuation()

MxS32 MxSoundManager::GetAttenuation ( MxU32  p_volume)

[AI] Maps a percentage volume (1-100) to a DirectSound-specific attenuation value.

Parameters
p_volumeThe desired volume as a percentage, 1 (min, not zero) to 100 (max). [AI]
Returns
The corresponding DirectSound attenuation value, ranging from -10000 (silent) to 0 (loudest).

[AI] Returns a lookup from a static table for DirectSound volume attenuation.

Definition at line 200 of file mxsoundmanager.cpp.

◆ GetDirectSound()

LPDIRECTSOUND MxSoundManager::GetDirectSound ( )
inline

[AI] Gets pointer to internal DirectSound interface.

Returns
LPDIRECTSOUND interface pointer for use with low-level DirectSound APIs. [AI]

Definition at line 70 of file mxsoundmanager.h.

◆ Init()

void MxSoundManager::Init ( )
protected

[AI] Internal initialization routine for member variables and DirectSound pointers.

[AI] Sets all internal pointers to NULL, called during construction and resource resets.

Definition at line 38 of file mxsoundmanager.cpp.

◆ Pause()

void MxSoundManager::Pause ( )
virtual

[AI] Pauses all currently playing wave presenters.

[AI] Iterates through all managed presenters and pauses those that are MxWavePresenter. Used for suspending sound playback (e.g., when the game is minimized).

Definition at line 212 of file mxsoundmanager.cpp.

◆ Resume()

void MxSoundManager::Resume ( )
virtual

[AI] Resumes all previously paused wave presenters.

[AI] Iterates through all managed presenters and resumes those that are MxWavePresenter. Used for continuing sound playback after a pause.

Definition at line 227 of file mxsoundmanager.cpp.

◆ SetVolume()

void MxSoundManager::SetVolume ( MxS32  p_volume)
overridevirtual

[AI] Sets the global audio output volume for all managed sound presenters.

Parameters
p_volumeVolume level as an integer percentage (0-100). [AI]

[AI] Iterates through all managed sound presenters and sets their individual volumes to match the manager's global volume.

Reimplemented from MxAudioManager.

Definition at line 165 of file mxsoundmanager.cpp.

Member Data Documentation

◆ m_directSound

LPDIRECTSOUND MxSoundManager::m_directSound
protected

[AI] Pointer to main DirectSound interface. Needed for all DirectSound operations.

Definition at line 103 of file mxsoundmanager.h.

◆ m_dsBuffer

LPDIRECTSOUNDBUFFER MxSoundManager::m_dsBuffer
protected

[AI] Primary DirectSound buffer interface for setting output format/volume.

Definition at line 104 of file mxsoundmanager.h.

◆ m_unk0x38

undefined MxSoundManager::m_unk0x38[4]
protected

[AI] Unknown, reserved/unused memory or opaque data per binary compatibility. [AI_SUGGESTED_NAME: reserved] [AI]

Definition at line 105 of file mxsoundmanager.h.


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