mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 14:04:23 +02:00
fixed some typos in audio stats; cleaned up code
This commit is contained in:
parent
bd8b7eb710
commit
06ed8e4b63
2 changed files with 31 additions and 29 deletions
|
@ -132,10 +132,10 @@ Audio::Audio(int16_t initialJitterBufferSamples, QObject* parent) :
|
||||||
_outgoingAvatarAudioSequenceNumber(0),
|
_outgoingAvatarAudioSequenceNumber(0),
|
||||||
_incomingMixedAudioSequenceNumberStats(INCOMING_SEQ_STATS_HISTORY_LENGTH),
|
_incomingMixedAudioSequenceNumberStats(INCOMING_SEQ_STATS_HISTORY_LENGTH),
|
||||||
_interframeTimeGapStats(TIME_GAPS_STATS_INTERVAL_SAMPLES, TIME_GAP_STATS_WINDOW_INTERVALS),
|
_interframeTimeGapStats(TIME_GAPS_STATS_INTERVAL_SAMPLES, TIME_GAP_STATS_WINDOW_INTERVALS),
|
||||||
_audioInputBufferMsecsDataAvailableStats(MSECS_PER_SECOND / (float)AUDIO_CALLBACK_MSECS * CALLBACK_ACCELERATOR_RATIO, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
_audioInputMsecsReadStats(MSECS_PER_SECOND / (float)AUDIO_CALLBACK_MSECS * CALLBACK_ACCELERATOR_RATIO, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
||||||
_inputRingBufferMsecsDataAvailableStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
_inputRingBufferMsecsAvailableStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
||||||
_outputRingBufferFramesAvailableStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
_outputRingBufferFramesAvailableStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
||||||
_audioOutputBufferFramesAvailableStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS)
|
_audioOutputMsecsUnplayedStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS)
|
||||||
{
|
{
|
||||||
// clear the array of locally injected samples
|
// clear the array of locally injected samples
|
||||||
memset(_localProceduralSamples, 0, NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL);
|
memset(_localProceduralSamples, 0, NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL);
|
||||||
|
@ -168,11 +168,11 @@ void Audio::resetStats() {
|
||||||
|
|
||||||
_interframeTimeGapStats.reset();
|
_interframeTimeGapStats.reset();
|
||||||
|
|
||||||
_audioInputBufferMsecsDataAvailableStats.reset();
|
_audioInputMsecsReadStats.reset();
|
||||||
_inputRingBufferMsecsDataAvailableStats.reset();
|
_inputRingBufferMsecsAvailableStats.reset();
|
||||||
|
|
||||||
_outputRingBufferFramesAvailableStats.reset();
|
_outputRingBufferFramesAvailableStats.reset();
|
||||||
_audioOutputBufferFramesAvailableStats.reset();
|
_audioOutputMsecsUnplayedStats.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::audioMixerKilled() {
|
void Audio::audioMixerKilled() {
|
||||||
|
@ -522,7 +522,7 @@ void Audio::handleAudioInput() {
|
||||||
_inputRingBuffer.writeData(inputByteArray.data(), inputByteArray.size());
|
_inputRingBuffer.writeData(inputByteArray.data(), inputByteArray.size());
|
||||||
|
|
||||||
float audioInputMsecsRead = inputByteArray.size() / (float)(_inputFormat.channelCount() * _inputFormat.sampleRate() * sizeof(int16_t)) * MSECS_PER_SECOND;
|
float audioInputMsecsRead = inputByteArray.size() / (float)(_inputFormat.channelCount() * _inputFormat.sampleRate() * sizeof(int16_t)) * MSECS_PER_SECOND;
|
||||||
_audioInputBufferMsecsDataAvailableStats.update(audioInputMsecsRead);
|
_audioInputMsecsReadStats.update(audioInputMsecsRead);
|
||||||
|
|
||||||
while (_inputRingBuffer.samplesAvailable() >= inputSamplesRequired) {
|
while (_inputRingBuffer.samplesAvailable() >= inputSamplesRequired) {
|
||||||
|
|
||||||
|
@ -837,10 +837,10 @@ void Audio::sendDownstreamAudioStatsPacket() {
|
||||||
|
|
||||||
// since this function is called every second, we'll sample some of our stats here
|
// since this function is called every second, we'll sample some of our stats here
|
||||||
|
|
||||||
_inputRingBufferMsecsDataAvailableStats.update(getInputRingBufferMsecsDataAvailable());
|
_inputRingBufferMsecsAvailableStats.update(getInputRingBufferMsecsAvailable());
|
||||||
|
|
||||||
_outputRingBufferFramesAvailableStats.update(_ringBuffer.framesAvailable());
|
_outputRingBufferFramesAvailableStats.update(_ringBuffer.framesAvailable());
|
||||||
_audioOutputBufferFramesAvailableStats.update(getOutputRingBufferFramesAvailable());
|
_audioOutputMsecsUnplayedStats.update(getAudioOutputMsecsUnplayed());
|
||||||
|
|
||||||
// push the current seq number stats into history, which moves the history window forward 1s
|
// push the current seq number stats into history, which moves the history window forward 1s
|
||||||
// (since that's how often pushStatsToHistory() is called)
|
// (since that's how often pushStatsToHistory() is called)
|
||||||
|
@ -1431,12 +1431,12 @@ void Audio::renderStats(const float* color, int width, int height) {
|
||||||
|
|
||||||
SharedNodePointer audioMixerNodePointer = NodeList::getInstance()->soloNodeOfType(NodeType::AudioMixer);
|
SharedNodePointer audioMixerNodePointer = NodeList::getInstance()->soloNodeOfType(NodeType::AudioMixer);
|
||||||
if (!audioMixerNodePointer.isNull()) {
|
if (!audioMixerNodePointer.isNull()) {
|
||||||
audioInputBufferLatency = _audioInputBufferMsecsDataAvailableStats.getWindowAverage();
|
audioInputBufferLatency = _audioInputMsecsReadStats.getWindowAverage();
|
||||||
inputRingBufferLatency = getInputRingBufferAverageMsecsDataAvailable();
|
inputRingBufferLatency = getInputRingBufferAverageMsecsAvailable();
|
||||||
networkRoundtripLatency = audioMixerNodePointer->getPingMs();
|
networkRoundtripLatency = audioMixerNodePointer->getPingMs();
|
||||||
mixerRingBufferLatency = _audioMixerAvatarStreamAudioStats._ringBufferFramesAvailableAverage * BUFFER_SEND_INTERVAL_MSECS;
|
mixerRingBufferLatency = _audioMixerAvatarStreamAudioStats._ringBufferFramesAvailableAverage * BUFFER_SEND_INTERVAL_MSECS;
|
||||||
outputRingBufferLatency = _outputRingBufferFramesAvailableStats.getWindowAverage() * BUFFER_SEND_INTERVAL_MSECS;
|
outputRingBufferLatency = _outputRingBufferFramesAvailableStats.getWindowAverage() * BUFFER_SEND_INTERVAL_MSECS;
|
||||||
audioOutputBufferLatency = _audioOutputBufferFramesAvailableStats.getWindowAverage() * BUFFER_SEND_INTERVAL_MSECS;
|
audioOutputBufferLatency = _audioOutputMsecsUnplayedStats.getWindowAverage();
|
||||||
}
|
}
|
||||||
float totalLatency = audioInputBufferLatency + inputRingBufferLatency + networkRoundtripLatency + mixerRingBufferLatency + outputRingBufferLatency + audioOutputBufferLatency;
|
float totalLatency = audioInputBufferLatency + inputRingBufferLatency + networkRoundtripLatency + mixerRingBufferLatency + outputRingBufferLatency + audioOutputBufferLatency;
|
||||||
|
|
||||||
|
@ -1520,12 +1520,14 @@ void Audio::renderAudioStreamStats(const AudioStreamStats& streamStats, int hori
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, stringBuffer, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, stringBuffer, color);
|
||||||
|
|
||||||
if (isDownstreamStats) {
|
if (isDownstreamStats) {
|
||||||
|
|
||||||
|
const float BUFFER_SEND_INTERVAL_MSECS = BUFFER_SEND_INTERVAL_USECS / (float)USECS_PER_MSEC;
|
||||||
sprintf(stringBuffer, " Ringbuffer frames | desired: %u, avg_available(10s): %u+%d, available: %u+%d",
|
sprintf(stringBuffer, " Ringbuffer frames | desired: %u, avg_available(10s): %u+%d, available: %u+%d",
|
||||||
streamStats._ringBufferDesiredJitterBufferFrames,
|
streamStats._ringBufferDesiredJitterBufferFrames,
|
||||||
streamStats._ringBufferFramesAvailableAverage,
|
streamStats._ringBufferFramesAvailableAverage,
|
||||||
getOutputRingBufferAverageFramesAvailable(),
|
(int)(getAudioOutputAverageMsecsUnplayed() / BUFFER_SEND_INTERVAL_MSECS),
|
||||||
streamStats._ringBufferFramesAvailable,
|
streamStats._ringBufferFramesAvailable,
|
||||||
getOutputRingBufferFramesAvailable());
|
(int)(getAudioOutputMsecsUnplayed() / BUFFER_SEND_INTERVAL_MSECS));
|
||||||
} else {
|
} else {
|
||||||
sprintf(stringBuffer, " Ringbuffer frames | desired: %u, avg_available(10s): %u, available: %u",
|
sprintf(stringBuffer, " Ringbuffer frames | desired: %u, avg_available(10s): %u, available: %u",
|
||||||
streamStats._ringBufferDesiredJitterBufferFrames,
|
streamStats._ringBufferDesiredJitterBufferFrames,
|
||||||
|
@ -1817,14 +1819,14 @@ int Audio::calculateNumberOfFrameSamples(int numBytes) const {
|
||||||
return frameSamples;
|
return frameSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Audio::getOutputRingBufferFramesAvailable() const {
|
float Audio::getAudioOutputMsecsUnplayed() const {
|
||||||
float networkOutputToOutputRatio = (_desiredOutputFormat.sampleRate() / (float)_outputFormat.sampleRate())
|
int bytesAudioOutputUnplayed = _audioOutput->bufferSize() - _audioOutput->bytesFree();
|
||||||
* (_desiredOutputFormat.channelCount() / (float)_outputFormat.channelCount());
|
float msecsAudioOutputUnplayed = bytesAudioOutputUnplayed / (float)_outputFormat.bytesForDuration(USECS_PER_MSEC);
|
||||||
|
return msecsAudioOutputUnplayed;
|
||||||
return (_audioOutput->bufferSize() - _audioOutput->bytesFree()) * networkOutputToOutputRatio
|
|
||||||
/ (sizeof(int16_t) * _ringBuffer.getNumFrameSamples());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Audio::getInputRingBufferMsecsDataAvailable() const {
|
float Audio::getInputRingBufferMsecsAvailable() const {
|
||||||
return _inputRingBuffer.samplesAvailable() / (float)(_inputFormat.channelCount() * _inputFormat.sampleRate()) * MSECS_PER_SECOND;
|
int bytesInInputRingBuffer = _inputRingBuffer.samplesAvailable() * sizeof(int16_t);
|
||||||
|
float msecsInInputRingBuffer = bytesInInputRingBuffer / (float)(_inputFormat.bytesForDuration(USECS_PER_MSEC));
|
||||||
|
return msecsInInputRingBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,11 +80,11 @@ public:
|
||||||
|
|
||||||
const SequenceNumberStats& getIncomingMixedAudioSequenceNumberStats() const { return _incomingMixedAudioSequenceNumberStats; }
|
const SequenceNumberStats& getIncomingMixedAudioSequenceNumberStats() const { return _incomingMixedAudioSequenceNumberStats; }
|
||||||
|
|
||||||
float getInputRingBufferMsecsDataAvailable() const;
|
float getInputRingBufferMsecsAvailable() const;
|
||||||
float getInputRingBufferAverageMsecsDataAvailable() const { return (float)_inputRingBufferMsecsDataAvailableStats.getWindowAverage(); }
|
float getInputRingBufferAverageMsecsAvailable() const { return (float)_inputRingBufferMsecsAvailableStats.getWindowAverage(); }
|
||||||
|
|
||||||
int getOutputRingBufferFramesAvailable() const;
|
float getAudioOutputMsecsUnplayed() const;
|
||||||
int getOutputRingBufferAverageFramesAvailable() const { return (int)_audioOutputBufferFramesAvailableStats.getWindowAverage(); }
|
float getAudioOutputAverageMsecsUnplayed() const { return (float)_audioOutputMsecsUnplayedStats.getWindowAverage(); }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
|
@ -287,11 +287,11 @@ private:
|
||||||
|
|
||||||
MovingMinMaxAvg<quint64> _interframeTimeGapStats;
|
MovingMinMaxAvg<quint64> _interframeTimeGapStats;
|
||||||
|
|
||||||
MovingMinMaxAvg<float> _audioInputBufferMsecsDataAvailableStats;
|
MovingMinMaxAvg<float> _audioInputMsecsReadStats;
|
||||||
MovingMinMaxAvg<float> _inputRingBufferMsecsDataAvailableStats;
|
MovingMinMaxAvg<float> _inputRingBufferMsecsAvailableStats;
|
||||||
|
|
||||||
MovingMinMaxAvg<int> _outputRingBufferFramesAvailableStats;
|
MovingMinMaxAvg<int> _outputRingBufferFramesAvailableStats;
|
||||||
MovingMinMaxAvg<int> _audioOutputBufferFramesAvailableStats;
|
MovingMinMaxAvg<float> _audioOutputMsecsUnplayedStats;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue