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
490 // pack a placeholder value for sequence number for now, will be packed when destination node is known490 // pack a placeholder value for sequence number for now, will be packed when destination node is known
491 int numPreSequenceNumberBytes = audioPacket.size();491 int numPreSequenceNumberBytes = audioPacket.size();
492 packetStream << (quint16) 0;492 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));
501 493
502 if (silentFrame) {494 if (silentFrame) {
503 if (!_isListeningToAudioStream) {495 if (!_isListeningToAudioStream) {
@@ -507,12 +499,20 @@ void ScriptEngine::run() { · 3 unmodified lines
507 499
508 // write the number of silent samples so the audio-mixer can uphold timing500 // write the number of silent samples so the audio-mixer can uphold timing
509 packetStream.writeRawData(reinterpret_cast<const char*>(&SCRIPT_AUDIO_BUFFER_SAMPLES), sizeof(int16_t));501 packetStream.writeRawData(reinterpret_cast<const char*>(&SCRIPT_AUDIO_BUFFER_SAMPLES), sizeof(int16_t));
502
510 } else if (nextSoundOutput) {503 } 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
511 // write the raw audio data512 // write the raw audio data
512 packetStream.writeRawData(reinterpret_cast<const char*>(nextSoundOutput),513 packetStream.writeRawData(reinterpret_cast<const char*>(nextSoundOutput), numAvailableSamples * sizeof(int16_t));
513 numAvailableSamples * sizeof(int16_t));
514 }514 }
515 515
516 // write audio packet to AudioMixer nodes516 // write audio packet to AudioMixer nodes
517 NodeList* nodeList = NodeList::getInstance();517 NodeList* nodeList = NodeList::getInstance();
518 foreach(const SharedNodePointer& node, nodeList->getNodeHash()) {518 foreach(const SharedNodePointer& node, nodeList->getNodeHash()) {