|
Question about reading directly from a CDROM device file:
I am trying to read a track (on a multi-track CD, like a Photo CD (as
opposed to multi-session, since that is yet a different problem)) into a
raw data file.
I have successfully (apparently) used the CDROM_TOC_HEADER and
CDROM_TOC_ENTRYS ioctl calls to read in the TOC, and having parsed the TOC
data, the track directory looks consistent with the track listing from the
same CD given by a WinNT-based CD-Write software package. I am calculating
the lseek target for the track(s) from the LBA data, and I start a read loop.
The problem occurs when I hit the end of the track, trying to read the last
frame. The read hangs, apparently out of control of my program, and
eventually returns an EIO in errno. This can take a couple of minutes.
O_NONBLOCK and O_NDELAY have no effect. It hangs *before* I get a chance to
examine the n_chars returned by read().
Is there a way to:
1) know when to stop reading - the start lba is in the TOC, but the length
of the track apparently isn't. Is it calculated from the start of the
subsequent track? This issue isn't really the first problem, since I am
hanging *during* the last frame, not after, although I understand that
read() will return an error if you attempt to read the space between
tracks.
2) gain control of the read() call during this time when it is hung - what
is going on here? Is it that the driver is just trying very hard before
giving up?
I hope I am not posting a redundant note here. I looked thru the conference,
and 1569.1 was the closet thing I found.
|