Add loop method to all input and outputs

Adds a virtual loop() method to the file input and audio output objects.
By default does nothing, but it can be used to prefill buffers/etc. in the
case of a buffered input, or to update a volume meter on an output, etc.

The AudioGenerators all now call it as part of their own loop()s, so there
is no user intervention required to make it work.

Thanks to @armSeb for the idea with his SPI RAM code.
This commit is contained in:
Earle F. Philhower, III committed 2017-11-24 10:35:20 -08:00
1 parent df4588197f
commit fece88a9be
10 files changed
+72 -23

No files matched your search

+6 -2
View File
@@ -89,13 +89,13 @@ bool AudioGeneratorAAC::FillBufferWithValidFrame()
bool AudioGeneratorAAC::loop()
{
if (!running) return true; // Nothing to do here!
if (!running) goto done; // Nothing to do here!
// If we've got data, try and pump it out...
while (validSamples) {
lastSample[0] = outSample[curSample*2];
lastSample[1] = outSample[curSample*2 + 1];
if (!output->ConsumeSample(lastSample)) return true; // Can't send, but no error detected
if (!output->ConsumeSample(lastSample)) goto done; // Can't send, but no error detected
validSamples--;
curSample++;
}
@@ -128,6 +128,10 @@ bool AudioGeneratorAAC::loop()
running = false; // No more data, we're done here...
}
done:
file->loop();
output->loop();
return running;
}