Re: [linux-audio-user] Opening Stereo 8-bit 8-K Audio Streams

From: Adam Sampson <ats@email-addr-hidden>
Date: Mon Jan 08 2007 - 22:39:12 EET

Martin McCormick <martin@email-addr-hidden> writes:

> The audio device file descriptor is defined as
> FILE *audio_fd;
...
> Breakpoint 2, main (argc=2, argv=0xbffff684) at vx2ch.c:118
> 118 if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format)==-1)

A "FILE *" is not a file descriptor -- libc functions like fopen,
fread, fprintf etc. work with FILE *s, and system calls like open,
read and ioctl work with integer file descriptors. You can use the
fileno function to get the file descriptor that the FILE * is using,
so change "audio_fd" to "fileno(audio_fd)" in that ioctl call, and it
should be a bit happier.

The compiler should be complaining about you converting a pointer to
an integer when you compile that ioctl call as it currently stands;
it's always a good idea to use the -Wall compiler flag and pay careful
attention to the warnings it produces.

-- 
Adam Sampson <ats@email-addr-hidden>                         <http://offog.org/>
Received on Tue Jan 9 00:15:05 2007

This archive was generated by hypermail 2.1.8 : Tue Jan 09 2007 - 00:15:05 EET