Example #1
0
static
int lo_send_from_varargs_internal(lo_address to, lo_server from,
                  const char *file,
                  const int line, lo_timetag ts,
                  const char *path, const char *types,
                  va_list ap)
{
    lo_bundle b = NULL;
    int ret;

    lo_message msg = lo_message_new();
    if (ts.sec != LO_TT_IMMEDIATE.sec || ts.frac != LO_TT_IMMEDIATE.frac)
        b = lo_bundle_new(ts);

    // Clear any previous errors
    to->errnum = 0;
    to->errstr = NULL;

    ret = lo_message_add_varargs_internal(msg, types, ap, file, line);

    if (ret == 0) {
        if (b) {
            lo_bundle_add_message(b, path, msg);
            ret = lo_send_bundle_from(to, from, b);
        } else {
            ret = lo_send_message_from(to, from, path, msg);
        }
    }
    // Free-up memory
    lo_message_free(msg);
    if (b)
        lo_bundle_free(b);

    return ret;
}
Example #2
0
int lo_send_from(lo_address to, lo_server from, lo_timetag ts,
				 const char *path, const char *types, ...)
#endif
{
    lo_bundle b = NULL;
    va_list ap;
    int ret;
    
#ifndef __GNUC__
    const char *file = "";
    int line = 0;
#endif

    lo_message msg = lo_message_new();
    if (ts.sec!=LO_TT_IMMEDIATE.sec || ts.frac!=LO_TT_IMMEDIATE.frac)
        b = lo_bundle_new(ts);

    // Clear any previous errors
    to->errnum = 0;
    to->errstr = NULL;

    va_start(ap, types);
    ret = lo_message_add_varargs_internal(msg, types, ap, file, line);

    if (to->errnum) {
	if (b) lo_bundle_free(b);
	lo_message_free(msg);
	return to->errnum;
    }

    if (b) {
	lo_bundle_add_message(b, path, msg);
	ret = lo_send_bundle_from(to, from, b);
    } else {
	ret = lo_send_message_from(to, from, path, msg);
    }
    
    // Free-up memory
    lo_message_free(msg);
    if (b) lo_bundle_free(b);

    return ret;
}
Example #3
0
int info_handler(const char *path, const char *types, lo_arg **argv, int argc,
		 void *data, void *user_data)
{
//      printf("info message\n");
//      fflush(stdout);

  lo_bundle b = lo_bundle_new( LO_TT_IMMEDIATE );

      int num_joysticks = SDL_NumJoysticks();
//       printf("Found %d joystick(s)\n\n", num_joysticks);
	lo_message m1 = lo_message_new();
	lo_message_add_int32( m1, num_joysticks );
	lo_bundle_add_message( b, "/joystick/number", m1 );
	int joy_idx;
        for(joy_idx = 0; joy_idx < num_joysticks; ++joy_idx)
        {
          SDL_Joystick* joy = SDL_JoystickOpen(joy_idx);
          if (!joy)
          {
            fprintf(stderr, "Unable to open joystick %d\n", joy_idx);
          }
          else
          {
	    lo_message m2 = get_joystick_info_msg( joy_idx, joy );
	    lo_bundle_add_message( b, "/joystick/info", m2 );
//             print_joystick_info(joy_idx, joy);
            SDL_JoystickClose(joy);
          }
//         }
      }

 	if ( lo_send_bundle_from( t, s, b )  == -1 ){
 		{ printf("sd2osc/info: OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); }
 	}
 	lo_bundle_free( b );
	fflush(stdout);

    return 0;
}
Example #4
0
void mapper_receiver_send_release_request(mapper_receiver rc,
                                          mapper_signal sig,
                                          mapper_signal_instance si,
                                          mapper_timetag_t tt)
{
    mapper_receiver_signal rs = rc->signals;
    mapper_connection c;

    if (!mapper_receiver_in_scope(rc, si->id_map->group))
        return;

    while (rs) {
        if (rs->signal == sig)
            break;
        rs = rs->next;
    }
    if (!rs)
        return;

    //lo_bundle b = lo_bundle_new(tt);
    lo_bundle b = lo_bundle_new(LO_TT_IMMEDIATE);

    c = rs->connections;
    while (c) {
        lo_message m = lo_message_new();
        if (!m)
            return;
        lo_message_add_int32(m, si->id_map->group);
        lo_message_add_int32(m, si->id_map->remote);
        lo_message_add_false(m);
        lo_bundle_add_message(b, c->props.src_name, m);
        c = c->next;
    }

    if (lo_bundle_count(b))
        lo_send_bundle_from(rc->props.src_addr, rc->device->server, b);

    lo_bundle_free_messages(b);
}
Example #5
0
// note on memory handling of mapper_router_bundle_message():
// path: not owned, will not be freed (assumed is signal name, owned by signal)
// message: will be owned, will be freed when done
void send_or_bundle_message(mapper_link link, const char *path, lo_message msg,
                            mapper_timetag_t tt)
{
    mapper_local_link llink = link->local;
    // Check if a matching bundle exists
    mapper_queue q = llink->queues;
    while (q) {
        if (memcmp(&q->tt, &tt,
                   sizeof(mapper_timetag_t))==0)
            break;
        q = q->next;
    }
    if (q) {
        // Add message to existing bundle
        lo_bundle_add_message(q->bundle, path, msg);
    }
    else {
        // Send message immediately
        lo_bundle b = lo_bundle_new(tt);
        lo_bundle_add_message(b, path, msg);
        lo_send_bundle_from(llink->data_addr, link->local_device->local->server, b);
        lo_bundle_free_messages(b);
    }
}
Example #6
0
int lo_send_bundle(lo_address a, lo_bundle b)
{
    return lo_send_bundle_from(a, NULL, b);
}
Example #7
0
void NonBlockOSCServer::sendBundle(lo_address targ, lo_bundle bundle)
{
  lo_send_bundle_from( targ, server, bundle );
}