2
Purpose: This program has been used to verify that the select() call works
3
* Copyright (C) 4Front Technologies, 2002-2004. Released under GPLv2/CDDL.
6
* This program opens an audio device and then just
7
* copies input to output. Select is used for flow control.
13
#include <sys/types.h>
15
#include <soundcard.h>
17
#include <sys/select.h>
21
main (int agrc, char *argv[])
32
int frag = 0x00200008; /* 32 fragments of 2^8=256 bytes */
38
if ((fd = open ("/dev/dsp", O_RDWR, 0)) == -1)
40
perror ("/dev/dsp open");
44
ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &frag);
47
* Set just the sampling tahe. Use the default format. We do not do any
48
* error checking (maybe not so good idea) because we don't care what
49
* the sampling rate really is.
52
ioctl (fd, SNDCTL_DSP_SPEED, &tmp);
68
if (select (fd + 1, &reads, &writes, NULL, &time) == -1)
74
if (FD_ISSET (fd, &reads))
76
struct audio_buf_info info;
78
if (ioctl (fd, SNDCTL_DSP_GETISPACE, &info) == -1)
86
l = read (fd, buf, n);
91
if (FD_ISSET (fd, &writes))
95
struct audio_buf_info info;
97
if (ioctl (fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
105
printf ("Write %d\n", l);