aboutsummaryrefslogtreecommitdiff
path: root/doc/examples/SoundRecorder/src/soundcard.c
diff options
context:
space:
mode:
Diffstat (limited to 'doc/examples/SoundRecorder/src/soundcard.c')
-rw-r--r--doc/examples/SoundRecorder/src/soundcard.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/doc/examples/SoundRecorder/src/soundcard.c b/doc/examples/SoundRecorder/src/soundcard.c
new file mode 100644
index 00000000..14b581b2
--- /dev/null
+++ b/doc/examples/SoundRecorder/src/soundcard.c
@@ -0,0 +1,49 @@
1/* by Luis Figueiredo (stdio@netc.pt)
2 *
3 * file: soundcard.c
4 *
5 * description: handlers soundcard setup
6 *
7 * date: 17:00,13-00-2002
8 */
9
10#include "soundcard.h"
11
12
13
14
15
16
17int soundcard_init(const char *dev, struct soundcard_setup *ss) {
18 int ret;
19 int soundfd;
20 soundfd=open(dev,O_RDWR|O_NONBLOCK);
21 if(soundfd <1) {
22 perror("open");
23 return -1;
24 }
25 IFDEBUG(fprintf(stderr,"soundcard.c: Setting soundcard:\n"));
26 IFDEBUG(fprintf(stderr,"soundcard.c: rate: %d\n",ss->rate));
27 ret=ioctl(soundfd,SNDCTL_DSP_SPEED,&ss->rate);
28 if(ret==-1) {
29 perror("ioctl");
30 return-1 ;
31 };
32 IFDEBUG(fprintf(stderr,"soundcard.c: channels: %d\n",ss->channels));
33 ret=ioctl(soundfd,SNDCTL_DSP_CHANNELS,&ss->channels);
34 if(ret==-1) {
35 perror("ioctl");
36 return -1;
37 };
38 IFDEBUG(fprintf(stderr,"soundcard.c: fmt %d\n",ss->fmt));
39 ret=ioctl(soundfd,SNDCTL_DSP_SETFMT,&ss->fmt);
40 if(ret==-1) {
41 perror("ioctl");
42 return -1;
43 };
44 IFDEBUG(fprintf(stderr,"Sound card setup sucessfull\n"));
45 return soundfd;
46};
47
48
49