Mercurial > hg > forks > pwpunix
annotate pwplib/snd-hpux.c @ 89:ea44e1d9eb7c default tip
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 25 May 2014 05:03:14 +0300 |
parents | 85671798fdb3 |
children |
rev | line source |
---|---|
0 | 1 #include "config.h" |
2 | |
3 #ifdef DRIVE_HPUX | |
4 | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <unistd.h> | |
8 #include <fcntl.h> | |
9 | |
10 #include <sys/audio.h> | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
11 #include "sound.h" |
0 | 12 |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
13 struct { |
0 | 14 int fd; |
15 char buf[4096]; | |
16 int buflgt; | |
17 int freq; | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
18 } pwp_hpuxsnd; |
0 | 19 |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
20 static void hpuxsnd_loopflush(void) |
0 | 21 { |
22 for(;;) | |
23 { | |
24 struct audio_status bi; | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
25 ioctl(pwp_hpuxsnd.fd, AUDIO_GET_STATUS, &bi); |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
26 if (bi.transmit_exact_count > 3000)break; |
0 | 27 |
28 pwplib.player(); | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
29 gb_genwave(pwp_hpuxsnd.buf, pwp_hpuxsnd.buflgt); |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
30 write(pwp_hpuxsnd.fd, pwp_hpuxsnd.buf, pwp_hpuxsnd.buflgt); |
0 | 31 |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
32 if (bi.transmit_buffer_count > 6000) break; |
0 | 33 } |
34 } | |
35 | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
36 static void hpuxsnd_restore(void) |
0 | 37 { |
38 close(pwp_hpuxsnd.fd); | |
39 } | |
40 | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
41 int hpuxsnd_init(void) |
0 | 42 { |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
43 pwp_hpuxsnd.fd = open("/dev/audio",O_WRONLY); |
0 | 44 if(pwp_hpuxsnd.fd<0)return 0; |
45 | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
46 pwp_hpuxsnd.freq = 8000; |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
47 pwp_hpuxsnd.buflgt = pwp_hpuxsnd.freq / TIMERHZ; |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
48 |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
49 ioctl(pwp_hpuxsnd.fd, AUDIO_SET_TXBUFSIZE, 2048); |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
50 ioctl(pwp_hpuxsnd.fd, AUDIO_SET_SAMPLE_RATE, pwp_hpuxsnd.freq); |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
51 ioctl(pwp_hpuxsnd.fd, AUDIO_SET_CHANNELS, AUDIO_CHANNEL_0|AUDIO_CHANNEL_1); |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
52 ioctl(pwp_hpuxsnd.fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_LINEAR8BIT); |
0 | 53 |
54 pwpwrite("* HP-UX sound\n"); | |
55 | |
54
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
56 pwplib.sound = gb_sound; |
85671798fdb3
Various code cleanups, cosmetics, warning fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
57 pwplib.loopflush = hpuxsnd_loopflush; |
0 | 58 gb_init(pwp_hpuxsnd.freq); |
59 | |
17
c60e531d19cd
Some misc. cleanups and minor warning removals.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
60 pwplib_regdestr(hpuxsnd_restore); |
0 | 61 |
62 return 1; | |
63 } | |
64 #endif |