mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 12:24:29 +02:00
don't use audio when the bearing sent by the agent is garbage
This commit is contained in:
parent
78df9fb2ed
commit
f45062a097
1 changed files with 9 additions and 8 deletions
|
@ -36,8 +36,6 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
|
|
||||||
unsigned char* dataBuffer = sourceBuffer + 1;
|
unsigned char* dataBuffer = sourceBuffer + 1;
|
||||||
|
|
||||||
printf("The number of bytes received is %d\n", numBytes);
|
|
||||||
|
|
||||||
if (sourceBuffer[0] == PACKET_HEADER_INJECT_AUDIO ||
|
if (sourceBuffer[0] == PACKET_HEADER_INJECT_AUDIO ||
|
||||||
sourceBuffer[0] == PACKET_HEADER_MICROPHONE_AUDIO) {
|
sourceBuffer[0] == PACKET_HEADER_MICROPHONE_AUDIO) {
|
||||||
// if this came from an injector or interface client
|
// if this came from an injector or interface client
|
||||||
|
@ -58,19 +56,22 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
memcpy(&_bearing, dataBuffer, sizeof(float));
|
memcpy(&_bearing, dataBuffer, sizeof(float));
|
||||||
dataBuffer += sizeof(_bearing);
|
dataBuffer += sizeof(_bearing);
|
||||||
|
|
||||||
printf("This agent's bearing is %f\n", _bearing);
|
// if this agent sent us a NaN bearing then don't consider this good audio and bail
|
||||||
|
if (_bearing != _bearing) {
|
||||||
if (_bearing > 180 || _bearing < -180) {
|
_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;
|
||||||
|
|
||||||
// correct the bearing
|
// correct the bearing
|
||||||
_bearing = _bearing > 0
|
_bearing = _bearing > 0
|
||||||
? _bearing - AGENT_LOOPBACK_MODIFIER
|
? _bearing - AGENT_LOOPBACK_MODIFIER
|
||||||
: _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
|
||||||
|
|
Loading…
Reference in a new issue