Add Mixer::loop() to allow just sending I2S data

Allow users to call the ::loop() method to pump out any possible data
to the I2S interface, without requiring any Stubs to pump the queue.
This commit is contained in:
Earle F. Philhower, III committed 2018-02-26 13:11:23 -08:00
1 parent e9aec0449d
commit db411fadbf
2 files changed
+10 -3

No files matched your search

+8 -2
View File
@@ -177,7 +177,7 @@ void AudioOutputMixer::RemoveInput(int id)
stubRunning[id] = false;
}
bool AudioOutputMixer::ConsumeSample(int16_t sample[2], int id)
bool AudioOutputMixer::loop()
{
// First, try and fill I2S...
// This is not optimal, but algorithmically should work fine
@@ -216,7 +216,13 @@ bool AudioOutputMixer::ConsumeSample(int16_t sample[2], int id)
readPtr = (readPtr + 1) % buffSize;
}
} while (avail);
return true;
}
bool AudioOutputMixer::ConsumeSample(int16_t sample[2], int id)
{
loop(); // Send any pre-existing, completed I2S data we can fit
// Now, do we have space for a new sample?
int nextWritePtr = (writePtr[id] + 1) % buffSize;
if (nextWritePtr == readPtr) {