reduce stream lock usage in AudioMixerClientData::getIgnoreBox

This commit is contained in:
Zach Pomerantz 2017-02-02 16:24:12 +00:00
parent 569ae113a0
commit 9bcc5c95b4
2 changed files with 9 additions and 8 deletions

View file

@ -62,18 +62,21 @@ AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() {
AABox& AudioMixerClientData::getIgnoreBox(unsigned int frame) {
// check for a memoized box
if (frame != _ignoreBoxMemo.frame.load(std::memory_order_acquire) {
// create the box
AABox box(getAvatarBoundingBoxCorner(), getAvatarBoundingBoxScale());
stream = getAvatarAudioStream();
glm::vec3 corner = stream ? stream->getAvatarBoundingBoxCorner() : glm::vec3(0);
glm::vec3 scale = stream ? stream->getAvatarBoundingBoxScale() : glm::vec3(0);
// enforce a minimum scale
static const glm::vec3 MIN_IGNORE_BOX_SCALE = glm::vec3(0.3f, 1.3f, 0.3f);
if (glm::any(glm::lessThan(getAvatarBoundingBoxScale(), MIN_IGNORE_BOX_SCALE))) {
box.setScaleStayCentered(MIN_IGNORE_BOX_SCALE);
if (glm::any(glm::lessThan(scale, MIN_IGNORE_BOX_SCALE))) {
scale = MIN_IGNORE_BOX_SCALE;
}
// quadruple the scale
const float IGNORE_BOX_SCALE_FACTOR = 4.0f;
box.embiggen(IGNORE_BOX_SCALE_FACTOR);
scale *= IGNORE_BOX_SCALE_FACTOR;
// create the box
AABox box(corner, scale);
// update the memoized box
// this may be called by multiple threads concurrently,

View file

@ -96,8 +96,6 @@ public:
bool shouldMuteClient() { return _shouldMuteClient; }
void setShouldMuteClient(bool shouldMuteClient) { _shouldMuteClient = shouldMuteClient; }
glm::vec3 getPosition() { return getAvatarAudioStream() ? getAvatarAudioStream()->getPosition() : glm::vec3(0); }
glm::vec3 getAvatarBoundingBoxCorner() { return getAvatarAudioStream() ? getAvatarAudioStream()->getAvatarBoundingBoxCorner() : glm::vec3(0); }
glm::vec3 getAvatarBoundingBoxScale() { return getAvatarAudioStream() ? getAvatarAudioStream()->getAvatarBoundingBoxScale() : glm::vec3(0); }
bool getRequestsDomainListData() { return _requestsDomainListData; }
void setRequestsDomainListData(bool requesting) { _requestsDomainListData = requesting; }