#include <unistd.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdlib>
#include <lvtk/plugin.hpp>
#include "workhorse.h"
using std::vector;
class Workhorse;
class Workhorse : public PluginType
{
public:
Workhorse (double rate)
: PluginType (p_n_ports),
m_sleeping (false),
log_Entry (map (LV2_LOG__Entry)),
log_Trace (map (LV2_LOG__Trace)),
bufsize (0)
{ }
void
activate()
{
std::stringstream ss;
ss << "Workhorse Buffer Information:\n";
ss << "\tBuffer Bounded: " << info.bounded << std::endl
<< "\tBuffer Fixed: " << info.fixed << std::endl
<< "\tBuffer Pow of 2: " << info.power_of_two << std::endl
<< "\tBuffer Min: " << info.min << std::endl
<< "\tBuffer Max: " << info.max << std::endl
<< "\tSequence Size: " << info.sequence_size << std::endl;
printf (log_Entry, ss.str().c_str());
}
void
run(uint32_t nframes)
{
static const char* msg = "go to sleep";
if (! m_sleeping)
{
WorkerStatus status (schedule_work (strlen(msg) + 1, (
void*)msg));
switch (status)
{
printf (log_Trace, "[workhorse] scheduled a job\n");
m_sleeping = true;
break;
default:
printf (log_Trace, "[workhorse] unknown scheduling error\n");
break;
}
}
}
work_response (uint32_t size, const void* body)
{
printf (log_Trace, "[workhorse] woke up. message: %s\n", (char*)body);
m_sleeping = false;
}
{
printf (log_Entry, "[workhorse] taking a nap now\n");
sleep (10);
respond (size, data);
}
uint32_t
{
}
uint32_t
{
}
private:
bool m_sleeping;
LV2_URID log_Entry;
LV2_URID log_Trace;
uint32_t bufsize;
};
static int _ = Workhorse::register_class (p_uri);