Hi, oh gurus,

I'm venturing into a realm of Unix programming that I had
previously been able to avoid: asynchronous event processing,
with or without threads.

Can anyone suggest why the following test-case program always

$ ./test-case 
test-case: can't set O_ASYNC on device: Invalid argument


For reference to details, my system is 4-STABLE about a week
old, and the device in question is a Midiman1010 sound card with
the 4Front (OSS) driver.  (FreeBSD's native pcm device doesn't
support this card.)

What I'm trying to achieve is the Unix equivalent of a DSP-style
IO interrupt for audio processing.  I want the main body of the
code to be able to go on and do UI things without sitting and
waiting at the inevitable read(....,fd), but I also want processing
of the input data to proceed immediately that data is available,
irrespective of what the UI code is doing (so just O_NONBLOCK
isn't what I'm after).  The code doesn't work if the O_ASYNC
argument to fcntl is O_NONBLOCK|O_ASYNC either.  Any clues?

Thanks for any suggestions.

/* standard OSS includes */
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/soundcard.h>

#include <err.h>
#include <signal.h>

#define BUF_SIZE 4096
int fd;
unsigned char buf[BUF_SIZE];

got_data(int sig)
    /* foo: do something with buf[] */
    if (-1 == read(fd, buf, BUF_SIZE))  /* initiate next read */
        err(1, "can't read from device");

main(int argc, char **argv)
    signal(SIGIO, got_data);
    fd=open("/dev/dsp6", O_RDONLY);
    if (-1 == fd) err(1, "can't open device");
    if (-1 == fcntl(fd, F_SETFL, O_ASYNC))
        err(1, "can't set O_ASYNC on device");
    if (-1 == read(fd, buf, BUF_SIZE))  /* initiate next read */
        err(1, "can't read from device");

    for (;;) { /* UI */ }

    return 0;

[EMAIL PROTECTED] mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to