mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-12 19:55:13 +02:00
Merge remote-tracking branch 'origin'
This commit is contained in:
commit
e3697f22f8
2 changed files with 16 additions and 1 deletions
|
@ -194,6 +194,21 @@ int audioCallback (const void *inputBuffer,
|
||||||
}
|
}
|
||||||
// play whatever we have in the audio buffer
|
// play whatever we have in the audio buffer
|
||||||
|
|
||||||
|
// check if we have more than we need to play out
|
||||||
|
int thresholdFrames = ceilf((PACKET_LENGTH_SAMPLES + JITTER_BUFFER_SAMPLES) / (float)PACKET_LENGTH_SAMPLES);
|
||||||
|
int thresholdSamples = thresholdFrames * PACKET_LENGTH_SAMPLES;
|
||||||
|
|
||||||
|
if (ringBuffer->diffLastWriteNextOutput() > thresholdSamples) {
|
||||||
|
// we need to push the next output forwards
|
||||||
|
int samplesToPush = ringBuffer->diffLastWriteNextOutput() - thresholdSamples;
|
||||||
|
|
||||||
|
if (ringBuffer->getNextOutput() + samplesToPush > ringBuffer->getBuffer()) {
|
||||||
|
ringBuffer->setNextOutput(ringBuffer->getBuffer() + (samplesToPush - (ringBuffer->getBuffer() + RING_BUFFER_SAMPLES - ringBuffer->getNextOutput())));
|
||||||
|
} else {
|
||||||
|
ringBuffer->setNextOutput(ringBuffer->getNextOutput() + samplesToPush);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(outputLeft, ringBuffer->getNextOutput(), PACKET_LENGTH_BYTES_PER_CHANNEL);
|
memcpy(outputLeft, ringBuffer->getNextOutput(), PACKET_LENGTH_BYTES_PER_CHANNEL);
|
||||||
memcpy(outputRight, ringBuffer->getNextOutput() + PACKET_LENGTH_SAMPLES_PER_CHANNEL, PACKET_LENGTH_BYTES_PER_CHANNEL);
|
memcpy(outputRight, ringBuffer->getNextOutput() + PACKET_LENGTH_SAMPLES_PER_CHANNEL, PACKET_LENGTH_BYTES_PER_CHANNEL);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ void *sendBuffer(void *args)
|
||||||
while (true) {
|
while (true) {
|
||||||
sentBytes = 0;
|
sentBytes = 0;
|
||||||
|
|
||||||
printf("Last send was %f us ago", usecTimestampNow() - usecTimestamp(&lastSend));
|
printf("Last send was %f ms ago\n", (usecTimestampNow() - usecTimestamp(&lastSend)) / 1000);
|
||||||
gettimeofday(&lastSend, NULL);
|
gettimeofday(&lastSend, NULL);
|
||||||
|
|
||||||
for (int i = 0; i < agentList.getAgents().size(); i++) {
|
for (int i = 0; i < agentList.getAgents().size(); i++) {
|
||||||
|
|
Loading…
Reference in a new issue