Subject: Re: man audio - howto ioctl()
To: Sascha Retzki <sascha.retzki@t-online.de>
From: Ben Collver <collver1@comcast.net>
List: current-users
Date: 04/14/2004 07:49:41
Hi Sascha,

For an example, look at my native NetBSD audio driver for csound, in the
NetBSD_open() function.  The answer to your first question is that the
third argument is passed by reference, as a pointer to a structure.


http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/audio/csound-bath/files/rtNetBSD.c?rev=1.2&content-type=text/x-cvsweb-markup


static int dspfd_in = -1, dspfd_out = -1;
...
void NetBSD_open(int nchanls, int dsize, float sr, int scale, int audio_mode)
{
...
audio_device_t device_info;
...
if (dspfd_out = open(NETBSD_SAMPLER, O_WRONLY)) == -1) {
...
}
...
ioctl(dspfd_in, AUDIO_GETDEV, &device_info);
fprintf(stderr, "NetBSD input audio info: %s, %s, %s\n",
	device_info.name,
	device_info.version,
	device_info.config);


Cheers,

Ben

On Wed, Apr 14, 2004 at 04:27:17PM +0200, Sascha Retzki wrote:
> Hi,
> 
> can somebody look at the audio(4) manpage and tell me how I ioctl()
> that:
> 
> AUDIO_GETDEV (audio_device_t)
>      This command fetches the current hardware device information into
>      the audio_device_t argument.
> 
>              typedef struct audio_device {
>                      char name[MAX_AUDIO_DEV_LEN];
>                      char version[MAX_AUDIO_DEV_LEN];
>                      char config[MAX_AUDIO_DEV_LEN];
>              } audio_device_t;
> 
> because the ioctl() prototype: 
> int ioctl(int fd, unsigned long expr,void *argp);
> Does not allow ( in my opinion ) to write into a structure. How do I
> make it ? I though about a more pratical implementation of the line:
> AUDIO_GETDEV (audio_device_t)
> and made:
> ioctl(fd,AUDIO_GETDEV (audio_device_t),0);
> which results in any other try I make:
> parse error before "struct"
> As I need these things ( this and some others structs ) to get the
> card even working, it would be cool if someone could point me into the
> right direction.
> 
> 
> With kind regards
> 
> 
> Sascha Retzki
> 
>