2023-01-15 17:01:27 +00:00
|
|
|
#include "FrameProducer.h"
|
|
|
|
|
2023-03-30 16:28:47 +00:00
|
|
|
FrameProducer::FrameProducer(FrameConsumer& fc, std::shared_ptr<FrameSource> fs) : frameConsumer(fc), frameSource(fs), juce::Thread("producer", 0) {}
|
2023-01-15 17:01:27 +00:00
|
|
|
|
|
|
|
FrameProducer::~FrameProducer() {
|
2023-03-30 16:28:47 +00:00
|
|
|
frameSource->disable();
|
2023-01-15 17:01:27 +00:00
|
|
|
stopThread(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameProducer::run() {
|
2023-03-30 16:28:47 +00:00
|
|
|
while (!threadShouldExit() && frameSource->isActive()) {
|
2023-03-30 20:09:53 +00:00
|
|
|
frameConsumer.addFrame(frameSource->next(), sourceFileIndex);
|
2023-01-15 17:01:27 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-30 16:28:47 +00:00
|
|
|
|
2023-03-30 20:09:53 +00:00
|
|
|
void FrameProducer::setSource(std::shared_ptr<FrameSource> source, int fileIndex) {
|
2023-03-30 16:28:47 +00:00
|
|
|
// TODO: should make this atomic
|
|
|
|
frameSource = source;
|
2023-03-30 20:09:53 +00:00
|
|
|
sourceFileIndex = fileIndex;
|
2023-03-30 16:28:47 +00:00
|
|
|
}
|