mirror of
https://github.com/overte-org/overte.git
synced 2025-08-14 15:10:18 +02:00
Removed gettimeofday in Audio
This commit is contained in:
parent
d34e6ff864
commit
8cfc8faa01
2 changed files with 7 additions and 9 deletions
|
@ -616,12 +616,11 @@ void Audio::handleAudioInput() {
|
|||
void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
|
||||
const int NUM_INITIAL_PACKETS_DISCARD = 3;
|
||||
const int STANDARD_DEVIATION_SAMPLE_COUNT = 500;
|
||||
|
||||
timeval currentReceiveTime;
|
||||
gettimeofday(¤tReceiveTime, NULL);
|
||||
|
||||
_timeSinceLastRecieved.start();
|
||||
_totalPacketsReceived++;
|
||||
|
||||
double timeDiff = diffclock(&_lastReceiveTime, ¤tReceiveTime);
|
||||
|
||||
double timeDiff = (double)_timeSinceLastRecieved.nsecsElapsed() / 1000000.0; // ns to ms
|
||||
|
||||
// Discard first few received packets for computing jitter (often they pile up on start)
|
||||
if (_totalPacketsReceived > NUM_INITIAL_PACKETS_DISCARD) {
|
||||
|
@ -646,8 +645,6 @@ void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
|
|||
}
|
||||
|
||||
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AUDIO).updateValue(audioByteArray.size());
|
||||
|
||||
_lastReceiveTime = currentReceiveTime;
|
||||
}
|
||||
|
||||
bool Audio::mousePressEvent(int x, int y) {
|
||||
|
@ -995,7 +992,7 @@ bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo)
|
|||
// setup a procedural audio output device
|
||||
_proceduralAudioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
|
||||
gettimeofday(&_lastReceiveTime, NULL);
|
||||
_timeSinceLastRecieved.start();
|
||||
supportedFormat = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <QAudio>
|
||||
#include <QAudioInput>
|
||||
#include <QElapsedTimer>
|
||||
#include <QGLWidget>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVector>
|
||||
|
@ -123,7 +124,7 @@ private:
|
|||
QString _outputAudioDeviceName;
|
||||
|
||||
StDev _stdev;
|
||||
timeval _lastReceiveTime;
|
||||
QElapsedTimer _timeSinceLastRecieved;
|
||||
float _averagedLatency;
|
||||
float _measuredJitter;
|
||||
int16_t _jitterBufferSamples;
|
||||
|
|
Loading…
Reference in a new issue