Commit 44b13cf5 authored by Hanspeter Portner's avatar Hanspeter Portner

add support for in/out realtime thread priorities..

parent 91304d8a
Pipeline #63384160 passed with stages
in 3 minutes and 39 seconds
......@@ -56,6 +56,16 @@ Frame rate (25)
.IP
OSC URI (osc.udp://:6666)
.HP
\fB\-I\fR PRIORITY
.IP
Input (OSC) realtime thread priority (0=disabled)
.HP
\fB\-O\fR PRIORITY
.IP
Output (DMX) realtime thread priority (0=disabled)
.SH LICENSE
Artistic License 2.0.
......
......@@ -55,6 +55,11 @@ struct _app_t {
struct ftdi_context ftdi;
struct {
int out;
int inp;
} priority;
struct {
varchunk_t *rx;
varchunk_t *tx;
......@@ -337,6 +342,26 @@ failure:
return -1;
}
static void
_thread_priority(int priority)
{
if(priority == 0)
{
return;
}
const struct sched_param schedp = {
.sched_priority = priority
};
const pthread_t self = pthread_self();
if(pthread_setschedparam(self, SCHED_FIFO, &schedp) != 0)
{
syslog(LOG_ERR, "[%s] '%s'\n", __func__, strerror(errno));
}
}
static void *
_beat(void *data)
{
......@@ -344,6 +369,8 @@ _beat(void *data)
const uint64_t step_ns = NSECS / app->fps;
_thread_priority(app->priority.out);
struct timespec to;
clock_gettime(CLOCK_MONOTONIC, &to);
......@@ -434,8 +461,11 @@ _usage(char **argv, app_t *app)
" [-D] DESCRIPTION USB product name (%s)\n"
" [-S] SERIAL USB serial ID (%s)\n"
" [-F] FPS Frame rate (%"PRIu32")\n"
" [-U] URI OSC URI (%s)\n\n"
, argv[0], app->vid, app->pid, app->des, app->sid, app->fps, app->url);
" [-U] URI OSC URI (%s)\n"
" [-I] PRIORITY Input (OSC) realtime thread priority (%i)\n"
" [-O] PRIORITY Output (DMX) realtime thread priority(%i)\n\n"
, argv[0], app->vid, app->pid, app->des, app->sid, app->fps, app->url,
app->priority.inp, app->priority.out);
}
int
......@@ -450,6 +480,9 @@ main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
app.sid = NULL;
app.fps = 30;
app.url = "osc.udp://:6666";
app.priority.inp = 0;
app.priority.out = 0;
fprintf(stderr,
"%s "OSC2FTDIDMX_VERSION"\n"
......@@ -458,7 +491,7 @@ main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
argv[0]);
int c;
while( (c = getopt(argc, argv, "vhdV:P:D:S:F:U:") ) != -1)
while( (c = getopt(argc, argv, "vhdV:P:D:S:F:U:I:O:") ) != -1)
{
switch(c)
{
......@@ -499,11 +532,20 @@ main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
{
app.url = optarg;
} break;
case 'I':
{
app.priority.inp = strtol(optarg, NULL, 10);
} break;
case 'O':
{
app.priority.out = strtol(optarg, NULL, 10);
} break;
case '?':
{
if( (optopt == 'V') || (optopt == 'P') || (optopt == 'D')
|| (optopt == 'S') || (optopt == 'F') || (optopt == 'U') )
|| (optopt == 'S') || (optopt == 'F') || (optopt == 'U')
|| (optopt == 'I') || (optopt == 'O') )
{
fprintf(stderr, "Option `-%c' requires an argument.\n", optopt);
}
......@@ -549,6 +591,8 @@ main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
return -1;
}
_thread_priority(app.priority.inp);
while(!done)
{
const LV2_OSC_Enum status = lv2_osc_stream_pollin(&app.stream, -1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment