Dan Muresan wrote:
I'm trying to cancel an ongoing sf_* I/O operation
(from another
thread of course). I'm finding this extremely unpleasant to implement.
Maybe its a bad idea. :-)
* 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)
Yep, sounds like a bad idea.
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).
Reading one frame at a time sounds like a bad idea too.
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.
It does. You can read any number of frames from 1 through to as many
frames as the file contains.
Basically you could define how fine grained you want you interruption
to be and then only read enough frames so that you can interrupt between
reads.
Say you want to be able to interrupt down to a 1/100th of a second and
your sample rate is 48000kHz. If you read 480 frames in each read and
get your interruption without jumping through difficult hoops.
BTW, I've had trouble sending messages to the
sndfile-users mailing
list (I subscribed, then it still rejected my mails).
I just checked, and the address you used to post this email to the LAU
list are not subscribed to the libsndfile-users list. Thats why the list
is rejecting your email.
In any case,
since there seems to be no mailing list archive, it doesn't seem like
a very trustworthy mailing list.
It works if you are suscribed, but I'm just as happy answering
libsndfile questions here (or better yet, the LAD list since this
is really a development question).
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/