use packet version helpers for PACKET_TYPE_INJECT_AUDIO

This commit is contained in:
Stephen Birarda 2013-07-08 14:07:34 -07:00
parent c64a961a38
commit 8f7a3f3567
3 changed files with 7 additions and 7 deletions

View file

@ -21,7 +21,7 @@ InjectedAudioRingBuffer::InjectedAudioRingBuffer() :
} }
int InjectedAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) { int InjectedAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
unsigned char* currentBuffer = sourceBuffer + sizeof(PACKET_TYPE_INJECT_AUDIO); unsigned char* currentBuffer = sourceBuffer + numBytesForPacketHeader(sourceBuffer);
// pull stream identifier from the packet // pull stream identifier from the packet
memcpy(&_streamIdentifier, currentBuffer, sizeof(_streamIdentifier)); memcpy(&_streamIdentifier, currentBuffer, sizeof(_streamIdentifier));

View file

@ -144,7 +144,8 @@ int main(int argc, char* argv[]) {
nodeList->linkedDataCreateCallback = createAvatarDataForNode; nodeList->linkedDataCreateCallback = createAvatarDataForNode;
timeval lastSend = {}; timeval lastSend = {};
unsigned char broadcastPacket = PACKET_TYPE_INJECT_AUDIO; int numBytesPacketHeader = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_INJECT_AUDIO);
unsigned char* broadcastPacket = new unsigned char[numBytesPacketHeader];
timeval lastDomainServerCheckIn = {}; timeval lastDomainServerCheckIn = {};
@ -211,7 +212,7 @@ int main(int argc, char* argv[]) {
// use the UDPSocket instance attached to our node list to ask avatar mixer for a list of avatars // use the UDPSocket instance attached to our node list to ask avatar mixer for a list of avatars
nodeList->getNodeSocket()->send(avatarMixer->getActiveSocket(), nodeList->getNodeSocket()->send(avatarMixer->getActiveSocket(),
&broadcastPacket, &broadcastPacket,
sizeof(broadcastPacket)); numBytesPacketHeader);
} }
} else { } else {
if (!injector.isInjectingAudio() && (::shouldLoopAudio || !::hasInjectedAudioOnce)) { if (!injector.isInjectingAudio() && (::shouldLoopAudio || !::hasInjectedAudioOnce)) {

View file

@ -70,7 +70,7 @@ void AudioInjector::injectAudio(UDPSocket* injectorSocket, sockaddr* destination
timeval startTime; timeval startTime;
// calculate the number of bytes required for additional data // calculate the number of bytes required for additional data
int leadingBytes = sizeof(PACKET_TYPE) int leadingBytes = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_INJECT_AUDIO)
+ sizeof(_streamIdentifier) + sizeof(_streamIdentifier)
+ sizeof(_position) + sizeof(_position)
+ sizeof(_orientation) + sizeof(_orientation)
@ -79,8 +79,7 @@ void AudioInjector::injectAudio(UDPSocket* injectorSocket, sockaddr* destination
unsigned char dataPacket[(BUFFER_LENGTH_SAMPLES_PER_CHANNEL * sizeof(int16_t)) + leadingBytes]; unsigned char dataPacket[(BUFFER_LENGTH_SAMPLES_PER_CHANNEL * sizeof(int16_t)) + leadingBytes];
dataPacket[0] = PACKET_TYPE_INJECT_AUDIO; unsigned char *currentPacketPtr = dataPacket + populateTypeAndVersion(dataPacket, PACKET_TYPE_INJECT_AUDIO);
unsigned char *currentPacketPtr = dataPacket + sizeof(PACKET_TYPE_INJECT_AUDIO);
// copy the identifier for this injector // copy the identifier for this injector
memcpy(currentPacketPtr, &_streamIdentifier, sizeof(_streamIdentifier)); memcpy(currentPacketPtr, &_streamIdentifier, sizeof(_streamIdentifier));