From d36943524064737fab4b03f3ed035c602c4ed867 Mon Sep 17 00:00:00 2001 From: wangyix Date: Fri, 11 Jul 2014 13:25:47 -0700 Subject: [PATCH 1/6] added dirty fix for NaN _nextOutputTrailingLoudness --- assignment-client/src/audio/AudioMixer.cpp | 26 ++++++++++++++++++- .../audio/src/PositionalAudioRingBuffer.cpp | 21 ++++++++++----- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 459f8a4b59..c856969de1 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -366,6 +366,11 @@ void AudioMixer::addBufferToMixForListeningNodeWithBuffer(PositionalAudioRingBuf } void AudioMixer::prepareMixForListeningNode(Node* node) { + + static int k = 0; + k++; + bool debug = (k % 20) == 0; + AvatarAudioRingBuffer* nodeRingBuffer = ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer(); // zero out the client mix for this node @@ -381,11 +386,30 @@ void AudioMixer::prepareMixForListeningNode(Node* node) { for (int i = 0; i < otherNodeClientData->getRingBuffers().size(); i++) { PositionalAudioRingBuffer* otherNodeBuffer = otherNodeClientData->getRingBuffers()[i]; + if ((*otherNode != *node || otherNodeBuffer->shouldLoopbackForNode()) && otherNodeBuffer->willBeAddedToMix() - && otherNodeBuffer->getNextOutputTrailingLoudness() > 0) { + && otherNodeBuffer->getNextOutputTrailingLoudness() > 0.0f) { addBufferToMixForListeningNodeWithBuffer(otherNodeBuffer, nodeRingBuffer); + } else { + + //if (debug) { + printf("\nWILL NOT MIX!!!\n"); + printf("listening node = %s\n", node->getUUID().toString().toLatin1().data()); + printf("other node = %s\n", otherNode->getUUID().toString().toLatin1().data()); + + if (otherNodeBuffer->getType() == PositionalAudioRingBuffer::Microphone) + printf("\t avatar buffer...\n"); + else + { + printf("\t inj buffer %s\n", ((InjectedAudioRingBuffer*)otherNodeBuffer)->getStreamIdentifier().toString().toLatin1().data()); + } + + printf("\t\t other==listening || shouldLoopBack: %d\n", (*otherNode != *node || otherNodeBuffer->shouldLoopbackForNode())); + printf("\t\t other will be added to mix: %d\n", otherNodeBuffer->willBeAddedToMix()); + printf("\t\t other trailing loudess: %f\n", otherNodeBuffer->getNextOutputTrailingLoudness()); + //} } } } diff --git a/libraries/audio/src/PositionalAudioRingBuffer.cpp b/libraries/audio/src/PositionalAudioRingBuffer.cpp index 411b02400d..8cba6d72b0 100644 --- a/libraries/audio/src/PositionalAudioRingBuffer.cpp +++ b/libraries/audio/src/PositionalAudioRingBuffer.cpp @@ -32,6 +32,7 @@ PositionalAudioRingBuffer::PositionalAudioRingBuffer(PositionalAudioRingBuffer:: _shouldLoopbackForNode(false), _shouldOutputStarveDebug(true), _isStereo(isStereo), + _nextOutputTrailingLoudness(0.0f), _listenerUnattenuatedZone(NULL), _lastFrameReceivedTime(0), _interframeTimeGapStatsForJitterCalc(TIME_GAPS_FOR_JITTER_CALC_INTERVAL_SAMPLES, TIME_GAPS_FOR_JITTER_CALC_WINDOW_INTERVALS), @@ -121,27 +122,35 @@ void PositionalAudioRingBuffer::updateNextOutputTrailingLoudness() { // ForBoundarySamples means that we expect the number of samples not to roll of the end of the ring buffer float nextLoudness = 0; - for (int i = 0; i < _numFrameSamples; ++i) { - nextLoudness += fabsf(_nextOutput[i]); + if (samplesAvailable() >= _numFrameSamples) { + for (int i = 0; i < _numFrameSamples; ++i) { + nextLoudness += fabsf(_nextOutput[i]); + } + nextLoudness /= _numFrameSamples; + nextLoudness /= MAX_SAMPLE_VALUE; } - nextLoudness /= _numFrameSamples; - nextLoudness /= MAX_SAMPLE_VALUE; - const int TRAILING_AVERAGE_FRAMES = 100; const float CURRENT_FRAME_RATIO = 1.0f / TRAILING_AVERAGE_FRAMES; const float PREVIOUS_FRAMES_RATIO = 1.0f - CURRENT_FRAME_RATIO; const float LOUDNESS_EPSILON = 0.000001f; + float oldNextOutputTrailingLoudness = _nextOutputTrailingLoudness; if (nextLoudness >= _nextOutputTrailingLoudness) { _nextOutputTrailingLoudness = nextLoudness; } else { _nextOutputTrailingLoudness = (_nextOutputTrailingLoudness * PREVIOUS_FRAMES_RATIO) + (CURRENT_FRAME_RATIO * nextLoudness); - + if (_nextOutputTrailingLoudness < LOUDNESS_EPSILON) { _nextOutputTrailingLoudness = 0; } } + + // fixes bug on Windows where _nextOutputTrailingLoudness sometimes becomes NaN. In that case, + // revert _nextOutputTrailingLoudness to its previous value + if (isNaN(_nextOutputTrailingLoudness)) { + _nextOutputTrailingLoudness = oldNextOutputTrailingLoudness; + } } bool PositionalAudioRingBuffer::shouldBeAddedToMix() { From 90c931ea45f24fb89f58f6fda562d4f5f95aedf3 Mon Sep 17 00:00:00 2001 From: wangyix Date: Fri, 11 Jul 2014 15:07:50 -0700 Subject: [PATCH 2/6] removed Audio.cpp initialization list warning; updated Injector removal conditions --- assignment-client/src/audio/AudioMixer.cpp | 4 ++-- assignment-client/src/audio/AudioMixerClientData.cpp | 3 +-- interface/src/Audio.cpp | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index c856969de1..6df23ca32f 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -394,7 +394,7 @@ void AudioMixer::prepareMixForListeningNode(Node* node) { addBufferToMixForListeningNodeWithBuffer(otherNodeBuffer, nodeRingBuffer); } else { - //if (debug) { + if (debug) { printf("\nWILL NOT MIX!!!\n"); printf("listening node = %s\n", node->getUUID().toString().toLatin1().data()); printf("other node = %s\n", otherNode->getUUID().toString().toLatin1().data()); @@ -409,7 +409,7 @@ void AudioMixer::prepareMixForListeningNode(Node* node) { printf("\t\t other==listening || shouldLoopBack: %d\n", (*otherNode != *node || otherNodeBuffer->shouldLoopbackForNode())); printf("\t\t other will be added to mix: %d\n", otherNodeBuffer->willBeAddedToMix()); printf("\t\t other trailing loudess: %f\n", otherNodeBuffer->getNextOutputTrailingLoudness()); - //} + } } } } diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index 94bbdc6a6b..b6e9f8883e 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -154,13 +154,12 @@ void AudioMixerClientData::pushBuffersAfterFrameSend() { // this was a used buffer, push the output pointer forwards PositionalAudioRingBuffer* audioBuffer = *i; - const int INJECTOR_CONSECUTIVE_NOT_MIXED_THRESHOLD = 100; + const int INJECTOR_CONSECUTIVE_NOT_MIXED_THRESHOLD = 200; if (audioBuffer->willBeAddedToMix()) { audioBuffer->shiftReadPosition(audioBuffer->getSamplesPerFrame()); audioBuffer->setWillBeAddedToMix(false); } else if (audioBuffer->getType() == PositionalAudioRingBuffer::Injector - && audioBuffer->hasStarted() && audioBuffer->isStarved() && audioBuffer->getConsecutiveNotMixedCount() > INJECTOR_CONSECUTIVE_NOT_MIXED_THRESHOLD) { // this is an empty audio buffer that has starved, safe to delete // also delete its sequence number stats diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 3689ff0143..bc2da96f6e 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -115,9 +115,9 @@ Audio::Audio(int16_t initialJitterBufferSamples, QObject* parent) : _audioMixerAvatarStreamAudioStats(), _outgoingAvatarAudioSequenceNumber(0), _incomingMixedAudioSequenceNumberStats(INCOMING_SEQ_STATS_HISTORY_LENGTH), - _interframeTimeGapStats(TIME_GAPS_STATS_INTERVAL_SAMPLES, TIME_GAP_STATS_WINDOW_INTERVALS), _starveCount(0), - _consecutiveNotMixedCount(0) + _consecutiveNotMixedCount(0), + _interframeTimeGapStats(TIME_GAPS_STATS_INTERVAL_SAMPLES, TIME_GAP_STATS_WINDOW_INTERVALS) { // clear the array of locally injected samples memset(_localProceduralSamples, 0, NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL); From 82e9aa8bb7835a442c37a22fa0796e6fe9f78ea0 Mon Sep 17 00:00:00 2001 From: wangyix Date: Fri, 11 Jul 2014 16:08:15 -0700 Subject: [PATCH 3/6] made stats easier to read; reverted injected stream deletion conditions --- .../src/audio/AudioMixerClientData.cpp | 3 +- interface/src/ui/Stats.cpp | 40 +++++++++++-------- libraries/shared/src/SharedUtil.cpp | 14 +++++++ libraries/shared/src/SharedUtil.h | 4 ++ 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index b6e9f8883e..94bbdc6a6b 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -154,12 +154,13 @@ void AudioMixerClientData::pushBuffersAfterFrameSend() { // this was a used buffer, push the output pointer forwards PositionalAudioRingBuffer* audioBuffer = *i; - const int INJECTOR_CONSECUTIVE_NOT_MIXED_THRESHOLD = 200; + const int INJECTOR_CONSECUTIVE_NOT_MIXED_THRESHOLD = 100; if (audioBuffer->willBeAddedToMix()) { audioBuffer->shiftReadPosition(audioBuffer->getSamplesPerFrame()); audioBuffer->setWillBeAddedToMix(false); } else if (audioBuffer->getType() == PositionalAudioRingBuffer::Injector + && audioBuffer->hasStarted() && audioBuffer->isStarved() && audioBuffer->getConsecutiveNotMixedCount() > INJECTOR_CONSECUTIVE_NOT_MIXED_THRESHOLD) { // this is an empty audio buffer that has starved, safe to delete // also delete its sequence number stats diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 15a54e42a6..69e7fde209 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -346,26 +346,28 @@ void Stats::display( verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, downstreamLabelString, color); - char downstreamAudioStatsString[30]; + char downstreamAudioStatsString[512]; AudioStreamStats downstreamAudioStreamStats = audio->getDownstreamAudioStreamStats(); - sprintf(downstreamAudioStatsString, " mix: %.1f%%/%.1f%%, %u/?/%u", downstreamAudioStreamStats._packetStreamStats.getLostRate()*100.0f, + sprintf(downstreamAudioStatsString, " mix: %.2f%%/%.2f%%, %u/?/%u", downstreamAudioStreamStats._packetStreamStats.getLostRate()*100.0f, downstreamAudioStreamStats._packetStreamWindowStats.getLostRate() * 100.0f, downstreamAudioStreamStats._ringBufferFramesAvailable, downstreamAudioStreamStats._ringBufferDesiredJitterBufferFrames); verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, downstreamAudioStatsString, color); - sprintf(downstreamAudioStatsString, " %llu/%llu/%.2f, %u/%u", downstreamAudioStreamStats._timeGapMin, - downstreamAudioStreamStats._timeGapMax, downstreamAudioStreamStats._timeGapAverage, + sprintf(downstreamAudioStatsString, " %s/%s/%s, %u/%u", formatUsecTime(downstreamAudioStreamStats._timeGapMin).toLatin1().data(), + formatUsecTime(downstreamAudioStreamStats._timeGapMax).toLatin1().data(), + formatUsecTime(downstreamAudioStreamStats._timeGapAverage).toLatin1().data(), downstreamAudioStreamStats._ringBufferStarveCount, downstreamAudioStreamStats._ringBufferOverflowCount); verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, downstreamAudioStatsString, color); - sprintf(downstreamAudioStatsString, " %llu/%llu/%.2f, %u/?", downstreamAudioStreamStats._timeGapWindowMin, - downstreamAudioStreamStats._timeGapWindowMax, downstreamAudioStreamStats._timeGapWindowAverage, + sprintf(downstreamAudioStatsString, " %s/%s/%s, %u/?", formatUsecTime(downstreamAudioStreamStats._timeGapWindowMin).toLatin1().data(), + formatUsecTime(downstreamAudioStreamStats._timeGapWindowMax).toLatin1().data(), + formatUsecTime(downstreamAudioStreamStats._timeGapWindowAverage).toLatin1().data(), downstreamAudioStreamStats._ringBufferConsecutiveNotMixedCount); verticalOffset += STATS_PELS_PER_LINE; @@ -376,11 +378,11 @@ void Stats::display( verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, upstreamLabelString, color); - char upstreamAudioStatsString[30]; + char upstreamAudioStatsString[512]; const AudioStreamStats& audioMixerAvatarAudioStreamStats = audio->getAudioMixerAvatarStreamAudioStats(); - sprintf(upstreamAudioStatsString, " mic: %.1f%%/%.1f%%, %u/%u/%u", audioMixerAvatarAudioStreamStats._packetStreamStats.getLostRate()*100.0f, + sprintf(upstreamAudioStatsString, " mic: %.2f%%/%.2f%%, %u/%u/%u", audioMixerAvatarAudioStreamStats._packetStreamStats.getLostRate()*100.0f, audioMixerAvatarAudioStreamStats._packetStreamWindowStats.getLostRate() * 100.0f, audioMixerAvatarAudioStreamStats._ringBufferFramesAvailable, audioMixerAvatarAudioStreamStats._ringBufferCurrentJitterBufferFrames, audioMixerAvatarAudioStreamStats._ringBufferDesiredJitterBufferFrames); @@ -388,15 +390,17 @@ void Stats::display( verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, upstreamAudioStatsString, color); - sprintf(upstreamAudioStatsString, " %llu/%llu/%.2f, %u/%u", audioMixerAvatarAudioStreamStats._timeGapMin, - audioMixerAvatarAudioStreamStats._timeGapMax, audioMixerAvatarAudioStreamStats._timeGapAverage, + sprintf(upstreamAudioStatsString, " %s/%s/%s, %u/%u", formatUsecTime(audioMixerAvatarAudioStreamStats._timeGapMin).toLatin1().data(), + formatUsecTime(audioMixerAvatarAudioStreamStats._timeGapMax).toLatin1().data(), + formatUsecTime(audioMixerAvatarAudioStreamStats._timeGapAverage).toLatin1().data(), audioMixerAvatarAudioStreamStats._ringBufferStarveCount, audioMixerAvatarAudioStreamStats._ringBufferOverflowCount); verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, upstreamAudioStatsString, color); - sprintf(upstreamAudioStatsString, " %llu/%llu/%.2f, %u/%u", audioMixerAvatarAudioStreamStats._timeGapWindowMin, - audioMixerAvatarAudioStreamStats._timeGapWindowMax, audioMixerAvatarAudioStreamStats._timeGapWindowAverage, + sprintf(upstreamAudioStatsString, " %s/%s/%s, %u/%u", formatUsecTime(audioMixerAvatarAudioStreamStats._timeGapWindowMin).toLatin1().data(), + formatUsecTime(audioMixerAvatarAudioStreamStats._timeGapWindowMax).toLatin1().data(), + formatUsecTime(audioMixerAvatarAudioStreamStats._timeGapWindowAverage).toLatin1().data(), audioMixerAvatarAudioStreamStats._ringBufferConsecutiveNotMixedCount, audioMixerAvatarAudioStreamStats._ringBufferSilentFramesDropped); verticalOffset += STATS_PELS_PER_LINE; @@ -404,7 +408,7 @@ void Stats::display( foreach(const AudioStreamStats& injectedStreamAudioStats, audioMixerInjectedStreamAudioStatsMap) { - sprintf(upstreamAudioStatsString, " inj: %.1f%%/%.1f%%, %u/%u/%u", injectedStreamAudioStats._packetStreamStats.getLostRate()*100.0f, + sprintf(upstreamAudioStatsString, " inj: %.2f%%/%.2f%%, %u/%u/%u", injectedStreamAudioStats._packetStreamStats.getLostRate()*100.0f, injectedStreamAudioStats._packetStreamWindowStats.getLostRate() * 100.0f, injectedStreamAudioStats._ringBufferFramesAvailable, injectedStreamAudioStats._ringBufferCurrentJitterBufferFrames, injectedStreamAudioStats._ringBufferDesiredJitterBufferFrames); @@ -412,15 +416,17 @@ void Stats::display( verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, upstreamAudioStatsString, color); - sprintf(upstreamAudioStatsString, " %llu/%llu/%.2f, %u/%u", injectedStreamAudioStats._timeGapMin, - injectedStreamAudioStats._timeGapMax, injectedStreamAudioStats._timeGapAverage, + sprintf(upstreamAudioStatsString, " %s/%s/%s, %u/%u", formatUsecTime(injectedStreamAudioStats._timeGapMin).toLatin1().data(), + formatUsecTime(injectedStreamAudioStats._timeGapMax).toLatin1().data(), + formatUsecTime(injectedStreamAudioStats._timeGapAverage).toLatin1().data(), injectedStreamAudioStats._ringBufferStarveCount, injectedStreamAudioStats._ringBufferOverflowCount); verticalOffset += STATS_PELS_PER_LINE; drawText(horizontalOffset, verticalOffset, scale, rotation, font, upstreamAudioStatsString, color); - sprintf(upstreamAudioStatsString, " %llu/%llu/%.2f, %u/%u", injectedStreamAudioStats._timeGapWindowMin, - injectedStreamAudioStats._timeGapWindowMax, injectedStreamAudioStats._timeGapWindowAverage, + sprintf(upstreamAudioStatsString, " %s/%s/%s, %u/%u", formatUsecTime(injectedStreamAudioStats._timeGapWindowMin).toLatin1().data(), + formatUsecTime(injectedStreamAudioStats._timeGapWindowMax).toLatin1().data(), + formatUsecTime(injectedStreamAudioStats._timeGapWindowAverage).toLatin1().data(), injectedStreamAudioStats._ringBufferConsecutiveNotMixedCount, injectedStreamAudioStats._ringBufferSilentFramesDropped); verticalOffset += STATS_PELS_PER_LINE; diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index e4d2e1c835..23d33969f4 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -837,3 +837,17 @@ bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, f QByteArray createByteArray(const glm::vec3& vector) { return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z); } + +QString formatUsecTime(float usecs, int prec) { + QString result; + if (usecs > USECS_PER_MINUTE) { + result = QString::number(usecs / USECS_PER_MINUTE, 'f', prec) + "min"; + } else if (usecs > USECS_PER_SECOND) { + result = QString::number(usecs / USECS_PER_SECOND, 'f', prec) + 's'; + } else if (usecs > USECS_PER_MSEC) { + result = QString::number(usecs / USECS_PER_MSEC, 'f', prec) + "ms"; + } else { + result = QString::number(usecs, 'f', prec) + "us"; + } + return result; +} diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index e5c2a0afc9..81ec2ab810 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -57,7 +57,9 @@ static const float METERS_PER_MILLIMETER = 0.001f; static const float MILLIMETERS_PER_METER = 1000.0f; static const quint64 USECS_PER_MSEC = 1000; static const quint64 MSECS_PER_SECOND = 1000; +static const quint64 SECONDS_PER_MINUTE = 60; static const quint64 USECS_PER_SECOND = USECS_PER_MSEC * MSECS_PER_SECOND; +static const quint64 USECS_PER_MINUTE = USECS_PER_SECOND * SECONDS_PER_MINUTE; const int BITS_IN_BYTE = 8; @@ -189,4 +191,6 @@ bool isNaN(float value); QByteArray createByteArray(const glm::vec3& vector); +QString formatUsecTime(float usecs, int prec = 3); + #endif // hifi_SharedUtil_h From a59cef31979f09a07bd11641965a5858df2474b5 Mon Sep 17 00:00:00 2001 From: wangyix Date: Mon, 14 Jul 2014 10:05:37 -0700 Subject: [PATCH 4/6] removed debug code in AudioMixer --- assignment-client/src/audio/AudioMixer.cpp | 26 +--------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 6df23ca32f..c86d37e283 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -366,11 +366,6 @@ void AudioMixer::addBufferToMixForListeningNodeWithBuffer(PositionalAudioRingBuf } void AudioMixer::prepareMixForListeningNode(Node* node) { - - static int k = 0; - k++; - bool debug = (k % 20) == 0; - AvatarAudioRingBuffer* nodeRingBuffer = ((AudioMixerClientData*) node->getLinkedData())->getAvatarAudioRingBuffer(); // zero out the client mix for this node @@ -385,31 +380,12 @@ void AudioMixer::prepareMixForListeningNode(Node* node) { // enumerate the ARBs attached to the otherNode and add all that should be added to mix for (int i = 0; i < otherNodeClientData->getRingBuffers().size(); i++) { PositionalAudioRingBuffer* otherNodeBuffer = otherNodeClientData->getRingBuffers()[i]; - - + if ((*otherNode != *node || otherNodeBuffer->shouldLoopbackForNode()) && otherNodeBuffer->willBeAddedToMix() && otherNodeBuffer->getNextOutputTrailingLoudness() > 0.0f) { addBufferToMixForListeningNodeWithBuffer(otherNodeBuffer, nodeRingBuffer); - } else { - - if (debug) { - printf("\nWILL NOT MIX!!!\n"); - printf("listening node = %s\n", node->getUUID().toString().toLatin1().data()); - printf("other node = %s\n", otherNode->getUUID().toString().toLatin1().data()); - - if (otherNodeBuffer->getType() == PositionalAudioRingBuffer::Microphone) - printf("\t avatar buffer...\n"); - else - { - printf("\t inj buffer %s\n", ((InjectedAudioRingBuffer*)otherNodeBuffer)->getStreamIdentifier().toString().toLatin1().data()); - } - - printf("\t\t other==listening || shouldLoopBack: %d\n", (*otherNode != *node || otherNodeBuffer->shouldLoopbackForNode())); - printf("\t\t other will be added to mix: %d\n", otherNodeBuffer->willBeAddedToMix()); - printf("\t\t other trailing loudess: %f\n", otherNodeBuffer->getNextOutputTrailingLoudness()); - } } } } From cb5a9bf6688e3728ac1783422e033b82e55d463b Mon Sep 17 00:00:00 2001 From: wangyix Date: Mon, 14 Jul 2014 10:43:02 -0700 Subject: [PATCH 5/6] moved some const defs to avoid redefinition --- libraries/shared/src/SharedUtil.cpp | 3 +++ libraries/shared/src/SharedUtil.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 23d33969f4..b5be502ed5 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -839,6 +839,9 @@ QByteArray createByteArray(const glm::vec3& vector) { } QString formatUsecTime(float usecs, int prec) { + static const quint64 SECONDS_PER_MINUTE = 60; + static const quint64 USECS_PER_MINUTE = USECS_PER_SECOND * SECONDS_PER_MINUTE; + QString result; if (usecs > USECS_PER_MINUTE) { result = QString::number(usecs / USECS_PER_MINUTE, 'f', prec) + "min"; diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 81ec2ab810..6bb39f7e12 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -57,9 +57,7 @@ static const float METERS_PER_MILLIMETER = 0.001f; static const float MILLIMETERS_PER_METER = 1000.0f; static const quint64 USECS_PER_MSEC = 1000; static const quint64 MSECS_PER_SECOND = 1000; -static const quint64 SECONDS_PER_MINUTE = 60; static const quint64 USECS_PER_SECOND = USECS_PER_MSEC * MSECS_PER_SECOND; -static const quint64 USECS_PER_MINUTE = USECS_PER_SECOND * SECONDS_PER_MINUTE; const int BITS_IN_BYTE = 8; From a37e24aeb48981dd6252b5a0f0ee03ca24a5eeef Mon Sep 17 00:00:00 2001 From: wangyix Date: Mon, 14 Jul 2014 11:08:00 -0700 Subject: [PATCH 6/6] updated domain page stats to use formated usec time strings --- .../src/audio/AudioMixerClientData.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/assignment-client/src/audio/AudioMixerClientData.cpp b/assignment-client/src/audio/AudioMixerClientData.cpp index 94bbdc6a6b..6559b57959 100644 --- a/assignment-client/src/audio/AudioMixerClientData.cpp +++ b/assignment-client/src/audio/AudioMixerClientData.cpp @@ -280,12 +280,12 @@ QString AudioMixerClientData::getAudioStreamStatsString() const { + " silents_dropped: ?" + " lost%:" + QString::number(streamStats._packetStreamStats.getLostRate() * 100.0f, 'f', 2) + " lost%_30s:" + QString::number(streamStats._packetStreamWindowStats.getLostRate() * 100.0f, 'f', 2) - + " min_gap:" + QString::number(streamStats._timeGapMin) - + " max_gap:" + QString::number(streamStats._timeGapMax) - + " avg_gap:" + QString::number(streamStats._timeGapAverage, 'f', 2) - + " min_gap_30s:" + QString::number(streamStats._timeGapWindowMin) - + " max_gap_30s:" + QString::number(streamStats._timeGapWindowMax) - + " avg_gap_30s:" + QString::number(streamStats._timeGapWindowAverage, 'f', 2); + + " min_gap:" + formatUsecTime(streamStats._timeGapMin) + + " max_gap:" + formatUsecTime(streamStats._timeGapMax) + + " avg_gap:" + formatUsecTime(streamStats._timeGapAverage) + + " min_gap_30s:" + formatUsecTime(streamStats._timeGapWindowMin) + + " max_gap_30s:" + formatUsecTime(streamStats._timeGapWindowMax) + + " avg_gap_30s:" + formatUsecTime(streamStats._timeGapWindowAverage); AvatarAudioRingBuffer* avatarRingBuffer = getAvatarAudioRingBuffer(); if (avatarRingBuffer) { @@ -299,12 +299,12 @@ QString AudioMixerClientData::getAudioStreamStatsString() const { + " silents_dropped:" + QString::number(streamStats._ringBufferSilentFramesDropped) + " lost%:" + QString::number(streamStats._packetStreamStats.getLostRate() * 100.0f, 'f', 2) + " lost%_30s:" + QString::number(streamStats._packetStreamWindowStats.getLostRate() * 100.0f, 'f', 2) - + " min_gap:" + QString::number(streamStats._timeGapMin) - + " max_gap:" + QString::number(streamStats._timeGapMax) - + " avg_gap:" + QString::number(streamStats._timeGapAverage, 'f', 2) - + " min_gap_30s:" + QString::number(streamStats._timeGapWindowMin) - + " max_gap_30s:" + QString::number(streamStats._timeGapWindowMax) - + " avg_gap_30s:" + QString::number(streamStats._timeGapWindowAverage, 'f', 2); + + " min_gap:" + formatUsecTime(streamStats._timeGapMin) + + " max_gap:" + formatUsecTime(streamStats._timeGapMax) + + " avg_gap:" + formatUsecTime(streamStats._timeGapAverage) + + " min_gap_30s:" + formatUsecTime(streamStats._timeGapWindowMin) + + " max_gap_30s:" + formatUsecTime(streamStats._timeGapWindowMax) + + " avg_gap_30s:" + formatUsecTime(streamStats._timeGapWindowAverage); } else { result = "mic unknown"; } @@ -321,12 +321,12 @@ QString AudioMixerClientData::getAudioStreamStatsString() const { + " silents_dropped:" + QString::number(streamStats._ringBufferSilentFramesDropped) + " lost%:" + QString::number(streamStats._packetStreamStats.getLostRate() * 100.0f, 'f', 2) + " lost%_30s:" + QString::number(streamStats._packetStreamWindowStats.getLostRate() * 100.0f, 'f', 2) - + " min_gap:" + QString::number(streamStats._timeGapMin) - + " max_gap:" + QString::number(streamStats._timeGapMax) - + " avg_gap:" + QString::number(streamStats._timeGapAverage, 'f', 2) - + " min_gap_30s:" + QString::number(streamStats._timeGapWindowMin) - + " max_gap_30s:" + QString::number(streamStats._timeGapWindowMax) - + " avg_gap_30s:" + QString::number(streamStats._timeGapWindowAverage, 'f', 2); + + " min_gap:" + formatUsecTime(streamStats._timeGapMin) + + " max_gap:" + formatUsecTime(streamStats._timeGapMax) + + " avg_gap:" + formatUsecTime(streamStats._timeGapAverage) + + " min_gap_30s:" + formatUsecTime(streamStats._timeGapWindowMin) + + " max_gap_30s:" + formatUsecTime(streamStats._timeGapWindowMax) + + " avg_gap_30s:" + formatUsecTime(streamStats._timeGapWindowAverage); } } return result;