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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
diff -u ../work/configuration.sh ./configuration.sh
--- ../work/configuration.sh Sun Oct 26 12:31:52 1997
+++ ./configuration.sh Sun Oct 26 12:19:41 1997
@@ -72,6 +72,12 @@
INCLUDEDIRS=
LIBRARIES=
AUDIO_INCLUDES='#include <sys/audioio.h>' ;;
+ NetBSD*)
+ COMPILER=g++
+ COMPILERFLAGS='-O2 -DNETBSD'
+ INCLUDEDIRS=
+ LIBRARIES=
+ AUDIO_INCLUDES='#include <sys/audioio.h>' ;;
FreeBSD*)
COMPILER=g++
COMPILERFLAGS='-O2 -m486 -DLINUX -DDAMN_INTEL_BYTE_ORDER'
diff -u ../work/header.cc ./header.cc
--- ../work/header.cc Sun Oct 26 12:31:52 1997
+++ ./header.cc Sun Oct 26 12:25:28 1997
@@ -48,8 +48,8 @@
cerr << "invalid syncword 0x";
cerr.width (8);
cerr.fill ('0');
- cerr << hex << headerstring
- << " found at fileoffset " << dec
+ cerr << headerstring
+ << " found at fileoffset "
<< lseek (stream->filedescriptor (), 0, SEEK_CUR) - 4 << '\n';
return False;
}
diff -u ../work/ibitstream.cc ./ibitstream.cc
--- ../work/ibitstream.cc Sun Oct 26 12:31:52 1997
+++ ./ibitstream.cc Sun Oct 26 12:17:22 1997
@@ -33,6 +33,12 @@
#include "all.h"
#include "ibitstream.h"
+#ifdef NETBSD
+#include <machine/endian.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define DAMN_INTEL_BYTE_ORDER
+#endif
+#endif
#define swap_int32(int_32) (((int_32) << 24) | (((int_32) << 8) & 0x00ff0000) | \
(((int_32) >> 8) & 0x0000ff00) | ((int_32) >> 24))
diff -u ../work/maplay.cc ./maplay.cc
--- ../work/maplay.cc Sun Oct 26 12:31:52 1997
+++ ./maplay.cc Sun Oct 26 12:18:30 1997
@@ -323,6 +323,17 @@
Exit (0);
}
#else
+#ifdef NETBSD
+ {
+ if (NetBSDObuffer::class_suitable (mode == single_channel || which_channels != both) ? 1 : 2)
+ if (mode == single_channel || which_channels != both)
+ buffer = new NetBSDObuffer (1, header);
+ else
+ buffer = new NetBSDObuffer (2, header);
+ else
+ Exit (0);
+ }
+#else
//#ifdef your_machine
// {
// if (mode == single_channel || which_channels != both)
@@ -337,6 +348,7 @@
Exit (0);
}
//#endif // !your_machine
+#endif // !NETBSD
#endif // !LINUX
#endif // !SPARC
#endif // !Indigo
diff -u ../work/obuffer.cc ./obuffer.cc
--- ../work/obuffer.cc Sun Oct 26 12:31:52 1997
+++ ./obuffer.cc Sun Oct 26 12:32:53 1997
@@ -639,3 +639,122 @@
}
#endif /* LINUX */
+
+#ifdef NETBSD
+int NetBSDObuffer::audio_fd = -1;
+
+int NetBSDObuffer::open_audio_device (void)
+{
+ int fd;
+
+ if ((fd = open ("/dev/audio", O_WRONLY | O_NDELAY, 0)) < 0)
+ if (errno == EBUSY)
+ {
+ cerr << "Sorry, the audio device is busy!\n";
+ exit (1);
+ }
+ else
+ {
+ perror ("can't open /dev/audio for writing");
+ exit (1);
+ }
+
+ int flags;
+ if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
+ {
+ perror ("fcntl F_GETFL on /dev/audio failed");
+ exit (1);
+ }
+ flags &= ~O_NDELAY;
+ if (fcntl (fd, F_SETFL, flags) < 0)
+ {
+ perror ("fcntl F_SETFL on /dev/audio failed");
+ exit (1);
+ }
+ return fd;
+}
+
+
+NetBSDObuffer::NetBSDObuffer (uint32 number_of_channels, Header *header)
+{
+#ifdef DEBUG
+ if (!number_of_channels || number_of_channels > MAXCHANNELS)
+ {
+ cerr << "NetBSDObuffer: 0 < number of channels < " << MAXCHANNELS << "!\n";
+ exit (1);
+ }
+#endif
+ channels = number_of_channels;
+ for (int i = 0; i < number_of_channels; ++i)
+ bufferp[i] = buffer + i;
+
+ if (audio_fd < 0)
+ {
+ cerr << "Internal error, NetBSDObuffer::audio_fd has to be initialized\n"
+ "by NetBSDObuffer::class_suitable()!\n";
+ exit (1);
+ }
+
+ audio_info info;
+ AUDIO_INITINFO(&info);
+
+ // configure the device:
+ info.play.encoding = AUDIO_ENCODING_SLINEAR;
+ info.play.precision = 16;
+ info.play.channels = channels;
+ info.play.sample_rate = header->frequency ();
+
+ if (ioctl (audio_fd, AUDIO_SETINFO, &info))
+ {
+ perror ("configuration of /dev/audio failed");
+ exit (1);
+ }
+}
+
+
+NetBSDObuffer::~NetBSDObuffer (void)
+{
+ close (audio_fd);
+}
+
+
+void NetBSDObuffer::append (uint32 channel, int16 value)
+{
+#ifdef DEBUG
+ if (channel >= channels)
+ {
+ cerr << "illegal channelnumber in NetBSDObuffer::append()!\n";
+ exit (1);
+ }
+ if (bufferp[channel] - buffer >= OBUFFERSIZE)
+ {
+ cerr << "buffer overflow!\n";
+ exit (1);
+ }
+#endif
+ *bufferp[channel] = value;
+ bufferp[channel] += channels;
+}
+
+
+void NetBSDObuffer::write_buffer (int)
+{
+ int length = (int)((char *)bufferp[0] - (char *)buffer);
+ if (write (audio_fd, buffer, length) != length)
+ {
+ perror ("write to /dev/audio failed");
+ exit (1);
+ }
+ for (int i = 0; i < channels; ++i)
+ bufferp[i] = buffer + i;
+}
+
+
+boolean NetBSDObuffer::class_suitable (uint32 number_of_channels)
+{
+ // open the dsp audio device:
+ audio_fd = open_audio_device ();
+ return True;
+}
+
+#endif /* NETBSD */
diff -u ../work/obuffer.h ./obuffer.h
--- ../work/obuffer.h Sun Oct 26 12:31:52 1997
+++ ./obuffer.h Sun Oct 26 12:19:16 1997
@@ -163,4 +163,24 @@
};
#endif // LINUX
+#ifdef NETBSD
+class NetBSDObuffer : public Obuffer
+{
+ int16 buffer[OBUFFERSIZE];
+ int16 *bufferp[MAXCHANNELS];
+ uint32 channels;
+ static int audio_fd;
+
+ static int open_audio_device (void);
+
+public:
+ NetBSDObuffer (uint32 number_of_channels, Header *);
+ ~NetBSDObuffer (void);
+ void append (uint32 channel, int16 value);
+ void write_buffer (int dummy);
+
+ static boolean class_suitable (uint32 number_of_channels);
+};
+#endif // LINUX
+
#endif
|