- time_last = g_timer_elapsed(mydata->timer, NULL);
-
- while (thread_running) {
- /* Rate control */
- time_cur = g_timer_elapsed(mydata->timer, NULL);
-
- time_diff = time_cur - time_last;
- time_last = time_cur;
-
- nb_to_send = cur_samplerate * time_diff;
-
- if (limit_samples)
- nb_to_send = MIN(nb_to_send,
- limit_samples - mydata->samples_counter);
-
- /* Make sure we don't overflow. */
- nb_to_send = MIN(nb_to_send, BUFSIZE);
-
- if (nb_to_send) {
- samples_generator(buf, nb_to_send, data);
- mydata->samples_counter += nb_to_send;
-
- g_io_channel_write_chars(channels[1], (gchar *)&buf,
- nb_to_send, (gsize *)&bytes_written, NULL);
- }