static void * read_thread(void *dp) { sndio_in_driver *d = dp; struct pollfd pfd; int size, ret, off, nfds; if (!sio_start(d->hdl)) { error_error("could not start sndio"); goto done; } while (d->read_trun) { nfds = sio_pollfd(d->hdl, &pfd, POLLIN); poll(&pfd, nfds, -1); if (sio_revents(d->hdl, &pfd) & POLLIN) { size = d->par.rchan * d->par.bps * d->bufsize; off = 0; while (size > 0) { ret = sio_read(d->hdl, d->sndbuf + off, size); off += ret; size -= ret; } sample_editor_sampled(d->sndbuf, d->bufsize, d->par.rate, d->mf); } } done: pthread_exit(NULL); return NULL; }
static void alsa_poll_ready_sampling (gpointer data, gint source, GdkInputCondition condition) { alsa_driver * const d = data; int size; size = (d->stereo + 1) * (d->bits / 8) * d->fragsize; size = snd_pcm_read(d->soundfd, d->sndbuf, size); sample_editor_sampled(d->sndbuf, d->fragsize, d->playrate, d->mf); }