Showing the changes to interface/src/Application.cpp (1 of 70 files). Show all
Unified · Split
| @@ -654,6 +654,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 653 unmodified lines | ||
| 654 | 654 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us |
| 655 | 655 | |
| 656 | 656 | auto nodeList = DependencyManager::get<NodeList>(); |
| 657 | + nodeList->startThread(); | |
| 657 | 658 | |
| 658 | 659 | // Set up a watchdog thread to intentionally crash the application on deadlocks |
| 659 | 660 | _deadlockWatchdogThread = new DeadlockWatchdogThread(); |
| @@ -679,25 +680,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 19 unmodified lines | ||
| 679 | 680 | |
| 680 | 681 | updateHeartbeat(); |
| 681 | 682 | |
| 682 | − // start the nodeThread so its event loop is running | |
| 683 | − QThread* nodeThread = new QThread(this); | |
| 684 | − nodeThread->setObjectName("NodeList Thread"); | |
| 685 | − nodeThread->start(); | |
| 686 | − | |
| 687 | − // make sure the node thread is given highest priority | |
| 688 | − nodeThread->setPriority(QThread::TimeCriticalPriority); | |
| 689 | − | |
| 690 | 683 | // setup a timer for domain-server check ins |
| 691 | 684 | QTimer* domainCheckInTimer = new QTimer(nodeList.data()); |
| 692 | 685 | connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn); |
| 693 | 686 | domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); |
| 694 | 687 | |
| 695 | − // put the NodeList and datagram processing on the node thread | |
| 696 | − nodeList->moveToThread(nodeThread); | |
| 697 | − | |
| 698 | − // put the audio processing on a separate thread | |
| 699 | − QThread* audioThread = new QThread(); | |
| 700 | − audioThread->setObjectName("Audio Thread"); | |
| 701 | 688 | |
| 702 | 689 | auto audioIO = DependencyManager::get<AudioClient>(); |
| 703 | 690 | audioIO->setPositionGetter([]{ |
| @@ -713,7 +700,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines | ||
| 713 | 700 | return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY; |
| 714 | 701 | }); |
| 715 | 702 | |
| 716 | − audioIO->moveToThread(audioThread); | |
| 717 | 703 | recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) { |
| 718 | 704 | audioIO->handleRecordedAudioInput(frame->data); |
| 719 | 705 | }); |
| @@ -727,9 +713,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 7 unmodified lines | ||
| 727 | 713 | }); |
| 728 | 714 | |
| 729 | 715 | auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>(); |
| 730 | − connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start); | |
| 731 | − connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit); | |
| 732 | − connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater); | |
| 733 | 716 | connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled); |
| 734 | 717 | connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer); |
| 735 | 718 | connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket); |
| @@ -747,19 +730,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 11 unmodified lines | ||
| 747 | 730 | } |
| 748 | 731 | }); |
| 749 | 732 | |
| 750 | − audioThread->start(); | |
| 733 | + audioIO->startThread(); | |
| 751 | 734 | |
| 752 | 735 | ResourceManager::init(); |
| 753 | 736 | // Make sure we don't time out during slow operations at startup |
| 754 | 737 | updateHeartbeat(); |
| 755 | 738 | |
| 756 | 739 | // Setup MessagesClient |
| 757 | − auto messagesClient = DependencyManager::get<MessagesClient>(); | |
| 758 | − QThread* messagesThread = new QThread; | |
| 759 | − messagesThread->setObjectName("Messages Client Thread"); | |
| 760 | − messagesClient->moveToThread(messagesThread); | |
| 761 | − connect(messagesThread, &QThread::started, messagesClient.data(), &MessagesClient::init); | |
| 762 | − messagesThread->start(); | |
| 740 | + DependencyManager::get<MessagesClient>()->startThread(); | |
| 763 | 741 | |
| 764 | 742 | const DomainHandler& domainHandler = nodeList->getDomainHandler(); |
| 765 | 743 | |
| @@ -1679,12 +1657,7 @@ void Application::aboutToQuit() { · 913 unmodified lines | ||
| 1679 | 1657 | _autoSwitchDisplayModeSupportedHMDPlugin->endSession(); |
| 1680 | 1658 | } |
| 1681 | 1659 | // use the CloseEventSender via a QThread to send an event that says the user asked for the app to close |
| 1682 | − auto closeEventSender = DependencyManager::get<CloseEventSender>(); | |
| 1683 | − QThread* closureEventThread = new QThread(this); | |
| 1684 | − closeEventSender->moveToThread(closureEventThread); | |
| 1685 | − // sendQuitEventAsync will bail immediately if the UserActivityLogger is not enabled | |
| 1686 | − connect(closureEventThread, &QThread::started, closeEventSender.data(), &CloseEventSender::sendQuitEventAsync); | |
| 1687 | − closureEventThread->start(); | |
| 1660 | + DependencyManager::get<CloseEventSender>()->startThread(); | |
| 1688 | 1661 | |
| 1689 | 1662 | // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. |
| 1690 | 1663 | DependencyManager::get<OffscreenUi>()->hide("RunningScripts"); |
| @@ -1772,6 +1745,8 @@ void Application::cleanupBeforeQuit() { · 81 unmodified lines | ||
| 1772 | 1745 | // stop QML |
| 1773 | 1746 | DependencyManager::destroy<OffscreenUi>(); |
| 1774 | 1747 | |
| 1748 | + DependencyManager::destroy<OffscreenQmlSurfaceCache>(); | |
| 1749 | + | |
| 1775 | 1750 | if (_snapshotSoundInjector != nullptr) { |
| 1776 | 1751 | _snapshotSoundInjector->stop(); |
| 1777 | 1752 | } |
| @@ -1831,15 +1806,9 @@ Application::~Application() { · 53 unmodified lines | ||
| 1831 | 1806 | |
| 1832 | 1807 | ResourceManager::cleanup(); |
| 1833 | 1808 | |
| 1834 | − QThread* nodeThread = DependencyManager::get<NodeList>()->thread(); | |
| 1835 | − | |
| 1836 | 1809 | // remove the NodeList from the DependencyManager |
| 1837 | 1810 | DependencyManager::destroy<NodeList>(); |
| 1838 | 1811 | |
| 1839 | − // ask the node thread to quit and wait until it is done | |
| 1840 | − nodeThread->quit(); | |
| 1841 | − nodeThread->wait(); | |
| 1842 | − | |
| 1843 | 1812 | Leapmotion::destroy(); |
| 1844 | 1813 | |
| 1845 | 1814 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { |
| @@ -4152,10 +4121,10 @@ void Application::updateMyAvatarLookAtPosition() { · 2306 unmodified lines | ||
| 4152 | 4121 | } |
| 4153 | 4122 | } else { |
| 4154 | 4123 | // I am not looking at anyone else, so just look forward |
| 4155 | − if (isHMD) { | |
| 4156 | − glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * | |
| 4157 | − myAvatar->getHeadControllerPoseInSensorFrame().getMatrix(); | |
| 4158 | − lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, -TREE_SCALE)); | |
| 4124 | + auto headPose = myAvatar->getHeadControllerPoseInSensorFrame(); | |
| 4125 | + if (headPose.isValid()) { | |
| 4126 | + glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * headPose.getMatrix(); | |
| 4127 | + lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, TREE_SCALE)); | |
| 4159 | 4128 | } else { |
| 4160 | 4129 | lookAtSpot = myAvatar->getHead()->getEyePosition() + |
| 4161 | 4130 | (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); |