fix audio graphs for new audio infrastructure

This commit is contained in:
Stephen Birarda 2013-12-16 16:52:04 -08:00
parent 30b22a13ad
commit efe05adcae

View file

@ -509,14 +509,15 @@ void Audio::render(int screenWidth, int screenHeight) {
} }
glEnd(); glEnd();
// Show a bar with the amount of audio remaining in ring buffer beyond current playback // show a bar with the amount of audio remaining in ring buffer and output device
float remainingBuffer = 0; // beyond the current playback
int bytesLeftInAudioOutput = _audioOutput->bufferSize() - _audioOutput->bytesFree(); int bytesLeftInAudioOutput = _audioOutput->bufferSize() - _audioOutput->bytesFree();
float secondsLeftForAudioOutput = (bytesLeftInAudioOutput / sizeof(int16_t)) / _outputFormat.sampleRate(); float secondsLeftForAudioOutput = (bytesLeftInAudioOutput / sizeof(int16_t))
float timeLeftInCurrentBuffer = AUDIO_CALLBACK_MSECS - (secondsLeftForAudioOutput * 1000); / ((float) _outputFormat.sampleRate() * _outputFormat.channelCount());
float secondsLeftForRingBuffer = _ringBuffer.samplesAvailable()
remainingBuffer = 1 / AUDIO_CALLBACK_MSECS; / ((float) _desiredOutputFormat.sampleRate() * _desiredOutputFormat.channelCount());
float msLeftForAudioOutput = (secondsLeftForAudioOutput + secondsLeftForRingBuffer) * 1000;
if (_numFramesDisplayStarve == 0) { if (_numFramesDisplayStarve == 0) {
glColor3f(0, 1, 0); glColor3f(0, 1, 0);
@ -525,19 +526,19 @@ void Audio::render(int screenWidth, int screenHeight) {
_numFramesDisplayStarve--; _numFramesDisplayStarve--;
} }
if (_averagedLatency == 0.0) {
_averagedLatency = msLeftForAudioOutput;
} else {
_averagedLatency = 0.99f * _averagedLatency + 0.01f * (msLeftForAudioOutput);
}
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex2f(startX, topY + 2); glVertex2f(startX, topY + 2);
glVertex2f(startX + (remainingBuffer + timeLeftInCurrentBuffer) / AUDIO_CALLBACK_MSECS * frameWidth, topY + 2); glVertex2f(startX + _averagedLatency / AUDIO_CALLBACK_MSECS * frameWidth, topY + 2);
glVertex2f(startX + (remainingBuffer + timeLeftInCurrentBuffer) / AUDIO_CALLBACK_MSECS * frameWidth, bottomY - 2); glVertex2f(startX + _averagedLatency / AUDIO_CALLBACK_MSECS * frameWidth, bottomY - 2);
glVertex2f(startX, bottomY - 2); glVertex2f(startX, bottomY - 2);
glEnd(); glEnd();
if (_averagedLatency == 0.0) {
_averagedLatency = remainingBuffer + timeLeftInCurrentBuffer;
} else {
_averagedLatency = 0.99f * _averagedLatency + 0.01f * (remainingBuffer + timeLeftInCurrentBuffer);
}
// Show a yellow bar with the averaged msecs latency you are hearing (from time of packet receipt) // Show a yellow bar with the averaged msecs latency you are hearing (from time of packet receipt)
glColor3f(1,1,0); glColor3f(1,1,0);
glBegin(GL_QUADS); glBegin(GL_QUADS);