Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jeffrey Ventrella 2013-05-29 11:40:19 -07:00
commit f02e8dae23
2 changed files with 22 additions and 11 deletions

View file

@ -214,8 +214,8 @@ int main(int argc, const char* argv[]) {
(OFF_AXIS_ATTENUATION_FORMULA_STEP * (fabsf(angleOfDelivery) / 90.0f)); (OFF_AXIS_ATTENUATION_FORMULA_STEP * (fabsf(angleOfDelivery) / 90.0f));
attenuationCoefficient = distanceCoefficients[lowAgentIndex][highAgentIndex] attenuationCoefficient = distanceCoefficients[lowAgentIndex][highAgentIndex]
* otherAgentBuffer->getAttenuationRatio() * otherAgentBuffer->getAttenuationRatio()
* offAxisCoefficient; * offAxisCoefficient;
bearingRelativeAngleToSource *= (M_PI / 180); bearingRelativeAngleToSource *= (M_PI / 180);
@ -225,15 +225,15 @@ int main(int argc, const char* argv[]) {
} }
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f
? clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL ? clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL
: clientSamples; : clientSamples;
int16_t* delayedChannel = bearingRelativeAngleToSource > 0.0f int16_t* delayedChannel = bearingRelativeAngleToSource > 0.0f
? clientSamples ? clientSamples
: clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL; : clientSamples + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
int16_t* delaySamplePointer = otherAgentBuffer->getNextOutput() == otherAgentBuffer->getBuffer() int16_t* delaySamplePointer = otherAgentBuffer->getNextOutput() == otherAgentBuffer->getBuffer()
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay ? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
: otherAgentBuffer->getNextOutput() - numSamplesDelay; : otherAgentBuffer->getNextOutput() - numSamplesDelay;
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) { for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {
@ -246,7 +246,7 @@ int main(int argc, const char* argv[]) {
int16_t currentSample = (otherAgentBuffer->getNextOutput()[s] * attenuationCoefficient); int16_t currentSample = (otherAgentBuffer->getNextOutput()[s] * attenuationCoefficient);
plateauAdditionOfSamples(goodChannel[s], currentSample); plateauAdditionOfSamples(goodChannel[s], currentSample);
if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) { if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) {
plateauAdditionOfSamples(delayedChannel[s + numSamplesDelay], plateauAdditionOfSamples(delayedChannel[s + numSamplesDelay],
currentSample * weakChannelAmplitudeRatio); currentSample * weakChannelAmplitudeRatio);
} }
@ -287,6 +287,11 @@ int main(int argc, const char* argv[]) {
} }
agentList->updateAgentWithData(agentAddress, packetData, receivedBytes); agentList->updateAgentWithData(agentAddress, packetData, receivedBytes);
if (std::isnan(((AudioRingBuffer *)avatarAgent->getLinkedData())->getBearing())) {
// kill off this agent - temporary solution to mixer crash on mac sleep
avatarAgent->setAlive(false);
}
} else if (packetData[0] == PACKET_HEADER_INJECT_AUDIO) { } else if (packetData[0] == PACKET_HEADER_INJECT_AUDIO) {
Agent* matchingInjector = NULL; Agent* matchingInjector = NULL;

View file

@ -7,6 +7,7 @@
// //
#include <cstring> #include <cstring>
#include <math.h>
#include "PacketHeaders.h" #include "PacketHeaders.h"
@ -56,7 +57,12 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
memcpy(&_bearing, dataBuffer, sizeof(float)); memcpy(&_bearing, dataBuffer, sizeof(float));
dataBuffer += sizeof(_bearing); dataBuffer += sizeof(_bearing);
if (_bearing > 180 || _bearing < -180) { // if this agent sent us a NaN bearing then don't consider this good audio and bail
if (std::isnan(_bearing)) {
_endOfLastWrite = _nextOutput = _buffer;
_started = false;
return 0;
} else if (_bearing > 180 || _bearing < -180) {
// we were passed an invalid bearing because this agent wants loopback (pressed the H key) // we were passed an invalid bearing because this agent wants loopback (pressed the H key)
_shouldLoopbackForAgent = true; _shouldLoopbackForAgent = true;
@ -66,7 +72,7 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
: _bearing + AGENT_LOOPBACK_MODIFIER; : _bearing + AGENT_LOOPBACK_MODIFIER;
} else { } else {
_shouldLoopbackForAgent = false; _shouldLoopbackForAgent = false;
} }
} }
// make sure we have enough bytes left for this to be the right amount of audio // make sure we have enough bytes left for this to be the right amount of audio