40 lines
956 B
C++
40 lines
956 B
C++
#include <VulcanoLE/Audio/VisAudioRunner.h>
|
|
#include <VUtils/Logging.h>
|
|
|
|
VisAudioRunner::VisAudioRunner(AudioGrabber *ag, VIZ::VisPlugins *vp) : grabber(ag), plugins(vp) {
|
|
i2c.readDevices();
|
|
}
|
|
|
|
VisAudioRunner::~VisAudioRunner() {
|
|
delete plugins;
|
|
delete grabber;
|
|
}
|
|
|
|
VisAudioRunner *VisAudioRunner::create() {
|
|
return new VisAudioRunner(AudioGrabber::createAudioGrabber(), new VIZ::VisPlugins());
|
|
}
|
|
|
|
|
|
void VisAudioRunner::init() {
|
|
grabber->env = env;
|
|
plugins->env = env;
|
|
grabber->init();
|
|
plugins->onStartup();
|
|
LOG("Create Visual Audio Runner Thread")
|
|
thread = std::thread(&VisAudioRunner::run, this);
|
|
}
|
|
|
|
void VisAudioRunner::run() const {
|
|
usleep(5000);
|
|
while (isActive) {
|
|
if (grabber->work()) {
|
|
plugins->onTick();
|
|
} else {
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
}
|
|
}
|
|
usleep(50000);
|
|
DBG("SHUTDOWN HOOk")
|
|
plugins->onShutdown();
|
|
}
|