Skip to content

Commit

Permalink
tweak(mumble): simplify how we send clients and channels for the Voic…
Browse files Browse the repository at this point in the history
…eTarget packet

The previous implementation allowed duplicates, and was more complex than what we need since we don't care about channel linking (we would always set it to false)

This will also reset connections if they have too many in flight TCP pings

This removes all the swaps from std::wstring <-> std::string

Send Auth packet immediately after Version

In the spec we have to send the Auth packet after Version, we opted to
do it whenever we get the version packet back, this isn't really needed
and slows down the exchange, since the server will only send `CryptoSetup`
after we send this packet.
  • Loading branch information
AvarianKnight committed Feb 10, 2025
1 parent cf73c44 commit fd6fec4
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 333 deletions.
18 changes: 8 additions & 10 deletions code/components/extra-natives-five/src/NuiAudioSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ extern "C"
class MumbleAudioEntityBase
{
public:
MumbleAudioEntityBase(const std::wstring& name)
MumbleAudioEntityBase(const std::string& name)
: m_position(rage::Vec3V{ 0.f, 0.f, 0.f }),
m_positionForce(rage::Vec3V{ 0.f, 0.f, 0.f }),
m_buffer(nullptr),
Expand Down Expand Up @@ -1389,7 +1389,7 @@ class MumbleAudioEntityBase

CPed* m_ped;

std::wstring m_name;
std::string m_name;

std::function<void(int)> m_poller;
};
Expand All @@ -1398,7 +1398,7 @@ template<int Build>
class MumbleAudioEntity : public rage::audEntity<Build>, public MumbleAudioEntityBase, public std::enable_shared_from_this<MumbleAudioEntity<Build>>
{
public:
MumbleAudioEntity(const std::wstring& name)
MumbleAudioEntity(const std::string& name)
: MumbleAudioEntityBase(name)
{
}
Expand Down Expand Up @@ -1821,7 +1821,7 @@ class MumbleAudioSink : public IMumbleAudioSink
public:
void Process();

MumbleAudioSink(const std::wstring& name);
MumbleAudioSink(const std::string& name);
virtual ~MumbleAudioSink() override;

virtual void SetPollHandler(const std::function<void(int)>& poller) override;
Expand All @@ -1833,7 +1833,7 @@ class MumbleAudioSink : public IMumbleAudioSink
void Reset();

private:
std::wstring m_name;
std::string m_name;
int m_serverId;

/// <summary>
Expand All @@ -1860,11 +1860,9 @@ static std::set<MumbleAudioSink*> g_sinks;
static std::shared_mutex g_submixMutex;
static std::map<int, int> g_submixIds;

MumbleAudioSink::MumbleAudioSink(const std::wstring& name)
: m_serverId(-1), m_position(rage::Vec3V{ 0.f, 0.f, 0.f }), m_distance(5.0f), m_overrideVolume(-1.0f), m_name(name)
MumbleAudioSink::MumbleAudioSink(const std::string& userName)
: m_serverId(-1), m_position(rage::Vec3V{ 0.f, 0.f, 0.f }), m_distance(5.0f), m_overrideVolume(-1.0f), m_name(userName)
{
auto userName = ToNarrow(name);

if (userName.length() >= 2)
{
int serverId = atoi(userName.substr(1, userName.length() - 1).c_str());
Expand Down Expand Up @@ -2888,7 +2886,7 @@ static InitFunction initFunction([]()
ProcessAudioSinks();
});

OnGetMumbleAudioSink.Connect([](const std::wstring& name, fwRefContainer<IMumbleAudioSink>* sink)
OnGetMumbleAudioSink.Connect([](const std::string& name, fwRefContainer<IMumbleAudioSink>* sink)
{
fwRefContainer<MumbleAudioSink> ref = new MumbleAudioSink(name);
*sink = ref;
Expand Down
Loading

0 comments on commit fd6fec4

Please sign in to comment.