mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 20:55:10 +02:00
only keep the threshold number of frames on mixer as well
This commit is contained in:
parent
4be337d34b
commit
14e3160d50
1 changed files with 16 additions and 0 deletions
|
@ -81,6 +81,22 @@ void *sendBuffer(void *args)
|
||||||
printf("Buffer %d starved.\n", i);
|
printf("Buffer %d starved.\n", i);
|
||||||
agentBuffer->setStarted(false);
|
agentBuffer->setStarted(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// check if we have more than we need to play out
|
||||||
|
int thresholdFrames = ceilf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL + JITTER_BUFFER_SAMPLES) / (float)BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||||
|
int thresholdSamples = thresholdFrames * BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
|
||||||
|
|
||||||
|
if (agentBuffer->diffLastWriteNextOutput() > thresholdSamples) {
|
||||||
|
// we need to push the next output forwards
|
||||||
|
int samplesToPush = agentBuffer->diffLastWriteNextOutput() - thresholdSamples;
|
||||||
|
|
||||||
|
if (agentBuffer->getNextOutput() + samplesToPush > agentBuffer->getBuffer()) {
|
||||||
|
agentBuffer->setNextOutput(agentBuffer->getBuffer() + (samplesToPush - (agentBuffer->getBuffer() + RING_BUFFER_SAMPLES - agentBuffer->getNextOutput())));
|
||||||
|
} else {
|
||||||
|
agentBuffer->setNextOutput(agentBuffer->getNextOutput() + samplesToPush);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// good buffer, add this to the mix
|
// good buffer, add this to the mix
|
||||||
agentBuffer->setStarted(true);
|
agentBuffer->setStarted(true);
|
||||||
agentBuffer->setAddedToMix(true);
|
agentBuffer->setAddedToMix(true);
|
||||||
|
|
Loading…
Reference in a new issue