mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:35:45 +02:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
07eba1ae88
2 changed files with 114 additions and 109 deletions
|
@ -86,7 +86,7 @@ void *sendBuffer(void *args) {
|
|||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||
AudioRingBuffer* agentBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
||||
|
||||
if (agentBuffer != NULL && agentBuffer->getEndOfLastWrite() != NULL) {
|
||||
if (agentBuffer && agentBuffer->getEndOfLastWrite() != NULL) {
|
||||
|
||||
if (!agentBuffer->isStarted()
|
||||
&& agentBuffer->diffLastWriteNextOutput() <= BUFFER_LENGTH_SAMPLES_PER_CHANNEL + JITTER_BUFFER_SAMPLES) {
|
||||
|
@ -111,6 +111,7 @@ void *sendBuffer(void *args) {
|
|||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||
AudioRingBuffer* agentRingBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
||||
|
||||
if (agentRingBuffer) {
|
||||
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
||||
|
||||
for (AgentList::iterator otherAgent = agentList->begin(); otherAgent != agentList->end(); otherAgent++) {
|
||||
|
@ -140,7 +141,8 @@ void *sendBuffer(void *args) {
|
|||
powf(agentPosition[2] - otherAgentPosition[2], 2));
|
||||
|
||||
float minCoefficient = std::min(1.0f,
|
||||
powf(0.5, (logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1));
|
||||
powf(0.5,
|
||||
(logf(DISTANCE_RATIO * distanceToAgent) / logf(3)) - 1));
|
||||
distanceCoefficients[lowAgentIndex][highAgentIndex] = minCoefficient;
|
||||
}
|
||||
|
||||
|
@ -196,8 +198,12 @@ void *sendBuffer(void *args) {
|
|||
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
|
||||
}
|
||||
|
||||
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f ? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL : clientMix;
|
||||
int16_t* delayedChannel = bearingRelativeAngleToSource > 0.0f ? clientMix : clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f
|
||||
? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL
|
||||
: clientMix;
|
||||
int16_t* delayedChannel = bearingRelativeAngleToSource > 0.0f
|
||||
? clientMix
|
||||
: clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||
|
||||
int16_t* delaySamplePointer = otherAgentBuffer->getNextOutput() == otherAgentBuffer->getBuffer()
|
||||
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
|
||||
|
@ -225,10 +231,11 @@ void *sendBuffer(void *args) {
|
|||
|
||||
agentList->getAgentSocket().send(agent->getPublicSocket(), clientMix, BUFFER_LENGTH_BYTES);
|
||||
}
|
||||
}
|
||||
|
||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||
AudioRingBuffer* agentBuffer = (AudioRingBuffer*) agent->getLinkedData();
|
||||
if (agentBuffer->shouldBeAddedToMix()) {
|
||||
if (agentBuffer && agentBuffer->shouldBeAddedToMix()) {
|
||||
agentBuffer->setNextOutput(agentBuffer->getNextOutput() + BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||
|
||||
if (agentBuffer->getNextOutput() >= agentBuffer->getBuffer() + RING_BUFFER_SAMPLES) {
|
||||
|
|
|
@ -9,15 +9,13 @@
|
|||
#include <cstring>
|
||||
#include "AudioRingBuffer.h"
|
||||
|
||||
AudioRingBuffer::AudioRingBuffer(int ringSamples, int bufferSamples) {
|
||||
ringBufferLengthSamples = ringSamples;
|
||||
bufferLengthSamples = bufferSamples;
|
||||
|
||||
started = false;
|
||||
_shouldBeAddedToMix = false;
|
||||
|
||||
endOfLastWrite = NULL;
|
||||
|
||||
AudioRingBuffer::AudioRingBuffer(int ringSamples, int bufferSamples) :
|
||||
ringBufferLengthSamples(ringSamples),
|
||||
bufferLengthSamples(bufferSamples),
|
||||
endOfLastWrite(NULL),
|
||||
started(false),
|
||||
_shouldBeAddedToMix(false),
|
||||
_shouldLoopbackForAgent(false) {
|
||||
buffer = new int16_t[ringBufferLengthSamples];
|
||||
nextOutput = buffer;
|
||||
};
|
||||
|
@ -27,6 +25,7 @@ AudioRingBuffer::AudioRingBuffer(const AudioRingBuffer &otherRingBuffer) {
|
|||
bufferLengthSamples = otherRingBuffer.bufferLengthSamples;
|
||||
started = otherRingBuffer.started;
|
||||
_shouldBeAddedToMix = otherRingBuffer._shouldBeAddedToMix;
|
||||
_shouldLoopbackForAgent = otherRingBuffer._shouldLoopbackForAgent;
|
||||
|
||||
buffer = new int16_t[ringBufferLengthSamples];
|
||||
memcpy(buffer, otherRingBuffer.buffer, sizeof(int16_t) * ringBufferLengthSamples);
|
||||
|
@ -149,8 +148,7 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
return numBytes;
|
||||
}
|
||||
|
||||
short AudioRingBuffer::diffLastWriteNextOutput()
|
||||
{
|
||||
short AudioRingBuffer::diffLastWriteNextOutput() {
|
||||
if (endOfLastWrite == NULL) {
|
||||
return 0;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue