History

merge from upstream

Seth Alves committed 10 years ago

Commit b761ecf2 parents a0771f8 20b7e5f55 files · +1110 −356Browse files

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

Unified · Split

interface/src/Application.cpp+14−27
@@ -210,9 +210,7 @@ const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensi · 209 unmodified lines
210210
211211 class DeadlockWatchdogThread : public QThread {
212212 public:
213− static const unsigned long HEARTBEAT_CHECK_INTERVAL_SECS = 1;
214213 static const unsigned long HEARTBEAT_UPDATE_INTERVAL_SECS = 1;
215− static const unsigned long HEARTBEAT_REPORT_INTERVAL_USECS = 5 * USECS_PER_SECOND;
216214 static const unsigned long MAX_HEARTBEAT_AGE_USECS = 30 * USECS_PER_SECOND;
217215 static const int WARNING_ELAPSED_HEARTBEAT = 500 * USECS_PER_MSEC; // warn if elapsed heartbeat average is large
218216 static const int HEARTBEAT_SAMPLES = 100000; // ~5 seconds worth of samples
@@ -239,8 +237,6 @@ public: · 20 unmodified lines
239237 *crashTrigger = 0xDEAD10CC;
240238 }
241239
242− static void setSuppressStatus(bool suppress) { _suppressStatus = suppress; }
243−
244240 void run() override {
245241 while (!_quit) {
246242 QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
@@ -248,7 +244,6 @@ public: · 1 unmodified line
248244 uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us
249245 uint64_t now = usecTimestampNow();
250246 auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0;
251− auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0;
252247 auto elapsedMovingAverage = _movingAverage.getAverage();
253248
254249 if (elapsedMovingAverage > _maxElapsedAverage) {
@@ -274,21 +269,10 @@ public: · 19 unmodified lines
274269 if (elapsedMovingAverage > WARNING_ELAPSED_HEARTBEAT) {
275270 qDebug() << "DEADLOCK WATCHDOG WARNING:"
276271 << "lastHeartbeatAge:" << lastHeartbeatAge
277− << "elapsedMovingAverage:" << elapsedMovingAverage << "** OVER EXPECTED VALUE**"
278− << "maxElapsed:" << _maxElapsed
279− << "maxElapsedAverage:" << _maxElapsedAverage
280− << "samples:" << _movingAverage.getSamples();
281− _lastReport = now;
282− }
283−
284− if (!_suppressStatus && sinceLastReport > HEARTBEAT_REPORT_INTERVAL_USECS) {
285− qDebug() << "DEADLOCK WATCHDOG STATUS:"
286− << "lastHeartbeatAge:" << lastHeartbeatAge
287− << "elapsedMovingAverage:" << elapsedMovingAverage
272+ << "elapsedMovingAverage:" << elapsedMovingAverage << "** OVER EXPECTED VALUE **"
288273 << "maxElapsed:" << _maxElapsed
289274 << "maxElapsedAverage:" << _maxElapsedAverage
290275 << "samples:" << _movingAverage.getSamples();
291− _lastReport = now;
292276 }
293277
294278 if (lastHeartbeatAge > MAX_HEARTBEAT_AGE_USECS) {
@@ -310,9 +294,7 @@ public: · 15 unmodified lines
310294 }
311295 }
312296
313− static std::atomic<bool> _suppressStatus;
314297 static std::atomic<uint64_t> _heartbeat;
315− static std::atomic<uint64_t> _lastReport;
316298 static std::atomic<uint64_t> _maxElapsed;
317299 static std::atomic<int> _maxElapsedAverage;
318300 static ThreadSafeMovingAverage<int, HEARTBEAT_SAMPLES> _movingAverage;
@@ -320,17 +302,11 @@ public: · 1 unmodified line
320302 bool _quit { false };
321303 };
322304
323−std::atomic<bool> DeadlockWatchdogThread::_suppressStatus;
324305 std::atomic<uint64_t> DeadlockWatchdogThread::_heartbeat;
325−std::atomic<uint64_t> DeadlockWatchdogThread::_lastReport;
326306 std::atomic<uint64_t> DeadlockWatchdogThread::_maxElapsed;
327307 std::atomic<int> DeadlockWatchdogThread::_maxElapsedAverage;
328308 ThreadSafeMovingAverage<int, DeadlockWatchdogThread::HEARTBEAT_SAMPLES> DeadlockWatchdogThread::_movingAverage;
329309
330−void Application::toggleSuppressDeadlockWatchdogStatus(bool checked) {
331− DeadlockWatchdogThread::setSuppressStatus(checked);
332−}
333−
334310 #ifdef Q_OS_WIN
335311 class MyNativeEventFilter : public QAbstractNativeEventFilter {
336312 public:
@@ -3014,8 +2990,19 @@ void Application::init() { · 2677 unmodified lines
30142990 _entityClipboardRenderer.setTree(_entityClipboard);
30152991
30162992 // Make sure any new sounds are loaded as soon as know about them.
3017− connect(tree.get(), &EntityTree::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound);
3018− connect(getMyAvatar(), &MyAvatar::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound);
2993+ connect(tree.get(), &EntityTree::newCollisionSoundURL, this, [this](QUrl newURL, EntityItemID id) {
2994+ EntityTreePointer tree = getEntities()->getTree();
2995+ if (auto entity = tree->findEntityByEntityItemID(id)) {
2996+ auto sound = DependencyManager::get<SoundCache>()->getSound(newURL);
2997+ entity->setCollisionSound(sound);
2998+ }
2999+ }, Qt::QueuedConnection);
3000+ connect(getMyAvatar(), &MyAvatar::newCollisionSoundURL, this, [this](QUrl newURL) {
3001+ if (auto avatar = getMyAvatar()) {
3002+ auto sound = DependencyManager::get<SoundCache>()->getSound(newURL);
3003+ avatar->setCollisionSound(sound);
3004+ }
3005+ }, Qt::QueuedConnection);
30193006 }
30203007
30213008 void Application::updateLOD() const {