History

Merge branch 'master' of github.com:highfidelity/hifi into fix-head-puck-broken-eyes

Seth Alves committed 9 years ago

Commit 197fb622 parents ce4c3e1 759a87c52 files · +1068 −296Browse files

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

Unified · Split

interface/src/Application.cpp+6−37
@@ -653,6 +653,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 652 unmodified lines
653 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us653 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
654 654
655 auto nodeList = DependencyManager::get<NodeList>();655 auto nodeList = DependencyManager::get<NodeList>();
656 nodeList->startThread();
656 657
657 // Set up a watchdog thread to intentionally crash the application on deadlocks658 // Set up a watchdog thread to intentionally crash the application on deadlocks
658 _deadlockWatchdogThread = new DeadlockWatchdogThread();659 _deadlockWatchdogThread = new DeadlockWatchdogThread();
@@ -678,25 +679,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 19 unmodified lines
678 679
679 updateHeartbeat();680 updateHeartbeat();
680 681
681 // start the nodeThread so its event loop is running
682 QThread* nodeThread = new QThread(this);
683 nodeThread->setObjectName("NodeList Thread");
684 nodeThread->start();
685
686 // make sure the node thread is given highest priority
687 nodeThread->setPriority(QThread::TimeCriticalPriority);
688
689 // setup a timer for domain-server check ins682 // setup a timer for domain-server check ins
690 QTimer* domainCheckInTimer = new QTimer(nodeList.data());683 QTimer* domainCheckInTimer = new QTimer(nodeList.data());
691 connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);684 connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);
692 domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);685 domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
693 686
694 // put the NodeList and datagram processing on the node thread
695 nodeList->moveToThread(nodeThread);
696
697 // put the audio processing on a separate thread
698 QThread* audioThread = new QThread();
699 audioThread->setObjectName("Audio Thread");
700 687
701 auto audioIO = DependencyManager::get<AudioClient>();688 auto audioIO = DependencyManager::get<AudioClient>();
702 audioIO->setPositionGetter([]{689 audioIO->setPositionGetter([]{
@@ -712,7 +699,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
712 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;699 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;
713 });700 });
714 701
715 audioIO->moveToThread(audioThread);
716 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {702 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {
717 audioIO->handleRecordedAudioInput(frame->data);703 audioIO->handleRecordedAudioInput(frame->data);
718 });704 });
@@ -726,9 +712,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 7 unmodified lines
726 });712 });
727 713
728 auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>();714 auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>();
729 connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
730 connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit);
731 connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater);
732 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);715 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
733 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);716 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
734 connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);717 connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);
@@ -746,19 +729,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 11 unmodified lines
746 }729 }
747 });730 });
748 731
749 audioThread->start();732 audioIO->startThread();
750 733
751 ResourceManager::init();734 ResourceManager::init();
752 // Make sure we don't time out during slow operations at startup735 // Make sure we don't time out during slow operations at startup
753 updateHeartbeat();736 updateHeartbeat();
754 737
755 // Setup MessagesClient738 // Setup MessagesClient
756 auto messagesClient = DependencyManager::get<MessagesClient>();739 DependencyManager::get<MessagesClient>()->startThread();
757 QThread* messagesThread = new QThread;
758 messagesThread->setObjectName("Messages Client Thread");
759 messagesClient->moveToThread(messagesThread);
760 connect(messagesThread, &QThread::started, messagesClient.data(), &MessagesClient::init);
761 messagesThread->start();
762 740
763 const DomainHandler& domainHandler = nodeList->getDomainHandler();741 const DomainHandler& domainHandler = nodeList->getDomainHandler();
764 742
@@ -1678,12 +1656,7 @@ void Application::aboutToQuit() { · 913 unmodified lines
1678 _autoSwitchDisplayModeSupportedHMDPlugin->endSession();1656 _autoSwitchDisplayModeSupportedHMDPlugin->endSession();
1679 }1657 }
1680 // use the CloseEventSender via a QThread to send an event that says the user asked for the app to close1658 // use the CloseEventSender via a QThread to send an event that says the user asked for the app to close
1681 auto closeEventSender = DependencyManager::get<CloseEventSender>();1659 DependencyManager::get<CloseEventSender>()->startThread();
1682 QThread* closureEventThread = new QThread(this);
1683 closeEventSender->moveToThread(closureEventThread);
1684 // sendQuitEventAsync will bail immediately if the UserActivityLogger is not enabled
1685 connect(closureEventThread, &QThread::started, closeEventSender.data(), &CloseEventSender::sendQuitEventAsync);
1686 closureEventThread->start();
1687 1660
1688 // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.1661 // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
1689 DependencyManager::get<OffscreenUi>()->hide("RunningScripts");1662 DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
@@ -1771,6 +1744,8 @@ void Application::cleanupBeforeQuit() { · 81 unmodified lines
1771 // stop QML1744 // stop QML
1772 DependencyManager::destroy<OffscreenUi>();1745 DependencyManager::destroy<OffscreenUi>();
1773 1746
1747 DependencyManager::destroy<OffscreenQmlSurfaceCache>();
1748
1774 if (_snapshotSoundInjector != nullptr) {1749 if (_snapshotSoundInjector != nullptr) {
1775 _snapshotSoundInjector->stop();1750 _snapshotSoundInjector->stop();
1776 }1751 }
@@ -1830,15 +1805,9 @@ Application::~Application() { · 53 unmodified lines
1830 1805
1831 ResourceManager::cleanup();1806 ResourceManager::cleanup();
1832 1807
1833 QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
1834
1835 // remove the NodeList from the DependencyManager1808 // remove the NodeList from the DependencyManager
1836 DependencyManager::destroy<NodeList>();1809 DependencyManager::destroy<NodeList>();
1837 1810
1838 // ask the node thread to quit and wait until it is done
1839 nodeThread->quit();
1840 nodeThread->wait();
1841
1842 Leapmotion::destroy();1811 Leapmotion::destroy();
1843 1812
1844 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {1813 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {