Mercurial > hg > forks > pwpunix
annotate pwplib/snd-oss.c @ 17:c60e531d19cd
Some misc. cleanups and minor warning removals.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 22 May 2010 20:32:49 +0300 |
parents | acb5694e93d9 |
children | b9d679965320 |
rev | line source |
---|---|
0 | 1 #include "config.h" |
2 | |
3 #ifdef DRIVE_OSS | |
4 | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <unistd.h> | |
8 #include <fcntl.h> | |
9 | |
10 #include <linux/soundcard.h> | |
11 | |
12 #include "pwplib.h" | |
13 | |
14 #define TIMERHZ 72 | |
15 | |
16 struct{ | |
17 int fd; | |
18 char buf[4096]; | |
19 int buflgt; | |
20 int freq; | |
21 }pwp_oss; | |
22 | |
23 extern void gb_sound(int,int,int,int); | |
24 | |
25 void oss_loopflush() | |
26 { | |
27 for(;;) | |
28 {audio_buf_info bi;ioctl(pwp_oss.fd,SNDCTL_DSP_GETOSPACE,&bi); | |
29 if(bi.fragments==1)break; | |
30 pwplib.player(); | |
31 gb_genwave(pwp_oss.buf,pwp_oss.buflgt); | |
32 write(pwp_oss.fd,pwp_oss.buf,pwp_oss.buflgt); | |
33 if(bi.fragments<3)break; | |
34 } | |
35 } | |
36 | |
37 void oss_restore() | |
38 { | |
39 close(pwp_oss.fd); | |
40 } | |
41 | |
42 int oss_init() | |
43 { | |
44 pwp_oss.fd=open("/dev/dsp",O_WRONLY); | |
45 if(pwp_oss.fd<0)return 0; | |
46 | |
47 pwpwrite("* OSS sound\n"); | |
48 | |
49 pwp_oss.freq=8000; | |
50 pwp_oss.buflgt=pwp_oss.freq/TIMERHZ; | |
51 | |
52 pwplib.sound=gb_sound; | |
53 pwplib.loopflush=oss_loopflush; | |
54 gb_init(pwp_oss.freq); | |
55 | |
17
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
56 pwplib_regdestr(oss_restore); |
0 | 57 |
58 return 1; | |
59 } | |
60 #endif |