mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 11:36:27 +02:00
fix Assignment ctor from data to properly parse payload
This commit is contained in:
parent
9dbbf8c65c
commit
67050f5cd2
3 changed files with 19 additions and 19 deletions
|
@ -159,26 +159,25 @@ void Agent::run() {
|
||||||
// find the audio-mixer in the NodeList so we can inject audio at it
|
// find the audio-mixer in the NodeList so we can inject audio at it
|
||||||
Node* audioMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
Node* audioMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
|
||||||
|
|
||||||
|
|
||||||
if (audioMixer && audioMixer->getActiveSocket()) {
|
if (audioMixer && audioMixer->getActiveSocket()) {
|
||||||
emit willSendAudioDataCallback();
|
emit willSendAudioDataCallback();
|
||||||
|
}
|
||||||
|
|
||||||
if (scriptedAudioInjector.hasSamplesToInject()) {
|
|
||||||
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
|
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
|
||||||
if (usecToSleep > 0) {
|
if (usecToSleep > 0) {
|
||||||
usleep(usecToSleep);
|
usleep(usecToSleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (audioMixer && audioMixer->getActiveSocket() && scriptedAudioInjector.hasSamplesToInject()) {
|
||||||
|
// we have an audio mixer and samples to inject, send those off
|
||||||
scriptedAudioInjector.injectAudio(NodeList::getInstance()->getNodeSocket(), audioMixer->getActiveSocket());
|
scriptedAudioInjector.injectAudio(NodeList::getInstance()->getNodeSocket(), audioMixer->getActiveSocket());
|
||||||
|
|
||||||
// clear out the audio injector so that it doesn't re-send what we just sent
|
// clear out the audio injector so that it doesn't re-send what we just sent
|
||||||
scriptedAudioInjector.clear();
|
scriptedAudioInjector.clear();
|
||||||
}
|
}
|
||||||
} else if (audioMixer) {
|
|
||||||
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
|
|
||||||
if (usecToSleep > 0) {
|
|
||||||
usleep(usecToSleep);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (audioMixer && !audioMixer->getActiveSocket()) {
|
||||||
// don't have an active socket for the audio-mixer, ping it now
|
// don't have an active socket for the audio-mixer, ping it now
|
||||||
NodeList::getInstance()->pingPublicAndLocalSocketsForInactiveNode(audioMixer);
|
NodeList::getInstance()->pingPublicAndLocalSocketsForInactiveNode(audioMixer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
|
||||||
if (dataBuffer[numBytesRead] != '\0') {
|
if (dataBuffer[numBytesRead] != '\0') {
|
||||||
// read the pool from the data buffer
|
// read the pool from the data buffer
|
||||||
setPool((const char*) dataBuffer + numBytesRead);
|
setPool((const char*) dataBuffer + numBytesRead);
|
||||||
|
numBytesRead += strlen(_pool) + sizeof('\0');
|
||||||
} else {
|
} else {
|
||||||
// skip past the null pool and null out our pool
|
// skip past the null pool and null out our pool
|
||||||
setPool(NULL);
|
setPool(NULL);
|
||||||
|
@ -192,7 +193,7 @@ int Assignment::packToBuffer(unsigned char* buffer) {
|
||||||
numPackedBytes += NUM_BYTES_RFC4122_UUID;
|
numPackedBytes += NUM_BYTES_RFC4122_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pool) {
|
if (hasPool()) {
|
||||||
// pack the pool for this assignment, it exists
|
// pack the pool for this assignment, it exists
|
||||||
int numBytesNullTerminatedPool = strlen(_pool) + sizeof('\0');
|
int numBytesNullTerminatedPool = strlen(_pool) + sizeof('\0');
|
||||||
memcpy(buffer + numPackedBytes, _pool, numBytesNullTerminatedPool);
|
memcpy(buffer + numPackedBytes, _pool, numBytesNullTerminatedPool);
|
||||||
|
|
Loading…
Reference in a new issue