mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:06:02 +02:00
move _shouldLoopbackForNode to PositionalAudioRingBuffer for access in injector
This commit is contained in:
parent
8681e66ed3
commit
80a2bd0844
9 changed files with 20 additions and 11 deletions
|
@ -200,8 +200,7 @@ void AudioMixer::prepareMixForListeningNode(Node* node) {
|
||||||
PositionalAudioRingBuffer* otherNodeBuffer = otherNodeClientData->getRingBuffers()[i];
|
PositionalAudioRingBuffer* otherNodeBuffer = otherNodeClientData->getRingBuffers()[i];
|
||||||
|
|
||||||
if ((*otherNode != *node
|
if ((*otherNode != *node
|
||||||
|| otherNodeBuffer->getType() != PositionalAudioRingBuffer::Microphone
|
|| otherNodeBuffer->shouldLoopbackForNode())
|
||||||
|| nodeRingBuffer->shouldLoopbackForNode())
|
|
||||||
&& otherNodeBuffer->willBeAddedToMix()) {
|
&& otherNodeBuffer->willBeAddedToMix()) {
|
||||||
addBufferToMixForListeningNodeWithBuffer(otherNodeBuffer, nodeRingBuffer);
|
addBufferToMixForListeningNodeWithBuffer(otherNodeBuffer, nodeRingBuffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
#include "AvatarAudioRingBuffer.h"
|
#include "AvatarAudioRingBuffer.h"
|
||||||
|
|
||||||
AvatarAudioRingBuffer::AvatarAudioRingBuffer() :
|
AvatarAudioRingBuffer::AvatarAudioRingBuffer() :
|
||||||
PositionalAudioRingBuffer(PositionalAudioRingBuffer::Microphone),
|
PositionalAudioRingBuffer(PositionalAudioRingBuffer::Microphone) {
|
||||||
_shouldLoopbackForNode(false) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,10 @@ public:
|
||||||
AvatarAudioRingBuffer();
|
AvatarAudioRingBuffer();
|
||||||
|
|
||||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||||
|
|
||||||
bool shouldLoopbackForNode() const { return _shouldLoopbackForNode; }
|
|
||||||
private:
|
private:
|
||||||
// disallow copying of AvatarAudioRingBuffer objects
|
// disallow copying of AvatarAudioRingBuffer objects
|
||||||
AvatarAudioRingBuffer(const AvatarAudioRingBuffer&);
|
AvatarAudioRingBuffer(const AvatarAudioRingBuffer&);
|
||||||
AvatarAudioRingBuffer& operator= (const AvatarAudioRingBuffer&);
|
AvatarAudioRingBuffer& operator= (const AvatarAudioRingBuffer&);
|
||||||
|
|
||||||
bool _shouldLoopbackForNode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__AvatarAudioRingBuffer__) */
|
#endif /* defined(__hifi__AvatarAudioRingBuffer__) */
|
||||||
|
|
|
@ -95,6 +95,10 @@ void AudioInjector::injectAudio(AbstractAudioInterface* localAudioInterface) {
|
||||||
memcpy(currentPacketPosition, rfcStreamUUID, rfcStreamUUID.size());
|
memcpy(currentPacketPosition, rfcStreamUUID, rfcStreamUUID.size());
|
||||||
currentPacketPosition += rfcStreamUUID.size();
|
currentPacketPosition += rfcStreamUUID.size();
|
||||||
|
|
||||||
|
// pack the flag for loopback
|
||||||
|
memcpy(currentPacketPosition, &_shouldLoopback, sizeof(_shouldLoopback));
|
||||||
|
currentPacketPosition += sizeof(_shouldLoopback);
|
||||||
|
|
||||||
// pack the position for injected audio
|
// pack the position for injected audio
|
||||||
memcpy(currentPacketPosition, &_position, sizeof(_position));
|
memcpy(currentPacketPosition, &_position, sizeof(_position));
|
||||||
currentPacketPosition += sizeof(_position);
|
currentPacketPosition += sizeof(_position);
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
void setPosition(const glm::vec3& position) { _position = position; }
|
void setPosition(const glm::vec3& position) { _position = position; }
|
||||||
void setOrientation(const glm::quat& orientation) { _orientation = orientation; }
|
void setOrientation(const glm::quat& orientation) { _orientation = orientation; }
|
||||||
void setVolume(float volume) { _volume = std::max(fabsf(volume), 1.0f); }
|
void setVolume(float volume) { _volume = std::max(fabsf(volume), 1.0f); }
|
||||||
|
void setShouldLoopback(bool shouldLoopback) { _shouldLoopback = shouldLoopback; }
|
||||||
public slots:
|
public slots:
|
||||||
void injectViaThread(AbstractAudioInterface* localAudioInterface = NULL);
|
void injectViaThread(AbstractAudioInterface* localAudioInterface = NULL);
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ private:
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
glm::quat _orientation;
|
glm::quat _orientation;
|
||||||
float _volume;
|
float _volume;
|
||||||
bool _shouldLoopback;
|
uchar _shouldLoopback;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startDownload();
|
void startDownload();
|
||||||
|
|
|
@ -32,6 +32,12 @@ int InjectedAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes
|
||||||
// push past the UUID for this node and the stream identifier
|
// push past the UUID for this node and the stream identifier
|
||||||
currentBuffer += (NUM_BYTES_RFC4122_UUID * 2);
|
currentBuffer += (NUM_BYTES_RFC4122_UUID * 2);
|
||||||
|
|
||||||
|
// pull the loopback flag and set our boolean
|
||||||
|
uchar shouldLoopback;
|
||||||
|
memcpy(&shouldLoopback, currentBuffer, sizeof(shouldLoopback));
|
||||||
|
currentBuffer += sizeof(shouldLoopback);
|
||||||
|
_shouldLoopbackForNode = (shouldLoopback == 1);
|
||||||
|
|
||||||
// use parsePositionalData in parent PostionalAudioRingBuffer class to pull common positional data
|
// use parsePositionalData in parent PostionalAudioRingBuffer class to pull common positional data
|
||||||
currentBuffer += parsePositionalData(currentBuffer, numBytes - (currentBuffer - sourceBuffer));
|
currentBuffer += parsePositionalData(currentBuffer, numBytes - (currentBuffer - sourceBuffer));
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ PositionalAudioRingBuffer::PositionalAudioRingBuffer(PositionalAudioRingBuffer::
|
||||||
_type(type),
|
_type(type),
|
||||||
_position(0.0f, 0.0f, 0.0f),
|
_position(0.0f, 0.0f, 0.0f),
|
||||||
_orientation(0.0f, 0.0f, 0.0f, 0.0f),
|
_orientation(0.0f, 0.0f, 0.0f, 0.0f),
|
||||||
_willBeAddedToMix(false)
|
_willBeAddedToMix(false),
|
||||||
|
_shouldLoopbackForNode(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
bool willBeAddedToMix() const { return _willBeAddedToMix; }
|
bool willBeAddedToMix() const { return _willBeAddedToMix; }
|
||||||
void setWillBeAddedToMix(bool willBeAddedToMix) { _willBeAddedToMix = willBeAddedToMix; }
|
void setWillBeAddedToMix(bool willBeAddedToMix) { _willBeAddedToMix = willBeAddedToMix; }
|
||||||
|
|
||||||
|
bool shouldLoopbackForNode() const { return _shouldLoopbackForNode; }
|
||||||
|
|
||||||
PositionalAudioRingBuffer::Type getType() const { return _type; }
|
PositionalAudioRingBuffer::Type getType() const { return _type; }
|
||||||
const glm::vec3& getPosition() const { return _position; }
|
const glm::vec3& getPosition() const { return _position; }
|
||||||
const glm::quat& getOrientation() const { return _orientation; }
|
const glm::quat& getOrientation() const { return _orientation; }
|
||||||
|
@ -46,6 +48,7 @@ protected:
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
glm::quat _orientation;
|
glm::quat _orientation;
|
||||||
bool _willBeAddedToMix;
|
bool _willBeAddedToMix;
|
||||||
|
bool _shouldLoopbackForNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__PositionalAudioRingBuffer__) */
|
#endif /* defined(__hifi__PositionalAudioRingBuffer__) */
|
||||||
|
|
|
@ -18,7 +18,7 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
|
||||||
case PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO:
|
case PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO:
|
||||||
case PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO:
|
case PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO:
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
case PACKET_TYPE_HEAD_DATA:
|
case PACKET_TYPE_HEAD_DATA:
|
||||||
return 12;
|
return 12;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue