summaryrefslogtreecommitdiff
path: root/audio/maplay/patches/patch-ah
blob: 3a0fbcd64bca7e1d8457c7928ddd73f481df6b52 (plain)
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
$NetBSD: patch-ah,v 1.5 2011/11/22 20:57:35 wiz Exp $

--- maplay.cc.orig	1994-06-23 12:14:36.000000000 +0000
+++ maplay.cc
@@ -31,16 +31,16 @@
  *      on an amd device or in stdout mode, if compiled with ULAW defined
  *    - option -amd forces maplay to treat /dev/audio as an amd device
  *      in the u-law version. This is helpful on some SPARC clones.
- *    - iostreams manipulator calls like "cerr << setw (2) << ..." replaced by
- *      "cerr.width (2); ..." due to problems with older GNU C++ releases.
+ *    - iostreams manipulator calls like "std::cerr << setw (2) << ..." replaced by
+ *      "std::cerr.width (2); ..." due to problems with older GNU C++ releases.
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include <iostream.h>
-#include <iomanip.h>
+#include <iostream>
+#include <iomanip>
 #include "all.h"
 #include "crc.h"
 #include "header.h"
@@ -54,14 +54,14 @@
 
 // data extracted from commandline arguments:
 static char *filename;
-static bool verbose_mode = False, filter_check = False;
-static bool stdout_mode = False;
+static boolean verbose_mode = False, filter_check = False;
+static boolean stdout_mode = False;
 static enum e_channels which_channels = both;
-static bool use_speaker = False, use_headphone = False, use_line_out = False;
+static boolean use_speaker = False, use_headphone = False, use_line_out = False;
 #ifdef ULAW
-static bool force_amd = False;
+static boolean force_amd = False;
 #endif
-static bool use_own_scalefactor = False;
+static boolean use_own_scalefactor = False;
 static real scalefactor;
 
 // data extracted from header of first frame:
@@ -90,15 +90,15 @@ static void Exit (int returncode)
 }
 
 
-main (int argc, char *argv[])
+int main (int argc, char *argv[])
 {
   int i;
-  bool read_ready = False, write_ready = False;
+  boolean read_ready = False, write_ready = False;
 
   if (argc < 2 || !strncmp (argv[1], "-h", 2))
   {
 usage:
-    cerr << "\nusage: " << argv[0]
+    std::cerr << "\nusage: " << argv[0]
 	 << " [-v] [-s] [-l] [-r] "
 #ifdef SPARC
 	    "[-us] [-uh] "
@@ -146,6 +146,12 @@ usage:
 #ifdef Solaris
 	    "SPARC Solaris 2.x"
 #else
+#ifdef __FreeBSD__
+	    "FreeBSD"
+#else
+#ifdef __DragonFly__
+	    "DragonFly"
+#else
 #ifdef LINUX
 	    "Linux"
 #else
@@ -159,6 +165,8 @@ usage:
 #endif
 #endif
 #endif
+#endif
+#endif
 	    " version)\n"
 	    "@(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)\n"
 	    "@(#) Berlin University of Technology\n"
@@ -180,10 +188,10 @@ usage:
 	  stdout_mode = True;
 	  break;
 	case 'l':
-	  which_channels = left;
+	  which_channels = maplay_left;
 	  break;
 	case 'r':
-	  which_channels = right;
+	  which_channels = maplay_right;
 	  break;
 #ifdef SPARC
 	case 'u':
@@ -216,7 +224,7 @@ usage:
 	case 'f':
 	  if (++i == argc)
 	  {
-	    cerr << "please specify a new scalefactor after the -f option!\n";
+	    std::cerr << "please specify a new scalefactor after the -f option!\n";
 	    exit (1);
 	  }
 	  use_own_scalefactor = True;
@@ -243,14 +251,14 @@ usage:
   header = new Header;
   if (!header->read_header (stream, &crc))
   {
-    cerr << "no header found!\n";
+    std::cerr << "no header found!\n";
     Exit (1);
   }
 
   // get info from header of first frame:
   layer = header->layer ();
   if ((mode = header->mode ()) == single_channel)
-    which_channels = left;
+    which_channels = maplay_left;
   sample_frequency = header->sample_frequency ();
 
   // create filter(s):
@@ -319,6 +327,17 @@ usage:
       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)
@@ -328,11 +347,12 @@ usage:
 //  }
 //#else
   {
-    cerr << "Sorry, I don't know your audio device.\n"
+    std::cerr << "Sorry, I don't know your audio device.\n"
 	    "Please use the stdout mode.\n";
     Exit (0);
   }
 //#endif	// !your_machine
+#endif  // !NETBSD
 #endif	// !LINUX
 #endif	// !SPARC
 #endif	// !Indigo
@@ -345,22 +365,22 @@ usage:
       ++name;
     else
       name = filename;
-    cerr << name << " is a layer " << header->layer_string () << ' '
+    std::cerr << name << " is a layer " << header->layer_string () << ' '
 	 << header->mode_string () << " MPEG audio stream with";
     if (!header->checksums ())
-      cerr << "out";
-    cerr << " checksums.\nThe sample frequency is "
+      std::cerr << "out";
+    std::cerr << " checksums.\nThe sample frequency is "
 	 << header->sample_frequency_string () << " at a bitrate of "
 	 << header->bitrate_string () << ".\n"
 	    "This stream is ";
     if (header->original ())
-      cerr << "an original";
+      std::cerr << "an original";
     else
-      cerr << "a copy";
-    cerr << " and is ";
+      std::cerr << "a copy";
+    std::cerr << " and is ";
     if (!header->copyright ())
-      cerr << "not ";
-    cerr << "copyright protected.\n";
+      std::cerr << "not ";
+    std::cerr << "copyright protected.\n";
   }
 
   do
@@ -371,20 +391,20 @@ usage:
     {
       // layer switching is allowed
       if (verbose_mode)
-	cerr << "switching to layer " << header->layer_string () << ".\n";
+	std::cerr << "switching to layer " << header->layer_string () << ".\n";
       layer = header->layer ();
     }
     if ((mode == single_channel && header->mode () != single_channel) ||
 	(mode != single_channel && header->mode () == single_channel))
     {
       // switching from single channel to stereo or vice versa is not allowed
-      cerr << "illegal switch from single channel to stereo or vice versa!\n";
+      std::cerr << "illegal switch from single channel to stereo or vice versa!\n";
       Exit (1);
     }
     if (header->sample_frequency () != sample_frequency)
     {
       // switching the sample frequency is not allowed
-      cerr << "sorry, can't switch the sample frequency in the middle of the stream!\n";
+      std::cerr << "sorry, can't switch the sample frequency in the middle of the stream!\n";
       Exit (1);
     }
 
@@ -423,7 +443,7 @@ usage:
     }
     else
     {
-      cerr << "sorry, layer 3 not implemented!\n";
+      std::cerr << "sorry, layer 3 not implemented!\n";
       Exit (0);
     }
 
@@ -463,7 +483,7 @@ usage:
     }
     else
       // Sh*t! Wrong crc checksum in frame!
-      cerr << "WARNING: frame contains wrong crc checksum! (throwing frame away)\n";
+      std::cerr << "WARNING: frame contains wrong crc checksum! (throwing frame away)\n";
 
     for (i = 0; i < header->number_of_subbands (); ++i)
       delete subbands[i];
@@ -481,18 +501,18 @@ usage:
     // check whether (one of) the filter(s) produced values not in [-1.0, 1.0]:
     if (range_violations)
     {
-      cerr << range_violations << " range violations have occured!\n";
+      std::cerr << range_violations << " range violations have occured!\n";
       if (stdout_mode)
-	cerr << "If you notice these violations,\n";
+	std::cerr << "If you notice these violations,\n";
       else
-	cerr << "If you have noticed these violations,\n";
-      cerr << "please use the -f option with the value ";
+	std::cerr << "If you have noticed these violations,\n";
+      std::cerr << "please use the -f option with the value ";
       if (mode != single_channel && which_channels == both &&
 	  filter2->hardest_violation () > filter1->hardest_violation ())
-	cerr << filter2->recommended_scalefactor ();
+	std::cerr << filter2->recommended_scalefactor ();
       else
-	cerr << filter1->recommended_scalefactor ();
-      cerr << "\nor a greater value up to 32768 and try again.\n";
+	std::cerr << filter1->recommended_scalefactor ();
+      std::cerr << "\nor a greater value up to 32768 and try again.\n";
     }
   }
   if (verbose_mode)
@@ -502,13 +522,13 @@ usage:
     uint32 minutes = (uint32)(playtime / 60.0);
     uint32 seconds = (uint32)playtime - minutes * 60;
     uint32 centiseconds = (uint32)((playtime - (real)(minutes * 60) - (real)seconds) * 100.0);
-    cerr << "end of stream, playtime: " << minutes << ':';
-    cerr.width (2);
-    cerr.fill ('0');
-    cerr << seconds << '.';
-    cerr.width (2);
-    cerr.fill ('0');
-    cerr << centiseconds << '\n';
+    std::cerr << "end of stream, playtime: " << minutes << ':';
+    std::cerr.width (2);
+    std::cerr.fill ('0');
+    std::cerr << seconds << '.';
+    std::cerr.width (2);
+    std::cerr.fill ('0');
+    std::cerr << centiseconds << '\n';
   }
 
   return 0;