1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
*** soundbyte.c.orig Wed Mar 5 23:04:49 1997
--- soundbyte.c Wed Jun 11 22:50:54 1997
***************
*** 15,21 ****
--- 15,23 ----
#ifdef Solaris
#include <sys/filio.h>
#else
+ #ifndef __FreeBSD__
#include <sys/dir.h>
+ #endif
#include <sys/file.h>
#endif
***************
*** 96,101 ****
--- 98,108 ----
}
#endif
+ #ifndef sun
+ #ifdef HALF_DUPLEX
+ static int oldvol = -1;
+ #endif
+ #endif
/* SOUNDINIT -- Open the sound peripheral and initialise for
access. Return TRUE if successful, FALSE
***************
*** 145,150 ****
--- 152,172 ----
}
ioctl(Audio_fd, AUDIO_SETINFO, &Audio_info);
#endif
+ #ifndef sun
+ #ifdef HALF_DUPLEX
+ if (iomode == O_RDONLY) {
+ if (oldvol == -1)
+ oldvol = soundgetvol();
+ soundplayvol(0);
+ } else if ( iomode == O_WRONLY
+ && oldvol != -1
+ ) {
+ if (soundgetvol() == 0)
+ soundplayvol(oldvol);
+ oldvol = -1;
+ }
+ #endif
+ #endif
return TRUE;
}
if (errno != EINTR) {
***************
*** 160,165 ****
--- 182,196 ----
void soundterm()
{
if (audiof >= 0) {
+ #ifndef sun
+ #ifdef HALF_DUPLEX
+ if (oldvol != -1) {
+ if (soundgetvol() == 0)
+ soundplayvol(oldvol);
+ oldvol = -1;
+ }
+ #endif
+ #endif
if (close(audiof) < 0) {
perror("closing audio device");
}
***************
*** 210,219 ****
arg = (value << 8) | value;
! if (ioctl(Audio_fd, MIXER_WRITE(SOUND_MIXER_PCM), &arg) < 0)
! perror("SOUND_MIXER_PCM");
#endif
}
/* SOUNDRECGAIN -- Set recording gain from 0 (minimum) to 100 (maximum). */
--- 241,270 ----
arg = (value << 8) | value;
! if (ioctl(Audio_fd, SOUND_MIXER_WRITE_PCM, &arg) < 0)
! perror("SOUND_MIXER_WRITE_PCM");
#endif
}
+
+ #ifndef sun
+ #ifdef HALF_DUPLEX
+
+ /* SOUNDGETVOL -- Get current playback volume. */
+
+ int soundgetvol()
+ {
+ int arg, v1, v2;
+
+ if (ioctl(Audio_fd, SOUND_MIXER_READ_PCM, &arg) < 0) {
+ perror("SOUND_MIXER_READ_PCM");
+ return -1;
+ }
+ v1 = arg & 0xFF;
+ v2 = (arg >> 8) & 0xFF;
+ return (v1 > v2) ? v1 : v2;
+ }
+ #endif
+ #endif
/* SOUNDRECGAIN -- Set recording gain from 0 (minimum) to 100 (maximum). */
|