/* $ gcc `pkg-config --cflags --libs glib-2.0` -lraw1394 -o \ raw1394reader_nothreads raw1394reader_nothreads.c */ #include #include static int iso_receive (raw1394handle_t handle, int channel, size_t len, quadlet_t * data) { switch (len) { case 12: g_print ("x"); break; case 492: g_print ("."); break; default: g_print (" %ld ???\n", len); break; } return 0; } static int bus_reset (raw1394handle_t handle, unsigned int generation) { g_print ("got bus reset, generation %u\n", generation); return 0; } static gpointer reader_loop (gpointer data) { raw1394handle_t handle = data; g_print ("[1] reader loop starting\n"); /* process */ while (g_random_double () > 0.001) raw1394_loop_iterate (handle); g_print ("\n[1] reader thread stopping\n"); return NULL; } int main (int argc, char *argv[]) { raw1394handle_t handle; struct raw1394_portinfo pinf[16]; int num_ports; handle = raw1394_new_handle (); if (!handle) { g_warning ("failed to open raw1394 handle"); return 1; } num_ports = raw1394_get_port_info (handle, pinf, 16); if (num_ports <= 0) { g_warning ("no ports available"); return 1; } if (raw1394_set_port (handle, 0) < 0) { g_warning ("failed to set port"); return 1; } raw1394_set_iso_handler (handle, 63, iso_receive); raw1394_set_bus_reset_handler (handle, bus_reset); if (raw1394_start_iso_rcv (handle, 63) < 0) { g_warning ("failed to start isochronous transfer"); return 1; } reader_loop (handle); g_print ("[0] stopping iso_rcv\n"); raw1394_stop_iso_rcv (handle, 63); raw1394_destroy_handle (handle); g_print ("[0] success\n"); return 0; }