1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-27 02:20:05 +00:00

Added method AudioFormatWriter::ThreadedWriter::setFlushInterval()

This commit is contained in:
jules 2014-07-06 12:00:20 +01:00
parent 48cdbf2622
commit a0fd7bbc1c
2 changed files with 31 additions and 1 deletions

View file

@ -199,6 +199,8 @@ public:
writer (w),
receiver (nullptr),
samplesWritten (0),
samplesPerFlush (0),
flushSampleCounter (0),
isRunning (true)
{
timeSliceThread.addTimeSliceClient (this);
@ -271,6 +273,18 @@ public:
}
fifo.finishedRead (size1 + size2);
if (samplesPerFlush > 0)
{
flushSampleCounter -= numToDo;
if (flushSampleCounter <= 0)
{
flushSampleCounter = samplesPerFlush;
writer->flush();
}
}
return 0;
}
@ -284,6 +298,11 @@ public:
samplesWritten = 0;
}
void setFlushInterval (int numSamples) noexcept
{
samplesPerFlush = numSamples;
}
private:
AbstractFifo fifo;
AudioSampleBuffer buffer;
@ -292,6 +311,7 @@ private:
CriticalSection thumbnailLock;
IncomingDataReceiver* receiver;
int64 samplesWritten;
int samplesPerFlush, flushSampleCounter;
volatile bool isRunning;
JUCE_DECLARE_NON_COPYABLE (Buffer)
@ -315,3 +335,8 @@ void AudioFormatWriter::ThreadedWriter::setDataReceiver (AudioFormatWriter::Thre
{
buffer->setDataReceiver (receiver);
}
void AudioFormatWriter::ThreadedWriter::setFlushInterval (int numSamplesPerFlush) noexcept
{
buffer->setFlushInterval (numSamplesPerFlush);
}

View file

@ -207,7 +207,12 @@ public:
The object passed-in must not be deleted while this writer is still using it.
*/
void setDataReceiver (IncomingDataReceiver* receiver);
void setDataReceiver (IncomingDataReceiver*);
/** Sets how many samples should be written before calling the AudioFormatWriter::flush method.
Set this to 0 to disable flushing (this is the default).
*/
void setFlushInterval (int numSamplesPerFlush) noexcept;
private:
class Buffer;