void agentLogout() { struct _agentInfo *info = &agentInfo; if (info->influence_device_name) { mapper_monitor_unlink(info->mon, info->influence_device_name, mdev_name(info->dev)); free(info->influence_device_name); } if (info->xagora_device_name) { mapper_monitor_unlink(info->mon, mdev_name(info->dev), info->xagora_device_name); free(info->xagora_device_name); } if (info->dev) mdev_free(info->dev); if (info->db) { mapper_db_remove_device_callback(info->db, dev_db_callback, info); mapper_db_remove_link_callback(info->db, link_db_callback, info); } if (info->mon) mapper_monitor_free(info->mon); if (info->admin) { mapper_admin_free(info->admin); } memset(info, 0, sizeof(struct _agentInfo)); }
int main() { signal(SIGINT, ctrlc); mapper_device dev = mdev_new("pwm", 9000, 0); float min0 = 0; float max1 = 1; float max1000 = 1000; mdev_add_input(dev, "/freq", 1, 'f', "Hz", &min0, &max1000, (mapper_signal_handler*)handler_freq, 0); mdev_add_input(dev, "/gain", 1, 'f', "Hz", &min0, &max1, (mapper_signal_handler*)handler_gain, 0); mdev_add_input(dev, "/duty", 1, 'f', "Hz", &min0, &max1, (mapper_signal_handler*)handler_duty, 0); run_synth(); set_duty(0.1); set_freq(110.0); set_gain(0.1); printf("Press Ctrl-C to quit.\n"); while (!done) mdev_poll(dev, 10); mdev_free(dev); set_freq(0); sleep(1); stop_synth(); }
void cleanup_destination() { if (destination) { printf("Freeing destination.. "); fflush(stdout); mdev_free(destination); printf("ok\n"); } }
void cleanup_source() { if (source) { printf("Freeing source.. "); fflush(stdout); mdev_free(source); printf("ok\n"); } }
void cleanup_devices() { int i; for (i=0; i<5; i++) { if (devices[i]) { printf("Freeing device %i... ", i); fflush(stdout); mdev_free(devices[i]); printf("ok\n"); } } }
void cleanup_source() { if (source) { if (source->routers) { printf("Removing router.. "); fflush(stdout); mdev_remove_router(source, source->routers); printf("ok\n"); } printf("Freeing source.. "); fflush(stdout); mdev_free(source); printf("ok\n"); } }
void cleanup_sources() { mapper_device source; for ( int i=0; i<num_sources; i++ ) { source = source_device_list[i]; if (source) { if (source->routers) { printf("Removing router.. "); fflush(stdout); mdev_remove_router(source, source->routers); printf("ok\n"); } printf("Freeing source.. "); fflush(stdout); mdev_free(source); printf("ok\n"); } } }
void cleanup_destinations() { mapper_device dest; for ( int i=0; i<num_dests; i++ ) { dest = dest_device_list[i]; if ( dest ) { if ( dest->routers ) { printf("Removing router.. "); fflush(stdout); mdev_remove_router(dest, dest->routers); printf("ok\n"); } printf("Freeing dests.. "); fflush(stdout); mdev_free( dest ); printf("ok\n"); } } }
int test_recv() { mapper_device md = mdev_new("synth", 0, 0); if (!md) goto error; printf("Mapper device created.\n"); float mn=0, mx=1; mapper_signal sig = mdev_add_input(md, "/mapped1", 1, 'f', 0, &mn, &mx, handler, 0); printf("Input signal /mapped1 registered.\n"); printf("Number of inputs: %d\n", mdev_num_inputs(md)); printf("Waiting for port/ordinal allocation..\n"); int i; for (i = 0; i < 10; i++) { mdev_poll(md, 500); if (mdev_ready(md)) break; usleep(500 * 1000); } if (i >= 10) { printf("Timed out waiting for signal name.\n"); goto error; } char port[10]; sprintf(port, "%i", md->admin->port); printf("using port = %s\n", port); lo_address a = lo_address_new("localhost", port); if (!a) { printf("Error creating lo_address for test.\n"); return 1; } printf("Polling device..\n"); for (i = 0; i < 10; i++) { lo_send(a, sig->props.name, "f", (float) i); printf("Updating signal %s to %f\n", sig->props.name, (float) i); sent++; mdev_poll(md, 500); //usleep(500 * 1000); } if (sent != received) { printf("Not all sent values were received.\n"); printf("Sent %d values, but %d received.\n", sent, received); goto error; } if (sent == 0) { printf("Unable to send any values.\n"); goto error; } printf("Sent and received %d values.\n", sent); mdev_free(md); lo_address_free(a); return 0; error: if (md) mdev_free(md); lo_address_free(a); return 1; }