Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 50fd9e5

Browse files
committed
Changed argument ordering of AudioMan::StopSound for consistency
Added Global Playback and Handling audioman region Added RTETools to audioman header to have access to limit Moved g_SoundEventsListMutex to a working spot
1 parent 6240570 commit 50fd9e5

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

Entities/SoundContainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ namespace RTE {
230230
/// </summary>
231231
/// <param name="player">Player to stop playback of this SoundContainer for.</param>
232232
/// <returns>Whether this SoundContainer successfully stopped playing.</returns>
233-
bool Stop(int player) { return HasAnySounds() ? g_AudioMan.StopSound(player, this) : false; }
233+
bool Stop(int player) { return HasAnySounds() ? g_AudioMan.StopSound(this, player) : false; }
234234

235235
/// <summary>
236236
/// Selects, saves and returns the next sound of this SoundContainer to be played.

Managers/AudioMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ namespace RTE {
481481

482482
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
483483

484-
bool AudioMan::StopSound(int player, SoundContainer *pSoundContainer) {
484+
bool AudioMan::StopSound(SoundContainer *pSoundContainer, int player) {
485485
if (m_IsInMultiplayerMode && pSoundContainer) {
486486
RegisterSoundEvent(player, SOUND_STOP, pSoundContainer->GetHash(), 0, pSoundContainer->GetPlayingChannels(), pSoundContainer->GetLoopSetting(), 1.0, pSoundContainer->IsAffectedByGlobalPitch());
487487
}

Managers/AudioMan.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _RTEAUDIOMAN_
33

44
#include "Constants.h"
5+
#include "RTETools.h"
56
#include "Entity.h"
67
#include "Timer.h"
78
#include "Singleton.h"
@@ -219,10 +220,12 @@ namespace RTE {
219220
bool SetSoundPitch(SoundContainer *pSound, float pitch);
220221
#pragma endregion
221222

223+
#pragma region Global Playback and Handling
222224
/// <summary>
223225
/// Stops all playback and clears the music playlist.
224226
/// </summary>
225227
void StopAll() { if (m_AudioEnabled) { m_MasterChannelGroup->stop(); } m_MusicPlayList.clear(); }
228+
#pragma endregion
226229

227230
#pragma region Music Playback and Handling
228231
/// <summary>
@@ -319,7 +322,7 @@ namespace RTE {
319322
/// <param name="player">Which player to stop the SoundContainer for.</param>
320323
/// <param name="pSound">Pointer to the SoundContainer to stop playing. Ownership is NOT transferred!</param>
321324
/// <returns></returns>
322-
bool StopSound(int player, SoundContainer *pSound);
325+
bool StopSound(SoundContainer *pSound, int player);
323326

324327
/// <summary>
325328
/// Fades out playback of all sounds in a specific SoundContainer.
@@ -404,6 +407,8 @@ namespace RTE {
404407
std::list<NetworkSoundData> m_SoundEvents[c_MaxClients]; //!< Lists of per player sound events.
405408
std::list<NetworkMusicData> m_MusicEvents[c_MaxClients]; //!< Lists of per player music events.
406409

410+
std::mutex g_SoundEventsListMutex[c_MaxClients]; //!< A list for locking sound events for multiplayer to avoid race conditions and other such problems.
411+
407412
private:
408413
/// <summary>
409414
/// A static callback function for FMOD to invoke when the music channel finishes playing. See fmod docs - FMOD_SYSTEM_CALLBACK for details

Managers/LuaMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ int LuaMan::Create()
15001500
.def("PlaySound", (SoundContainer *(AudioMan:: *)(const char *filePath, float attenuation, int player)) &AudioMan::PlaySound)
15011501
.def("PlaySound", (SoundContainer * (AudioMan:: *)(const char *filePath, float attenuation, int player, int loops, int priority, double pitchOrAffectedByGlobalPitch)) &AudioMan::PlaySound)
15021502
.def("StopSound", (bool (AudioMan:: *)(SoundContainer *soundContainer)) &AudioMan::StopSound)
1503-
.def("StopSound", (bool (AudioMan:: *)(int player, SoundContainer *soundContainer)) &AudioMan::StopSound)
1503+
.def("StopSound", (bool (AudioMan:: *)(SoundContainer *soundContainer, int player)) &AudioMan::StopSound)
15041504
.def("FadeOutSound", &AudioMan::FadeOutSound),
15051505

15061506
class_<UInputMan>("UInputManager")

0 commit comments

Comments
 (0)