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