History

Merge branch 'master' of https://github.com/highfidelity/hifi into orange

samcake committed 9 years ago

Commit bb389382 parents 3664655 e65895370 files · +1309 −332Browse files

Showing the changes to interface/src/Application.cpp (1 of 70 files). Show all

Unified · Split

interface/src/Application.cpp+10−41
@@ -654,6 +654,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 653 unmodified lines
654 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us654 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
655 655
656 auto nodeList = DependencyManager::get<NodeList>();656 auto nodeList = DependencyManager::get<NodeList>();
657 nodeList->startThread();
657 658
658 // Set up a watchdog thread to intentionally crash the application on deadlocks659 // Set up a watchdog thread to intentionally crash the application on deadlocks
659 _deadlockWatchdogThread = new DeadlockWatchdogThread();660 _deadlockWatchdogThread = new DeadlockWatchdogThread();
@@ -679,25 +680,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 19 unmodified lines
679 680
680 updateHeartbeat();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 // setup a timer for domain-server check ins683 // setup a timer for domain-server check ins
691 QTimer* domainCheckInTimer = new QTimer(nodeList.data());684 QTimer* domainCheckInTimer = new QTimer(nodeList.data());
692 connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);685 connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);
693 domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);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 auto audioIO = DependencyManager::get<AudioClient>();689 auto audioIO = DependencyManager::get<AudioClient>();
703 audioIO->setPositionGetter([]{690 audioIO->setPositionGetter([]{
@@ -713,7 +700,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
713 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;700 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;
714 });701 });
715 702
716 audioIO->moveToThread(audioThread);
717 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {703 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {
718 audioIO->handleRecordedAudioInput(frame->data);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 auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>();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 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);716 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
734 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);717 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
735 connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);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 ResourceManager::init();735 ResourceManager::init();
753 // Make sure we don't time out during slow operations at startup736 // Make sure we don't time out during slow operations at startup
754 updateHeartbeat();737 updateHeartbeat();
755 738
756 // Setup MessagesClient739 // Setup MessagesClient
757 auto messagesClient = DependencyManager::get<MessagesClient>();740 DependencyManager::get<MessagesClient>()->startThread();
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();
763 741
764 const DomainHandler& domainHandler = nodeList->getDomainHandler();742 const DomainHandler& domainHandler = nodeList->getDomainHandler();
765 743
@@ -1679,12 +1657,7 @@ void Application::aboutToQuit() { · 913 unmodified lines
1679 _autoSwitchDisplayModeSupportedHMDPlugin->endSession();1657 _autoSwitchDisplayModeSupportedHMDPlugin->endSession();
1680 }1658 }
1681 // use the CloseEventSender via a QThread to send an event that says the user asked for the app to close1659 // 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>();1660 DependencyManager::get<CloseEventSender>()->startThread();
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();
1688 1661
1689 // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.1662 // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
1690 DependencyManager::get<OffscreenUi>()->hide("RunningScripts");1663 DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
@@ -1772,6 +1745,8 @@ void Application::cleanupBeforeQuit() { · 81 unmodified lines
1772 // stop QML1745 // stop QML
1773 DependencyManager::destroy<OffscreenUi>();1746 DependencyManager::destroy<OffscreenUi>();
1774 1747
1748 DependencyManager::destroy<OffscreenQmlSurfaceCache>();
1749
1775 if (_snapshotSoundInjector != nullptr) {1750 if (_snapshotSoundInjector != nullptr) {
1776 _snapshotSoundInjector->stop();1751 _snapshotSoundInjector->stop();
1777 }1752 }
@@ -1831,15 +1806,9 @@ Application::~Application() { · 53 unmodified lines
1831 1806
1832 ResourceManager::cleanup();1807 ResourceManager::cleanup();
1833 1808
1834 QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
1835
1836 // remove the NodeList from the DependencyManager1809 // remove the NodeList from the DependencyManager
1837 DependencyManager::destroy<NodeList>();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 Leapmotion::destroy();1812 Leapmotion::destroy();
1844 1813
1845 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {1814 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
@@ -4152,10 +4121,10 @@ void Application::updateMyAvatarLookAtPosition() { · 2306 unmodified lines
4152 }4121 }
4153 } else {4122 } else {
4154 // I am not looking at anyone else, so just look forward4123 // I am not looking at anyone else, so just look forward
4155 if (isHMD) {4124 auto headPose = myAvatar->getHeadControllerPoseInSensorFrame();
4156 glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() *4125 if (headPose.isValid()) {
4157 myAvatar->getHeadControllerPoseInSensorFrame().getMatrix();4126 glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * headPose.getMatrix();
4158 lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, -TREE_SCALE));4127 lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, TREE_SCALE));
4159 } else {4128 } else {
4160 lookAtSpot = myAvatar->getHead()->getEyePosition() +4129 lookAtSpot = myAvatar->getHead()->getEyePosition() +
4161 (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));4130 (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));