diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index f3b623bac2..d6e82a3889 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -383,7 +383,8 @@ void AudioMixer::run() { const float STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.10f; const float BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.20f; - const float CUTOFF_DELTA = 0.02f; + + const float RATIO_BACK_OFF = 0.02f; const float CURRENT_FRAME_RATIO = 1.0f / TRAILING_AVERAGE_FRAMES; const float PREVIOUS_FRAMES_RATIO = 1.0f - CURRENT_FRAME_RATIO; @@ -399,20 +400,20 @@ void AudioMixer::run() { bool hasRatioChanged = false; if (framesSinceCutoffEvent >= TRAILING_AVERAGE_FRAMES) { + if (framesSinceCutoffEvent % TRAILING_AVERAGE_FRAMES == 0) { + qDebug() << "Current trailing sleep ratio:" << _trailingSleepRatio; + } + if (_trailingSleepRatio <= STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD) { // we're struggling - change our min required loudness to reduce some load - audabilityCutoffRatio += CUTOFF_DELTA; - - if (audabilityCutoffRatio >= 1) { - audabilityCutoffRatio = 1 - CUTOFF_DELTA; - } + audabilityCutoffRatio = audabilityCutoffRatio + (0.5f * (1.0f - audabilityCutoffRatio)); qDebug() << "Mixer is struggling, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was" << lastCutoffRatio << "and is now" << audabilityCutoffRatio; hasRatioChanged = true; } else if (_trailingSleepRatio >= BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD && audabilityCutoffRatio != 0) { // we've recovered and can back off the required loudness - audabilityCutoffRatio -= CUTOFF_DELTA; + audabilityCutoffRatio = audabilityCutoffRatio - RATIO_BACK_OFF; if (audabilityCutoffRatio < 0) { audabilityCutoffRatio = 0; @@ -430,8 +431,10 @@ void AudioMixer::run() { framesSinceCutoffEvent = 0; } - } else { - framesSinceCutoffEvent++; + } + + if (!hasRatioChanged) { + ++framesSinceCutoffEvent; } foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { diff --git a/assignment-client/src/main.cpp b/assignment-client/src/main.cpp index 7ee0ea9e14..0151f93319 100644 --- a/assignment-client/src/main.cpp +++ b/assignment-client/src/main.cpp @@ -15,8 +15,10 @@ int main(int argc, char* argv[]) { +#ifndef WIN32 setvbuf(stdout, NULL, _IOLBF, 0); - +#endif + // use the verbose message handler in Logging qInstallMessageHandler(Logging::verboseMessageHandler); diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index 496f9af1a0..d4dfa80724 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -880,7 +880,9 @@ void OctreeServer::run() { // we need to ask the DS about agents so we can ping/reply with them nodeList->addNodeTypeToInterestSet(NodeType::Agent); +#ifndef WIN32 setvbuf(stdout, NULL, _IOLBF, 0); +#endif nodeList->linkedDataCreateCallback = &OctreeServer::attachQueryNodeToNode; diff --git a/domain-server/src/main.cpp b/domain-server/src/main.cpp index 1d9f554237..970d1dad70 100644 --- a/domain-server/src/main.cpp +++ b/domain-server/src/main.cpp @@ -20,10 +20,11 @@ int main(int argc, char* argv[]) { +#ifndef WIN32 setvbuf(stdout, NULL, _IOLBF, 0); - +#endif + qInstallMessageHandler(Logging::verboseMessageHandler); - DomainServer domainServer(argc, argv); return domainServer.exec(); diff --git a/libraries/shared/src/Logging.cpp b/libraries/shared/src/Logging.cpp index 1713382fcf..f0dcd7b67b 100644 --- a/libraries/shared/src/Logging.cpp +++ b/libraries/shared/src/Logging.cpp @@ -86,7 +86,7 @@ const char* stringForLogType(QtMsgType msgType) { } // the following will produce 2000-10-02 13:55:36 -0700 -const char DATE_STRING_FORMAT[] = "%F %H:%M:%S %z"; +const char DATE_STRING_FORMAT[] = "%Y-%m-%d %H:%M:%S %z"; void Logging::verboseMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { if (message.isEmpty()) {