Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jan 1998 13:35:39 +0100 (MET)
From:      Luigi Rizzo <luigi@labinfo.iet.unipi.it>
To:        hackers@FreeBSD.ORG
Subject:   read audio from atapi cd: success!
Message-ID:  <199801031235.NAA16694@labinfo.iet.unipi.it>

next in thread | raw e-mail | index | archive | help
Well, I managed to put together some code to read audio data from
ATAPI CDs :)

The code is very primitive and inefficient (e.g. it uses ioctl()
and cannot currently read more than one block at a time, meaning
it is far slower than real time at least on my 2x drive) but it is
there as a hint to somebody with more knowledge than I have to make
it work well.

I DO NOT recommend to commit the as it is now, but I do hope that
some committer with sufficient knowledge has the time to work on
it and improve it according to the suggestion which follow.  Diffs
(more or less against 2.2.1R) are at

	ttp://www.iet.unipi.it/~luigi/cdda.diffs

They include changes to 3 files: atapi.c, wcd.c and cdio.h, and a
simple program to test the ioctl and read audio data.  The patch
also includes a more verbose attach to reveal the capabilities of
the drive, and an attempt to make the initial MODE_SENSE not timeout.
However the latter seems to be very unreliable on my drive (Sony
CDU-55E), which often returns a CHECK code.

BRIEF DESCRIPTION OF THE CODE

My initial goal was to support reading audio data through the read()
interface. However, I was having some trouble and unexpected
behaviours in replacing the READ_BIG with READ_CD command (maybe
due to interactions with other commands), so I decided to go along
another way and introduce a new ioctl() to be able to play with
the parameters in the atapi command.

The way I have implemented it, the ioctl issues a wcd_request_wait for
ATAPI_READ_CD, copying each block into a kernel buffer and from there
into user space using copyout.

This is highly inefficient since you cannot read more than 1
sector/revolution. It ought to be made more efficient by using
a larger block of storage and allowing for more than one sector at a
time. I am not sure of how much work is necessary to make the ioctl()
copy directly into the user-supplied buffer, it is probably necessary
to lock the buffer in memory and map it into the kernel space around
the transfer -- more or less what is done in function physio() in file
/sys/kern/kern_physio.c.

There might be more efficient ways, and I'd hate duplicating lot of
code which is already there...

	Cheers
	Luigi
-----------------------------+--------------------------------------
Luigi Rizzo                  |  Dip. di Ingegneria dell'Informazione
email: luigi@iet.unipi.it    |  Universita' di Pisa
tel: +39-50-568533           |  via Diotisalvi 2, 56126 PISA (Italy)
fax: +39-50-568522           |  http://www.iet.unipi.it/~luigi/
_____________________________|______________________________________



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801031235.NAA16694>