static void mainloop (void) { struct timeval timeout; vbi_capture_buffer *sliced_buffer; unsigned int n_frames; /* Don't wait more than two seconds for the driver to return data. */ timeout.tv_sec = 2; timeout.tv_usec = 0; /* Should receive a CNI within two seconds, call sign within ten seconds(?). */ if (services & VBI_SLICED_CAPTION_525) n_frames = 11 * 30; else n_frames = 3 * 25; for (; n_frames > 0; --n_frames) { unsigned int n_lines; int r; r = vbi_capture_pull (cap, /* raw_buffer */ NULL, &sliced_buffer, &timeout); switch (r) { case -1: fprintf (stderr, "VBI read error %d (%s)\n", errno, strerror (errno)); /* Could be ignored, esp. EIO with some drivers. */ exit (EXIT_FAILURE); case 0: fprintf (stderr, "VBI read timeout\n"); exit (EXIT_FAILURE); case 1: /* success */ break; default: assert (0); } n_lines = sliced_buffer->size / sizeof (vbi_sliced); vbi_decode (dec, (vbi_sliced *) sliced_buffer->data, n_lines, sliced_buffer->timestamp); if (quit) return; } printf ("No network ID received or network unknown.\n"); }
static void mainloop (void) { struct timeval timeout; /* Don't wait more than two seconds for the driver to return data. */ timeout.tv_sec = 2; timeout.tv_usec = 0; for (;;) { vbi_capture_buffer *sliced_buffer; unsigned int n_lines; int r; r = vbi_capture_pull (cap, /* raw_buffer */ NULL, &sliced_buffer, &timeout); switch (r) { case -1: fprintf (stderr, "VBI read error %d (%s)\n", errno, strerror (errno)); /* Could be ignored, esp. EIO with some drivers. */ exit (EXIT_FAILURE); case 0: fprintf (stderr, "VBI read timeout\n"); exit (EXIT_FAILURE); case 1: /* success */ break; default: assert (0); } n_lines = sliced_buffer->size / sizeof (vbi_sliced); vbi_decode (dec, (vbi_sliced *) sliced_buffer->data, n_lines, sliced_buffer->timestamp); } }