[LAU] cancelling I/O with libsndfile

Dan Muresan danmbox at gmail.com
Mon Jun 13 11:43:40 UTC 2011


Hi,

I'm trying to cancel an ongoing sf_* I/O operation (from another
thread of course). I'm finding this extremely unpleasant to implement.

* libsndfile sf_read_* and sf_write_* loop until the requested number
of frames has been transferred -- so signals are useless, even if I
were to disable SA_RESTART behavior

* a pthread_cancel() in the middle of I/O seems to mess up the
SNDFILE's data structure to the point that it is unusable later on; so
besides having to create a new thread after cancelling, I have to
re-open the SNDFILE (or manage a pool of back-up SNDFILE's, complete
with duplicate fd's)

Also, libsndfile doesn't seem to employ a user-space cache like normal
C streams (FILE *) -- instead it goes directly to read(2) and
write(2). This of course makes it exceedingly inefficient to read 1
frame at a time (due to repetead syscall overhead).

So... it's hard to process low-latency dynamic I/O requests with
libsndfile. It would be nice if libsndfile could allow short reads and
writes via some sf_command parameter.

BTW, I've had trouble sending messages to the sndfile-users mailing
list (I subscribed, then it still rejected my mails). In any case,
since there seems to be no mailing list archive, it doesn't seem like
a very trustworthy mailing list.


-- Dan


More information about the Linux-audio-user mailing list