History

silent audio packet type generalized

wangyix committed 12 years ago

Commit 48254571 parent 7e5972310 files · +85 −79Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 10 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+11−11
@@ -490,14 +490,6 @@ void ScriptEngine::run() { · 489 unmodified lines
490490 // pack a placeholder value for sequence number for now, will be packed when destination node is known
491491 int numPreSequenceNumberBytes = audioPacket.size();
492492 packetStream << (quint16) 0;
493−
494− // assume scripted avatar audio is mono and set channel flag to zero
495− packetStream << (quint8) 0;
496−
497− // use the orientation and position of this avatar for the source of this audio
498− packetStream.writeRawData(reinterpret_cast<const char*>(&_avatarData->getPosition()), sizeof(glm::vec3));
499− glm::quat headOrientation = _avatarData->getHeadOrientation();
500− packetStream.writeRawData(reinterpret_cast<const char*>(&headOrientation), sizeof(glm::quat));
501493
502494 if (silentFrame) {
503495 if (!_isListeningToAudioStream) {
@@ -507,12 +499,20 @@ void ScriptEngine::run() { · 3 unmodified lines
507499
508500 // write the number of silent samples so the audio-mixer can uphold timing
509501 packetStream.writeRawData(reinterpret_cast<const char*>(&SCRIPT_AUDIO_BUFFER_SAMPLES), sizeof(int16_t));
502+
510503 } else if (nextSoundOutput) {
504+ // assume scripted avatar audio is mono and set channel flag to zero
505+ packetStream << (quint8)0;
506+
507+ // use the orientation and position of this avatar for the source of this audio
508+ packetStream.writeRawData(reinterpret_cast<const char*>(&_avatarData->getPosition()), sizeof(glm::vec3));
509+ glm::quat headOrientation = _avatarData->getHeadOrientation();
510+ packetStream.writeRawData(reinterpret_cast<const char*>(&headOrientation), sizeof(glm::quat));
511+
511512 // write the raw audio data
512− packetStream.writeRawData(reinterpret_cast<const char*>(nextSoundOutput),
513− numAvailableSamples * sizeof(int16_t));
513+ packetStream.writeRawData(reinterpret_cast<const char*>(nextSoundOutput), numAvailableSamples * sizeof(int16_t));
514514 }
515−
515+
516516 // write audio packet to AudioMixer nodes
517517 NodeList* nodeList = NodeList::getInstance();
518518 foreach(const SharedNodePointer& node, nodeList->getNodeHash()) {