Beispiel #1
0
/* catch any osc incoming messages. */
int
OscToShmdata::osc_handler(const char *path,
                          const char */*types*/,
                          lo_arg **/*argv*/,
                          int /*argc*/,
                          lo_message m,
                          void *user_data) {
  OscToShmdata *context = static_cast<OscToShmdata *>(user_data);
  lo_timetag timetag = lo_message_get_timestamp(m);
  // g_print ("timestamp %u %u", path, timetag.sec, timetag.frac);
  if (0 != timetag.sec) {
    // FIXME handle internal timetag
    // note: this is not implemented in osc-send
  }
  size_t size;
  void *buftmp = lo_message_serialise(m, path, nullptr, &size);
  if (context->shm_->writer(&shmdata::Writer::alloc_size) < size) {
    context->shm_.reset(nullptr);
    context->shm_.reset(new ShmdataWriter(context,
                                          context->make_file_name("osc"),
                                          size,
                                          "application/x-libloserialized-osc"));
  }
  context->shm_->writer(&shmdata::Writer::copy_to_shm, buftmp, size);
  context->shm_->bytes_written(size);
  g_free(buftmp);
  return 0;
}
Beispiel #2
0
int timestamp_handler(const char *path, const char *types, lo_arg **argv, 
		      int argc, lo_message data, void *user_data)
{
    int bundled = argv[0]->i;

    lo_timetag ts, arg_ts;
    ts = lo_message_get_timestamp(data);
    arg_ts = argv[1]->t;

    if (bundled) {
      TEST((ts.sec == arg_ts.sec) && (ts.frac == arg_ts.frac));
    }
    else {
      TEST(ts.sec == LO_TT_IMMEDIATE.sec && ts.frac == LO_TT_IMMEDIATE.frac);
    }
    return 0;
}
Beispiel #3
0
/* TODO: Bundle messages together that happen in the same call to poll(). */
void text_write_generic(const char *path,
                        const char *types,
                        lo_message m)
{
    lo_timetag now;
    lo_timetag_now(&now);

    lo_timetag tt = lo_message_get_timestamp(m);

    if (memcmp(&tt, &LO_TT_IMMEDIATE, sizeof(lo_timetag))==0)
        fprintf(output_file, "%u %u %s %s ",
                now.sec, now.frac, path, types);
    else
        fprintf(output_file, "%u %u %s %s ",
                tt.sec, tt.frac, path, types);

    lo_arg **a = lo_message_get_argv(m);
    const char *t;
    int i=0;
    for (t=types; *t; t++, i++)
    {
        if (*t == 'i')
            fprintf(output_file, " %d", a[i]->i);
        else if (*t == 'f')
            fprintf(output_file, " %g", a[i]->f);
        else if (*t == 's')
            fprintf(output_file, " %s", &a[i]->s);
    }

    fprintf(output_file, "\n");
    fflush(output_file);

    if (now.sec > last_write.sec) {
        printf(".");
        fflush(stdout);
        last_write = now;
    }
}
Beispiel #4
0
lo_timetag* Pure_lo_message_get_timestamp(void* arg0)
{
  static lo_timetag ret;
  ret = lo_message_get_timestamp(arg0); return &ret;
}