mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:36:47 +02:00
make diffLastWriteNextOutput check for NULL endOfLastWrite
This commit is contained in:
parent
abdf15a811
commit
8b4fa7c009
2 changed files with 12 additions and 14 deletions
|
@ -418,20 +418,14 @@ void Audio::render(int screenWidth, int screenHeight)
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
// show the next audio buffer and end of last write position
|
// show the next audio buffer and end of last write position
|
||||||
int scaleLength = currentX - startX;
|
|
||||||
|
|
||||||
float nextOutputSampleOffset = data->ringBuffer->nextOutput - data->ringBuffer->buffer;
|
|
||||||
|
|
||||||
float remainingBuffer = 0;
|
float remainingBuffer = 0;
|
||||||
timeval currentTime;
|
timeval currentTime;
|
||||||
gettimeofday(¤tTime, NULL);
|
gettimeofday(¤tTime, NULL);
|
||||||
float timeLeftInCurrentBuffer = diffclock(currentTime, data->lastCallback)/(1000.0*(float)BUFFER_LENGTH_SAMPLES/(float)SAMPLE_RATE) * frameWidth;
|
float timeLeftInCurrentBuffer = diffclock(currentTime, data->lastCallback)/(1000.0*(float)BUFFER_LENGTH_SAMPLES/(float)SAMPLE_RATE) * frameWidth;
|
||||||
//float timeLeftInCurrentBuffer = diffclock(currentTime, data->lastCallback)/23.22 * frameWidth;
|
//float timeLeftInCurrentBuffer = diffclock(currentTime, data->lastCallback)/23.22 * frameWidth;
|
||||||
|
|
||||||
if (data->ringBuffer->endOfLastWrite != NULL) {
|
remainingBuffer = data->ringBuffer->diffLastWriteNextOutput() / BUFFER_LENGTH_SAMPLES * frameWidth;
|
||||||
remainingBuffer = (data->ringBuffer->diffLastWriteNextOutput())/BUFFER_LENGTH_SAMPLES*frameWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
|
@ -23,13 +23,17 @@ AudioRingBuffer::~AudioRingBuffer() {
|
||||||
|
|
||||||
short AudioRingBuffer::diffLastWriteNextOutput()
|
short AudioRingBuffer::diffLastWriteNextOutput()
|
||||||
{
|
{
|
||||||
short sampleDifference = endOfLastWrite - nextOutput;
|
if (endOfLastWrite == NULL) {
|
||||||
|
return 0;
|
||||||
if (sampleDifference < 0) {
|
} else {
|
||||||
sampleDifference += ringBufferLengthSamples;
|
short sampleDifference = endOfLastWrite - nextOutput;
|
||||||
|
|
||||||
|
if (sampleDifference < 0) {
|
||||||
|
sampleDifference += ringBufferLengthSamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sampleDifference;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sampleDifference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
short AudioRingBuffer::bufferOverlap(int16_t *pointer, short addedDistance)
|
short AudioRingBuffer::bufferOverlap(int16_t *pointer, short addedDistance)
|
||||||
|
|
Loading…
Reference in a new issue