mirror of
https://github.com/overte-org/overte.git
synced 2025-05-09 02:38:51 +02:00
fix should ignore opts
This commit is contained in:
parent
310c8b18ee
commit
207d2e78f0
3 changed files with 18 additions and 16 deletions
|
@ -59,7 +59,7 @@ AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldIgnore(const SharedNodePointer self, const SharedNodePointer node, unsigned int frame) {
|
bool AudioMixerClientData::shouldIgnore(const SharedNodePointer self, const SharedNodePointer node, unsigned int frame) {
|
||||||
// this is symmetric over self / node; they cache their computations to reduce work by 2x
|
// this is symmetric over self / node; they cache their computations to reduce work by 2x
|
||||||
|
|
||||||
auto& localCache = _nodeSourcesIgnoreMap[node->getUUID()];
|
auto& localCache = _nodeSourcesIgnoreMap[node->getUUID()];
|
||||||
|
@ -81,32 +81,32 @@ bool shouldIgnore(const SharedNodePointer self, const SharedNodePointer node, un
|
||||||
(!self->isIgnoringNodeWithID(node->getUUID()) ||
|
(!self->isIgnoringNodeWithID(node->getUUID()) ||
|
||||||
(nodeData->getRequestsDomainListData() && node->getCanKick())) &&
|
(nodeData->getRequestsDomainListData() && node->getCanKick())) &&
|
||||||
(!node->isIgnoringNodeWithID(self->getUUID()) ||
|
(!node->isIgnoringNodeWithID(self->getUUID()) ||
|
||||||
(getsRequestsDomainListData() && self->getCanKick()))) {
|
(getRequestsDomainListData() && self->getCanKick()))) {
|
||||||
|
|
||||||
// if either node is enabling an ignore radius, check their proximity
|
// if either node is enabling an ignore radius, check their proximity
|
||||||
if ((listener->isIgnoreRadiusEnabled() || node->isIgnoreRadiusEnabled())) {
|
if ((self->isIgnoreRadiusEnabled() || node->isIgnoreRadiusEnabled())) {
|
||||||
auto& listenerZone = listenerData->getIgnoreZone(frame);
|
auto& zone = getIgnoreZone(frame);
|
||||||
auto& nodeZone = nodeData->getIgnoreZone(frame);
|
auto& nodeZone = nodeData->getIgnoreZone(frame);
|
||||||
shouldIgnore = listenerBox.touches(nodeZone);
|
shouldIgnore = zone.touches(nodeZone);
|
||||||
} else {
|
} else {
|
||||||
shouldIgnore = false;
|
shouldIgnore = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remoteCache = nodeData._nodeSourcesIgnoreMap[self->getUUID()];
|
auto& remoteCache = nodeData->_nodeSourcesIgnoreMap[self->getUUID()];
|
||||||
// do not reset the cache until it has been used to avoid a data race
|
// do not reset the cache until it has been used to avoid a data race
|
||||||
if (!remoteCache.isCached) {
|
if (!remoteCache.isCached) {
|
||||||
cache.shouldIgnore = shouldIgnore;
|
remoteCache.shouldIgnore = shouldIgnore;
|
||||||
remoteCache.isCached = true;
|
remoteCache.isCached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shouldIgnore;
|
return shouldIgnore;
|
||||||
}
|
}
|
||||||
|
|
||||||
IgnoreZone& AudioMixerClientData::getIgnoreZone(unsigned int frame) {
|
AudioMixerClientData::IgnoreZone& AudioMixerClientData::getIgnoreZone(unsigned int frame) {
|
||||||
// check for a memoized zone
|
// check for a memoized zone
|
||||||
if (frame != _ignoreZoneMemo.frame.load(std::memory_order_acquire) {
|
if (frame != _ignoreZoneMemo.frame.load(std::memory_order_acquire)) {
|
||||||
stream = getAvatarAudioStream();
|
auto stream = getAvatarAudioStream();
|
||||||
|
|
||||||
// get the initial dimensions from the stream
|
// get the initial dimensions from the stream
|
||||||
glm::vec3 corner = stream ? stream->getAvatarBoundingBoxCorner() : glm::vec3(0);
|
glm::vec3 corner = stream ? stream->getAvatarBoundingBoxCorner() : glm::vec3(0);
|
||||||
|
@ -130,10 +130,11 @@ IgnoreZone& AudioMixerClientData::getIgnoreZone(unsigned int frame) {
|
||||||
// so take a lock and only update the memo if this call is first.
|
// so take a lock and only update the memo if this call is first.
|
||||||
// this prevents concurrent updates from invalidating the returned reference
|
// this prevents concurrent updates from invalidating the returned reference
|
||||||
// (contingent on the preconditions listed in the header).
|
// (contingent on the preconditions listed in the header).
|
||||||
std::lock_guard lock(_ignoreZoneMemo.mutex);
|
std::lock_guard<std::mutex> lock(_ignoreZoneMemo.mutex);
|
||||||
if (frame != _ignoreZoneMemo.frame.load(std::memory_order_acquire)) {
|
if (frame != _ignoreZoneMemo.frame.load(std::memory_order_acquire)) {
|
||||||
_ignoreZoneMemo.zone = box;
|
_ignoreZoneMemo.zone = box;
|
||||||
unsigned int oldFrame = _ignoreZoneMemo.frame.exchange(frame, std::memory_order_release);
|
unsigned int oldFrame = _ignoreZoneMemo.frame.exchange(frame, std::memory_order_release);
|
||||||
|
Q_UNUSED(oldFrame);
|
||||||
|
|
||||||
// check the precondition
|
// check the precondition
|
||||||
assert(frame == (oldFrame + 1));
|
assert(frame == (oldFrame + 1));
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
class AudioMixerClientData : public NodeData {
|
class AudioMixerClientData : public NodeData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
using IgnoreZone = AABox;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioMixerClientData(const QUuid& nodeID);
|
AudioMixerClientData(const QUuid& nodeID);
|
||||||
|
@ -107,11 +106,13 @@ public slots:
|
||||||
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
|
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
using IgnoreZone = AABox;
|
||||||
|
|
||||||
// returns an ignore zone, memoized by frame (lockless if the zone is already memoized)
|
// returns an ignore zone, memoized by frame (lockless if the zone is already memoized)
|
||||||
// preconditions:
|
// preconditions:
|
||||||
// - frame is monotonically increasing
|
// - frame is monotonically increasing
|
||||||
// - calls are only made to getIgnoreZone(frame + 1) when there are no references left from calls to getIgnoreZone(frame)
|
// - calls are only made to getIgnoreZone(frame + 1) when there are no references left from calls to getIgnoreZone(frame)
|
||||||
IgnoreZone& AudioMixerClientData::getIgnoreZone(unsigned int frame);
|
IgnoreZone& getIgnoreZone(unsigned int frame);
|
||||||
|
|
||||||
QReadWriteLock _streamsLock;
|
QReadWriteLock _streamsLock;
|
||||||
AudioStreamMap _audioStreams; // microphone stream from avatar is stored under key of null UUID
|
AudioStreamMap _audioStreams; // microphone stream from avatar is stored under key of null UUID
|
||||||
|
@ -124,8 +125,8 @@ private:
|
||||||
IgnoreZoneMemo _ignoreZoneMemo;
|
IgnoreZoneMemo _ignoreZoneMemo;
|
||||||
|
|
||||||
struct IgnoreNodeData {
|
struct IgnoreNodeData {
|
||||||
std::atomic<bool> flag { false };
|
std::atomic<bool> isCached { false };
|
||||||
bool ignore { false };
|
bool shouldIgnore { false };
|
||||||
};
|
};
|
||||||
using NodeSourcesIgnoreMap = std::unordered_map<QUuid, IgnoreNodeData>;
|
using NodeSourcesIgnoreMap = std::unordered_map<QUuid, IgnoreNodeData>;
|
||||||
NodeSourcesIgnoreMap _nodeSourcesIgnoreMap;
|
NodeSourcesIgnoreMap _nodeSourcesIgnoreMap;
|
||||||
|
|
|
@ -145,7 +145,7 @@ bool AudioMixerSlave::prepareMix(const SharedNodePointer& listener) {
|
||||||
mixStream(*listenerData, node->getUUID(), *listenerAudioStream, *nodeStream);
|
mixStream(*listenerData, node->getUUID(), *listenerAudioStream, *nodeStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!listenerData->shouldIgnoreNode(listener, node, _frame)) {
|
} else if (!listenerData->shouldIgnore(listener, node, _frame)) {
|
||||||
if (!isThrottling) {
|
if (!isThrottling) {
|
||||||
allStreams(node, &AudioMixerSlave::mixStream);
|
allStreams(node, &AudioMixerSlave::mixStream);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue