mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +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();
|
||||
|
||||
// show the next audio buffer and end of last write position
|
||||
int scaleLength = currentX - startX;
|
||||
|
||||
float nextOutputSampleOffset = data->ringBuffer->nextOutput - data->ringBuffer->buffer;
|
||||
|
||||
// show the next audio buffer and end of last write position
|
||||
float remainingBuffer = 0;
|
||||
timeval currentTime;
|
||||
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)/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);
|
||||
glBegin(GL_QUADS);
|
||||
|
|
|
@ -23,13 +23,17 @@ AudioRingBuffer::~AudioRingBuffer() {
|
|||
|
||||
short AudioRingBuffer::diffLastWriteNextOutput()
|
||||
{
|
||||
short sampleDifference = endOfLastWrite - nextOutput;
|
||||
|
||||
if (sampleDifference < 0) {
|
||||
sampleDifference += ringBufferLengthSamples;
|
||||
if (endOfLastWrite == NULL) {
|
||||
return 0;
|
||||
} else {
|
||||
short sampleDifference = endOfLastWrite - nextOutput;
|
||||
|
||||
if (sampleDifference < 0) {
|
||||
sampleDifference += ringBufferLengthSamples;
|
||||
}
|
||||
|
||||
return sampleDifference;
|
||||
}
|
||||
|
||||
return sampleDifference;
|
||||
}
|
||||
|
||||
short AudioRingBuffer::bufferOverlap(int16_t *pointer, short addedDistance)
|
||||
|
|
Loading…
Reference in a new issue