mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 07:43:57 +02:00
some initial audio stat render fixes
This commit is contained in:
parent
90ea978278
commit
bb93c64d8d
5 changed files with 12 additions and 18 deletions
|
@ -71,7 +71,7 @@ const int IDLE_SIMULATE_MSECS = 16; // How often should call simul
|
|||
// in the idle loop? (60 FPS is default)
|
||||
static QTimer* idleTimer = NULL;
|
||||
|
||||
const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2;
|
||||
const int STARTUP_JITTER_SAMPLES = NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL / 2;
|
||||
// Startup optimistically with small jitter buffer that
|
||||
// will start playback on the second received audio packet.
|
||||
|
||||
|
|
|
@ -451,6 +451,7 @@ void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
|
|||
_desiredOutputFormat, _outputFormat);
|
||||
|
||||
if (_outputDevice) {
|
||||
|
||||
_outputDevice->write(outputBuffer);
|
||||
|
||||
// add output (@speakers) data just written to the scope
|
||||
|
@ -500,7 +501,7 @@ void Audio::render(int screenWidth, int screenHeight) {
|
|||
glVertex2f(currentX, topY);
|
||||
glVertex2f(currentX, bottomY);
|
||||
|
||||
for (int i = 0; i < _ringBuffer.getSampleCapacity() / 2; i++) {
|
||||
for (int i = 0; i < RING_BUFFER_LENGTH_FRAMES; i++) {
|
||||
glVertex2f(currentX, halfY);
|
||||
glVertex2f(currentX + frameWidth, halfY);
|
||||
currentX += frameWidth;
|
||||
|
@ -512,14 +513,12 @@ void Audio::render(int screenWidth, int screenHeight) {
|
|||
|
||||
// Show a bar with the amount of audio remaining in ring buffer beyond current playback
|
||||
float remainingBuffer = 0;
|
||||
timeval currentTime;
|
||||
gettimeofday(¤tTime, NULL);
|
||||
float timeLeftInCurrentBuffer = 0;
|
||||
if (_lastCallbackTime.tv_usec > 0) {
|
||||
timeLeftInCurrentBuffer = AUDIO_CALLBACK_MSECS - diffclock(&_lastCallbackTime, ¤tTime);
|
||||
}
|
||||
|
||||
remainingBuffer = PACKET_LENGTH_SAMPLES / PACKET_LENGTH_SAMPLES * AUDIO_CALLBACK_MSECS;
|
||||
int bytesLeftInAudioOutput = _audioOutput->bufferSize() - _audioOutput->bytesFree();
|
||||
float secondsLeftForAudioOutput = (bytesLeftInAudioOutput / sizeof(int16_t)) / _outputFormat.sampleRate();
|
||||
float timeLeftInCurrentBuffer = AUDIO_CALLBACK_MSECS - (secondsLeftForAudioOutput * 1000);
|
||||
|
||||
remainingBuffer = 1 / AUDIO_CALLBACK_MSECS;
|
||||
|
||||
if (_numFramesDisplayStarve == 0) {
|
||||
glColor3f(0, 1, 0);
|
||||
|
@ -557,7 +556,8 @@ void Audio::render(int screenWidth, int screenHeight) {
|
|||
// Show a red bar with the 'start' point of one frame plus the jitter buffer
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
int jitterBufferPels = (1.f + (float)getJitterBufferSamples() / (float) PACKET_LENGTH_SAMPLES_PER_CHANNEL) * frameWidth;
|
||||
int jitterBufferPels = (1.f + (float)getJitterBufferSamples()
|
||||
/ (float) NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL) * frameWidth;
|
||||
sprintf(out, "%.0f\n", getJitterBufferSamples() / SAMPLE_RATE * 1000.f);
|
||||
drawtext(startX + jitterBufferPels - 5, topY - 9, 0.10, 0, 1, 0, out, 1, 0, 0);
|
||||
sprintf(out, "j %.1f\n", _measuredJitter);
|
||||
|
|
|
@ -26,11 +26,6 @@
|
|||
|
||||
static const int NUM_AUDIO_CHANNELS = 2;
|
||||
|
||||
static const int PACKET_LENGTH_BYTES = 1024;
|
||||
static const int PACKET_LENGTH_BYTES_PER_CHANNEL = PACKET_LENGTH_BYTES / 2;
|
||||
static const int PACKET_LENGTH_SAMPLES = PACKET_LENGTH_BYTES / sizeof(int16_t);
|
||||
static const int PACKET_LENGTH_SAMPLES_PER_CHANNEL = PACKET_LENGTH_SAMPLES / 2;
|
||||
|
||||
class QAudioInput;
|
||||
class QAudioOutput;
|
||||
class QIODevice;
|
||||
|
@ -86,7 +81,6 @@ private:
|
|||
AudioRingBuffer _ringBuffer;
|
||||
Oscilloscope* _scope;
|
||||
StDev _stdev;
|
||||
timeval _lastCallbackTime;
|
||||
timeval _lastReceiveTime;
|
||||
float _averagedLatency;
|
||||
float _measuredJitter;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
|
||||
#include "AudioRingBuffer.h"
|
||||
|
||||
const short RING_BUFFER_LENGTH_FRAMES = 10;
|
||||
|
||||
AudioRingBuffer::AudioRingBuffer(int numFrameSamples) :
|
||||
NodeData(NULL),
|
||||
_sampleCapacity(numFrameSamples * RING_BUFFER_LENGTH_FRAMES),
|
||||
|
|
|
@ -25,6 +25,8 @@ const int NETWORK_BUFFER_LENGTH_SAMPLES_STEREO = NETWORK_BUFFER_LENGTH_BYTES_STE
|
|||
const int NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL = 512;
|
||||
const int NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL = NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL / sizeof(int16_t);
|
||||
|
||||
const short RING_BUFFER_LENGTH_FRAMES = 10;
|
||||
|
||||
const int MAX_SAMPLE_VALUE = std::numeric_limits<int16_t>::max();
|
||||
const int MIN_SAMPLE_VALUE = std::numeric_limits<int16_t>::min();
|
||||
|
||||
|
|
Loading…
Reference in a new issue