move _shouldLoopbackForNode to PositionalAudioRingBuffer for access in injector

This commit is contained in:
Stephen Birarda 2013-12-19 15:44:04 -08:00
parent 8681e66ed3
commit 80a2bd0844
9 changed files with 20 additions and 11 deletions

View file

@ -200,8 +200,7 @@ void AudioMixer::prepareMixForListeningNode(Node* node) {
PositionalAudioRingBuffer* otherNodeBuffer = otherNodeClientData->getRingBuffers()[i];
if ((*otherNode != *node
|| otherNodeBuffer->getType() != PositionalAudioRingBuffer::Microphone
|| nodeRingBuffer->shouldLoopbackForNode())
|| otherNodeBuffer->shouldLoopbackForNode())
&& otherNodeBuffer->willBeAddedToMix()) {
addBufferToMixForListeningNodeWithBuffer(otherNodeBuffer, nodeRingBuffer);
}

View file

@ -11,8 +11,7 @@
#include "AvatarAudioRingBuffer.h"
AvatarAudioRingBuffer::AvatarAudioRingBuffer() :
PositionalAudioRingBuffer(PositionalAudioRingBuffer::Microphone),
_shouldLoopbackForNode(false) {
PositionalAudioRingBuffer(PositionalAudioRingBuffer::Microphone) {
}

View file

@ -18,14 +18,10 @@ public:
AvatarAudioRingBuffer();
int parseData(unsigned char* sourceBuffer, int numBytes);
bool shouldLoopbackForNode() const { return _shouldLoopbackForNode; }
private:
// disallow copying of AvatarAudioRingBuffer objects
AvatarAudioRingBuffer(const AvatarAudioRingBuffer&);
AvatarAudioRingBuffer& operator= (const AvatarAudioRingBuffer&);
bool _shouldLoopbackForNode;
};
#endif /* defined(__hifi__AvatarAudioRingBuffer__) */

View file

@ -95,6 +95,10 @@ void AudioInjector::injectAudio(AbstractAudioInterface* localAudioInterface) {
memcpy(currentPacketPosition, rfcStreamUUID, rfcStreamUUID.size());
currentPacketPosition += rfcStreamUUID.size();
// pack the flag for loopback
memcpy(currentPacketPosition, &_shouldLoopback, sizeof(_shouldLoopback));
currentPacketPosition += sizeof(_shouldLoopback);
// pack the position for injected audio
memcpy(currentPacketPosition, &_position, sizeof(_position));
currentPacketPosition += sizeof(_position);

View file

@ -31,6 +31,7 @@ public:
void setPosition(const glm::vec3& position) { _position = position; }
void setOrientation(const glm::quat& orientation) { _orientation = orientation; }
void setVolume(float volume) { _volume = std::max(fabsf(volume), 1.0f); }
void setShouldLoopback(bool shouldLoopback) { _shouldLoopback = shouldLoopback; }
public slots:
void injectViaThread(AbstractAudioInterface* localAudioInterface = NULL);
@ -42,7 +43,7 @@ private:
glm::vec3 _position;
glm::quat _orientation;
float _volume;
bool _shouldLoopback;
uchar _shouldLoopback;
private slots:
void startDownload();

View file

@ -32,6 +32,12 @@ int InjectedAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes
// push past the UUID for this node and the stream identifier
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
currentBuffer += parsePositionalData(currentBuffer, numBytes - (currentBuffer - sourceBuffer));

View file

@ -19,7 +19,8 @@ PositionalAudioRingBuffer::PositionalAudioRingBuffer(PositionalAudioRingBuffer::
_type(type),
_position(0.0f, 0.0f, 0.0f),
_orientation(0.0f, 0.0f, 0.0f, 0.0f),
_willBeAddedToMix(false)
_willBeAddedToMix(false),
_shouldLoopbackForNode(false)
{
}

View file

@ -33,6 +33,8 @@ public:
bool willBeAddedToMix() const { return _willBeAddedToMix; }
void setWillBeAddedToMix(bool willBeAddedToMix) { _willBeAddedToMix = willBeAddedToMix; }
bool shouldLoopbackForNode() const { return _shouldLoopbackForNode; }
PositionalAudioRingBuffer::Type getType() const { return _type; }
const glm::vec3& getPosition() const { return _position; }
const glm::quat& getOrientation() const { return _orientation; }
@ -46,6 +48,7 @@ protected:
glm::vec3 _position;
glm::quat _orientation;
bool _willBeAddedToMix;
bool _shouldLoopbackForNode;
};
#endif /* defined(__hifi__PositionalAudioRingBuffer__) */

View file

@ -18,7 +18,7 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
case PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO:
case PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO:
return 2;
case PACKET_TYPE_HEAD_DATA:
return 12;