Mock music and sound effects manager for testing purposes.
#include <MockAudioManager.hpp>
|
bool | isPlaying (const std::string &id) const |
| Whether the sound with the given id is being played or not.
|
|
bool | load (const std::string &music_filepath, const std::string &id, const int &type) |
| Loads an audio file, assigning it a string as identifier. More...
|
|
bool | play (const std::string &id, int loop) |
| Plays a music/sound effect file previously loaded. More...
|
|
bool | stopMusic () |
| Stops the music being played currently. More...
|
|
virtual bool | start () |
| Start the AudioManager. More...
|
|
virtual bool | stop () |
| Stops the AudioManager.
|
|
virtual bool | isStopped () const |
| True if the manager is not active.
|
|
virtual | ~MockAudioManager () |
| Destructor. Used to reset the local static reference after destroying this manager.
|
|
virtual bool | configure (const std::string ¶meter, const std::string &value) |
| Configures a parameter with a value.
|
|
|
static const std::string | id = "MOCK" |
| String that identifies this manager.
|
|
static const int | AUDIO_DURATION = 30 |
| Default duration (s)
|
|
static const int | UPDATE_PERIOD = 100 |
| Thread update period (ms)
|
|
static const int | MUSIC = 0 |
| Identifier for music tracks.
|
|
static const int | FX = 1 |
| Identifier for sound effect tracks.
|
|
|
std::mutex | durations_mutex |
| Dictionary for sound durations:
|
|
std::map< std::string, int > | durations |
|
std::mutex | loop_times_mutex |
| Dictionary for loop times.
|
|
std::map< std::string, int > | loop_times |
|
bool | stopped |
|
|
static bool | Register (AudioManager *manager, const std::string &id) |
| This function allows subclasses to install their unique instances in the singleton register to be selected later by the user.
|
|
◆ MockAudioManager()
rd::MockAudioManager::MockAudioManager |
( |
| ) |
|
|
private |
Constructor for this class is private, since the singleton can only be instantiated once, and the instantiation is done at the RegisterManager() method.
◆ load()
bool rd::MockAudioManager::load |
( |
const std::string & |
music_filepath, |
|
|
const std::string & |
id, |
|
|
const int & |
type |
|
) |
| |
|
virtual |
- Parameters
-
music_filepath | Path to the file to be loaded |
id | String that will identify the audio loaded |
type | Can take a value of MUSIC or FX depending if the audio is to be loaded as game music or sound effect |
- Returns
- True if sound was loaded successfully, false otherwise
Implements rd::AudioManager.
◆ play()
bool rd::MockAudioManager::play |
( |
const std::string & |
id, |
|
|
int |
loop |
|
) |
| |
|
virtual |
- Parameters
-
id | String that identifies the music / sound effect track |
loop | Number of times the music is played. -1 means play the music forever. |
- Returns
- True if sound was played successfully, false otherwise
Implements rd::AudioManager.
◆ RegisterManager()
bool rd::MockAudioManager::RegisterManager |
( |
| ) |
|
|
static |
It ensures that only one manager of this type is created (unique instance).
◆ start()
bool rd::MockAudioManager::start |
( |
| ) |
|
|
virtual |
◆ stopMusic()
bool rd::MockAudioManager::stopMusic |
( |
| ) |
|
|
virtual |
The documentation for this class was generated from the following files: