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
654654 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
655655
656656 auto nodeList = DependencyManager::get<NodeList>();
657+ nodeList->startThread();
657658
658659 // Set up a watchdog thread to intentionally crash the application on deadlocks
659660 _deadlockWatchdogThread = new DeadlockWatchdogThread();
@@ -679,25 +680,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 19 unmodified lines
679680
680681 updateHeartbeat();
681682
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−
690683 // setup a timer for domain-server check ins
691684 QTimer* domainCheckInTimer = new QTimer(nodeList.data());
692685 connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);
693686 domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
694687
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");
701688
702689 auto audioIO = DependencyManager::get<AudioClient>();
703690 audioIO->setPositionGetter([]{
@@ -713,7 +700,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
713700 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;
714701 });
715702
716− audioIO->moveToThread(audioThread);
717703 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {
718704 audioIO->handleRecordedAudioInput(frame->data);
719705 });
@@ -727,9 +713,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 7 unmodified lines
727713 });
728714
729715 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);
733716 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
734717 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
735718 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
747730 }
748731 });
749732
750− audioThread->start();
733+ audioIO->startThread();
751734
752735 ResourceManager::init();
753736 // Make sure we don't time out during slow operations at startup
754737 updateHeartbeat();
755738
756739 // 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();
763741
764742 const DomainHandler& domainHandler = nodeList->getDomainHandler();
765743
@@ -1679,12 +1657,7 @@ void Application::aboutToQuit() { · 913 unmodified lines
16791657 _autoSwitchDisplayModeSupportedHMDPlugin->endSession();
16801658 }
16811659 // 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();
16881661
16891662 // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
16901663 DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
@@ -1772,6 +1745,8 @@ void Application::cleanupBeforeQuit() { · 81 unmodified lines
17721745 // stop QML
17731746 DependencyManager::destroy<OffscreenUi>();
17741747
1748+ DependencyManager::destroy<OffscreenQmlSurfaceCache>();
1749+
17751750 if (_snapshotSoundInjector != nullptr) {
17761751 _snapshotSoundInjector->stop();
17771752 }
@@ -1831,15 +1806,9 @@ Application::~Application() { · 53 unmodified lines
18311806
18321807 ResourceManager::cleanup();
18331808
1834− QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
1835−
18361809 // remove the NodeList from the DependencyManager
18371810 DependencyManager::destroy<NodeList>();
18381811
1839− // ask the node thread to quit and wait until it is done
1840− nodeThread->quit();
1841− nodeThread->wait();
1842−
18431812 Leapmotion::destroy();
18441813
18451814 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
@@ -4152,10 +4121,10 @@ void Application::updateMyAvatarLookAtPosition() { · 2306 unmodified lines
41524121 }
41534122 } else {
41544123 // 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));
41594128 } else {
41604129 lookAtSpot = myAvatar->getHead()->getEyePosition() +
41614130 (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));