Send InjectorGainSet packet to the audio-mixer

This commit is contained in:
Ken Cooke 2019-03-15 17:24:50 -07:00 committed by Wayne Chen
parent b15651f1eb
commit 755762e8ec
2 changed files with 29 additions and 0 deletions

View file

@ -265,6 +265,8 @@ void NodeList::reset(bool skipDomainHandlerReset) {
_avatarGainMap.clear();
_avatarGainMapLock.unlock();
_injectorGain = 0.0f;
if (!skipDomainHandlerReset) {
// clear the domain connection information, unless they're the ones that asked us to reset
_domainHandler.softReset();
@ -1087,6 +1089,29 @@ float NodeList::getAvatarGain(const QUuid& nodeID) {
return 0.0f;
}
void NodeList::setInjectorGain(float gain) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) {
// setup the packet
auto setInjectorGainPacket = NLPacket::create(PacketType::InjectorGainSet, sizeof(float), true);
// We need to convert the gain in dB (from the script) to an amplitude before packing it.
setInjectorGainPacket->writePrimitive(packFloatGainToByte(fastExp2f(gain / 6.02059991f)));
qCDebug(networking) << "Sending Set Injector Gain packet with Gain:" << gain;
sendPacket(std::move(setInjectorGainPacket), *audioMixer);
_injectorGain = gain;
} else {
qWarning() << "Couldn't find audio mixer to send set gain request";
}
}
float NodeList::getInjectorGain() {
return _injectorGain;
}
void NodeList::kickNodeBySessionID(const QUuid& nodeID) {
// send a request to domain-server to kick the node with the given session ID
// the domain-server will handle the persistence of the kick (via username or IP)

View file

@ -83,6 +83,8 @@ public:
bool isPersonalMutingNode(const QUuid& nodeID) const;
void setAvatarGain(const QUuid& nodeID, float gain);
float getAvatarGain(const QUuid& nodeID);
void setInjectorGain(float gain);
float getInjectorGain();
void kickNodeBySessionID(const QUuid& nodeID);
void muteNodeBySessionID(const QUuid& nodeID);
@ -181,6 +183,8 @@ private:
mutable QReadWriteLock _avatarGainMapLock;
tbb::concurrent_unordered_map<QUuid, float, UUIDHasher> _avatarGainMap;
std::atomic<float> _injectorGain { 0.0f };
void sendIgnoreRadiusStateToNode(const SharedNodePointer& destinationNode);
#if defined(Q_OS_ANDROID)
Setting::Handle<bool> _ignoreRadiusEnabled { "IgnoreRadiusEnabled", false };