Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 192 files). Show all
Unified · Split
| @@ -323,8 +323,9 @@ void ScriptEngine::evaluate() { · 322 unmodified lines | ||
| 323 | 323 | |
| 324 | 324 | if (_engine.hasUncaughtException()) { |
| 325 | 325 | int line = _engine.uncaughtExceptionLineNumber(); |
| 326 | − qDebug() << "Uncaught exception at line" << line << ":" << result.toString(); | |
| 327 | − emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString()); | |
| 326 | + qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString(); | |
| 327 | + emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString()); | |
| 328 | + _engine.clearExceptions(); | |
| 328 | 329 | } |
| 329 | 330 | } |
| 330 | 331 | |
| @@ -333,7 +334,7 @@ QScriptValue ScriptEngine::evaluate(const QString& program, const QString& fileN · 2 unmodified lines | ||
| 333 | 334 | bool hasUncaughtException = _engine.hasUncaughtException(); |
| 334 | 335 | if (hasUncaughtException) { |
| 335 | 336 | int line = _engine.uncaughtExceptionLineNumber(); |
| 336 | − qDebug() << "Uncaught exception at line" << line << ": " << result.toString(); | |
| 337 | + qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ": " << result.toString(); | |
| 337 | 338 | } |
| 338 | 339 | emit evaluationFinished(result, hasUncaughtException); |
| 339 | 340 | _engine.clearExceptions(); |
| @@ -357,14 +358,15 @@ void ScriptEngine::run() { · 17 unmodified lines | ||
| 357 | 358 | init(); |
| 358 | 359 | } |
| 359 | 360 | _isRunning = true; |
| 361 | + _isFinished = false; | |
| 360 | 362 | emit runningStateChanged(); |
| 361 | 363 | |
| 362 | 364 | QScriptValue result = _engine.evaluate(_scriptContents); |
| 363 | 365 | if (_engine.hasUncaughtException()) { |
| 364 | 366 | int line = _engine.uncaughtExceptionLineNumber(); |
| 365 | − | |
| 366 | − qDebug() << "Uncaught exception at line" << line << ":" << result.toString(); | |
| 367 | − emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString()); | |
| 367 | + qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString(); | |
| 368 | + emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString()); | |
| 369 | + _engine.clearExceptions(); | |
| 368 | 370 | } |
| 369 | 371 | |
| 370 | 372 | QElapsedTimer startTime; |
| @@ -467,13 +469,17 @@ void ScriptEngine::run() { · 96 unmodified lines | ||
| 467 | 469 | _numAvatarSoundSentBytes = 0; |
| 468 | 470 | } |
| 469 | 471 | } |
| 470 | − | |
| 472 | + | |
| 471 | 473 | QByteArray audioPacket = byteArrayWithPopulatedHeader(silentFrame |
| 472 | 474 | ? PacketTypeSilentAudioFrame |
| 473 | 475 | : PacketTypeMicrophoneAudioNoEcho); |
| 474 | 476 | |
| 475 | 477 | QDataStream packetStream(&audioPacket, QIODevice::Append); |
| 476 | 478 | |
| 479 | + // pack a placeholder value for sequence number for now, will be packed when destination node is known | |
| 480 | + int numPreSequenceNumberBytes = audioPacket.size(); | |
| 481 | + packetStream << (quint16)0; | |
| 482 | + | |
| 477 | 483 | // use the orientation and position of this avatar for the source of this audio |
| 478 | 484 | packetStream.writeRawData(reinterpret_cast<const char*>(&_avatarData->getPosition()), sizeof(glm::vec3)); |
| 479 | 485 | glm::quat headOrientation = _avatarData->getHeadOrientation(); |
| @@ -493,7 +499,19 @@ void ScriptEngine::run() { · 13 unmodified lines | ||
| 493 | 499 | numAvailableSamples * sizeof(int16_t)); |
| 494 | 500 | } |
| 495 | 501 | |
| 496 | − nodeList->broadcastToNodes(audioPacket, NodeSet() << NodeType::AudioMixer); | |
| 502 | + // write audio packet to AudioMixer nodes | |
| 503 | + NodeList* nodeList = NodeList::getInstance(); | |
| 504 | + foreach(const SharedNodePointer& node, nodeList->getNodeHash()) { | |
| 505 | + // only send to nodes of type AudioMixer | |
| 506 | + if (node->getType() == NodeType::AudioMixer) { | |
| 507 | + // pack sequence number | |
| 508 | + quint16 sequence = _outgoingScriptAudioSequenceNumbers[node->getUUID()]++; | |
| 509 | + memcpy(audioPacket.data() + numPreSequenceNumberBytes, &sequence, sizeof(quint16)); | |
| 510 | + | |
| 511 | + // send audio packet | |
| 512 | + nodeList->writeDatagram(audioPacket, node); | |
| 513 | + } | |
| 514 | + } | |
| 497 | 515 | } |
| 498 | 516 | } |
| 499 | 517 | |
| @@ -504,8 +522,9 @@ void ScriptEngine::run() { · 4 unmodified lines | ||
| 504 | 522 | |
| 505 | 523 | if (_engine.hasUncaughtException()) { |
| 506 | 524 | int line = _engine.uncaughtExceptionLineNumber(); |
| 507 | − qDebug() << "Uncaught exception at line" << line << ":" << _engine.uncaughtException().toString(); | |
| 508 | − emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + _engine.uncaughtException().toString()); | |
| 525 | + qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << _engine.uncaughtException().toString(); | |
| 526 | + emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + _engine.uncaughtException().toString()); | |
| 527 | + _engine.clearExceptions(); | |
| 509 | 528 | } |
| 510 | 529 | } |
| 511 | 530 | emit scriptEnding(); |
| @@ -665,5 +684,10 @@ void ScriptEngine::include(const QString& includeFile) { · 153 unmodified lines | ||
| 665 | 684 | int line = _engine.uncaughtExceptionLineNumber(); |
| 666 | 685 | qDebug() << "Uncaught exception at (" << includeFile << ") line" << line << ":" << result.toString(); |
| 667 | 686 | emit errorMessage("Uncaught exception at (" + includeFile + ") line" + QString::number(line) + ":" + result.toString()); |
| 687 | + _engine.clearExceptions(); | |
| 668 | 688 | } |
| 669 | 689 | } |
| 690 | + | |
| 691 | +void ScriptEngine::nodeKilled(SharedNodePointer node) { | |
| 692 | + _outgoingScriptAudioSequenceNumbers.remove(node->getUUID()); | |
| 693 | +} | |