Mercurial > hg > sv-dependency-builds
comparison src/libsndfile-1.0.27/tests/write_read_test.tpl @ 40:1df64224f5ac
Current libsndfile source
author | Chris Cannam |
---|---|
date | Tue, 18 Oct 2016 13:22:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
39:7ddb4fc30dac | 40:1df64224f5ac |
---|---|
1 [+ AutoGen5 template c +] | |
2 /* | |
3 ** Copyright (C) 1999-2016 Erik de Castro Lopo <erikd@mega-nerd.com> | |
4 ** | |
5 ** This program is free software; you can redistribute it and/or modify | |
6 ** it under the terms of the GNU General Public License as published by | |
7 ** the Free Software Foundation; either version 2 of the License, or | |
8 ** (at your option) any later version. | |
9 ** | |
10 ** This program is distributed in the hope that it will be useful, | |
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ** GNU General Public License for more details. | |
14 ** | |
15 ** You should have received a copy of the GNU General Public License | |
16 ** along with this program; if not, write to the Free Software | |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 */ | |
19 | |
20 #include "sfconfig.h" | |
21 | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <string.h> | |
25 #include <math.h> | |
26 #include <inttypes.h> | |
27 | |
28 | |
29 #if HAVE_UNISTD_H | |
30 #include <unistd.h> | |
31 #endif | |
32 | |
33 #include <sndfile.h> | |
34 | |
35 #include "utils.h" | |
36 #include "generate.h" | |
37 | |
38 #define SAMPLE_RATE 11025 | |
39 #define DATA_LENGTH (1 << 12) | |
40 | |
41 #define SILLY_WRITE_COUNT (234) | |
42 | |
43 [+ FOR data_type | |
44 +]static void pcm_test_[+ (get "type_name") +] (const char *str, int format, int long_file_ok) ; | |
45 [+ ENDFOR data_type | |
46 +] | |
47 static void empty_file_test (const char *filename, int format) ; | |
48 | |
49 typedef union | |
50 { double d [DATA_LENGTH] ; | |
51 float f [DATA_LENGTH] ; | |
52 int i [DATA_LENGTH] ; | |
53 short s [DATA_LENGTH] ; | |
54 char c [DATA_LENGTH] ; | |
55 } BUFFER ; | |
56 | |
57 static BUFFER orig_data ; | |
58 static BUFFER test_data ; | |
59 | |
60 int | |
61 main (int argc, char **argv) | |
62 { int do_all = 0 ; | |
63 int test_count = 0 ; | |
64 | |
65 count_open_files () ; | |
66 | |
67 if (argc != 2) | |
68 { printf ("Usage : %s <test>\n", argv [0]) ; | |
69 printf (" Where <test> is one of the following:\n") ; | |
70 printf (" wav - test WAV file functions (little endian)\n") ; | |
71 printf (" aiff - test AIFF file functions (big endian)\n") ; | |
72 printf (" au - test AU file functions\n") ; | |
73 printf (" avr - test AVR file functions\n") ; | |
74 printf (" caf - test CAF file functions\n") ; | |
75 printf (" raw - test RAW header-less PCM file functions\n") ; | |
76 printf (" paf - test PAF file functions\n") ; | |
77 printf (" svx - test 8SVX/16SV file functions\n") ; | |
78 printf (" nist - test NIST Sphere file functions\n") ; | |
79 printf (" ircam - test IRCAM file functions\n") ; | |
80 printf (" voc - Create Voice file functions\n") ; | |
81 printf (" w64 - Sonic Foundry's W64 file functions\n") ; | |
82 printf (" flac - test FLAC file functions\n") ; | |
83 printf (" mpc2k - test MPC 2000 file functions\n") ; | |
84 printf (" rf64 - test RF64 file functions\n") ; | |
85 printf (" all - perform all tests\n") ; | |
86 exit (1) ; | |
87 } ; | |
88 | |
89 do_all = !strcmp (argv [1], "all") ; | |
90 | |
91 if (do_all || ! strcmp (argv [1], "wav")) | |
92 { pcm_test_char ("char.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
93 pcm_test_short ("short.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_16, SF_FALSE) ; | |
94 pcm_test_24bit ("24bit.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_24, SF_FALSE) ; | |
95 pcm_test_int ("int.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_32, SF_FALSE) ; | |
96 | |
97 pcm_test_char ("char.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
98 pcm_test_short ("short.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_16, SF_FALSE) ; | |
99 pcm_test_24bit ("24bit.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_24, SF_FALSE) ; | |
100 pcm_test_int ("int.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_PCM_32, SF_FALSE) ; | |
101 | |
102 pcm_test_24bit ("24bit.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_PCM_24, SF_FALSE) ; | |
103 pcm_test_int ("int.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_PCM_32, SF_FALSE) ; | |
104 | |
105 /* Lite remove start */ | |
106 pcm_test_float ("float.wav" , SF_FORMAT_WAV | SF_FORMAT_FLOAT , SF_FALSE) ; | |
107 pcm_test_double ("double.wav" , SF_FORMAT_WAV | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
108 | |
109 pcm_test_float ("float.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_FLOAT , SF_FALSE) ; | |
110 pcm_test_double ("double.rifx" , SF_ENDIAN_BIG | SF_FORMAT_WAV | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
111 | |
112 pcm_test_float ("float.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_FLOAT , SF_FALSE) ; | |
113 pcm_test_double ("double.wavex" , SF_FORMAT_WAVEX | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
114 /* Lite remove end */ | |
115 | |
116 empty_file_test ("empty_char.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ; | |
117 empty_file_test ("empty_short.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ; | |
118 empty_file_test ("empty_float.wav", SF_FORMAT_WAV | SF_FORMAT_FLOAT) ; | |
119 | |
120 test_count++ ; | |
121 } ; | |
122 | |
123 if (do_all || ! strcmp (argv [1], "aiff")) | |
124 { pcm_test_char ("char_u8.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
125 pcm_test_char ("char_s8.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
126 pcm_test_short ("short.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
127 pcm_test_24bit ("24bit.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_24, SF_FALSE) ; | |
128 pcm_test_int ("int.aiff" , SF_FORMAT_AIFF | SF_FORMAT_PCM_32, SF_FALSE) ; | |
129 | |
130 pcm_test_short ("short_sowt.aifc" , SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
131 pcm_test_24bit ("24bit_sowt.aifc" , SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | SF_FORMAT_PCM_24, SF_FALSE) ; | |
132 pcm_test_int ("int_sowt.aifc" , SF_ENDIAN_LITTLE | SF_FORMAT_AIFF | SF_FORMAT_PCM_32, SF_FALSE) ; | |
133 | |
134 pcm_test_short ("short_twos.aifc" , SF_ENDIAN_BIG | SF_FORMAT_AIFF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
135 pcm_test_24bit ("24bit_twos.aifc" , SF_ENDIAN_BIG | SF_FORMAT_AIFF | SF_FORMAT_PCM_24, SF_FALSE) ; | |
136 pcm_test_int ("int_twos.aifc" , SF_ENDIAN_BIG | SF_FORMAT_AIFF | SF_FORMAT_PCM_32, SF_FALSE) ; | |
137 | |
138 /* Lite remove start */ | |
139 pcm_test_short ("dwvw16.aifc", SF_FORMAT_AIFF | SF_FORMAT_DWVW_16, SF_TRUE) ; | |
140 pcm_test_24bit ("dwvw24.aifc", SF_FORMAT_AIFF | SF_FORMAT_DWVW_24, SF_TRUE) ; | |
141 | |
142 pcm_test_float ("float.aifc" , SF_FORMAT_AIFF | SF_FORMAT_FLOAT , SF_FALSE) ; | |
143 pcm_test_double ("double.aifc" , SF_FORMAT_AIFF | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
144 /* Lite remove end */ | |
145 | |
146 empty_file_test ("empty_char.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_U8) ; | |
147 empty_file_test ("empty_short.aiff", SF_FORMAT_AIFF | SF_FORMAT_PCM_16) ; | |
148 empty_file_test ("empty_float.aiff", SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ; | |
149 | |
150 test_count++ ; | |
151 } ; | |
152 | |
153 if (do_all || ! strcmp (argv [1], "au")) | |
154 { pcm_test_char ("char.au" , SF_FORMAT_AU | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
155 pcm_test_short ("short.au" , SF_FORMAT_AU | SF_FORMAT_PCM_16, SF_FALSE) ; | |
156 pcm_test_24bit ("24bit.au" , SF_FORMAT_AU | SF_FORMAT_PCM_24, SF_FALSE) ; | |
157 pcm_test_int ("int.au" , SF_FORMAT_AU | SF_FORMAT_PCM_32, SF_FALSE) ; | |
158 /* Lite remove start */ | |
159 pcm_test_float ("float.au" , SF_FORMAT_AU | SF_FORMAT_FLOAT , SF_FALSE) ; | |
160 pcm_test_double ("double.au", SF_FORMAT_AU | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
161 /* Lite remove end */ | |
162 | |
163 pcm_test_char ("char_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
164 pcm_test_short ("short_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_16, SF_FALSE) ; | |
165 pcm_test_24bit ("24bit_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_24, SF_FALSE) ; | |
166 pcm_test_int ("int_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_PCM_32, SF_FALSE) ; | |
167 /* Lite remove start */ | |
168 pcm_test_float ("float_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT , SF_FALSE) ; | |
169 pcm_test_double ("double_le.au" , SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
170 /* Lite remove end */ | |
171 test_count++ ; | |
172 } ; | |
173 | |
174 if (do_all || ! strcmp (argv [1], "caf")) | |
175 { pcm_test_char ("char.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
176 pcm_test_short ("short.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
177 pcm_test_24bit ("24bit.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_24, SF_FALSE) ; | |
178 pcm_test_int ("int.caf" , SF_FORMAT_CAF | SF_FORMAT_PCM_32, SF_FALSE) ; | |
179 /* Lite remove start */ | |
180 pcm_test_float ("float.caf" , SF_FORMAT_CAF | SF_FORMAT_FLOAT , SF_FALSE) ; | |
181 pcm_test_double ("double.caf" , SF_FORMAT_CAF | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
182 /* Lite remove end */ | |
183 | |
184 pcm_test_short ("short_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
185 pcm_test_24bit ("24bit_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_PCM_24, SF_FALSE) ; | |
186 pcm_test_int ("int_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_PCM_32, SF_FALSE) ; | |
187 /* Lite remove start */ | |
188 pcm_test_float ("float_le.caf" , SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_FLOAT , SF_FALSE) ; | |
189 pcm_test_double ("double_le.caf", SF_ENDIAN_LITTLE | SF_FORMAT_CAF | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
190 | |
191 pcm_test_short ("alac16.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_16, SF_FALSE) ; | |
192 pcm_test_20bit ("alac20.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_20, SF_FALSE) ; | |
193 pcm_test_24bit ("alac24.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_24, SF_FALSE) ; | |
194 pcm_test_int ("alac32.caf" , SF_FORMAT_CAF | SF_FORMAT_ALAC_32, SF_FALSE) ; | |
195 | |
196 /* Lite remove end */ | |
197 test_count++ ; | |
198 } ; | |
199 | |
200 if (do_all || ! strcmp (argv [1], "raw")) | |
201 { pcm_test_char ("char_s8.raw" , SF_FORMAT_RAW | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
202 pcm_test_char ("char_u8.raw" , SF_FORMAT_RAW | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
203 | |
204 pcm_test_short ("short_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16, SF_FALSE) ; | |
205 pcm_test_short ("short_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_16, SF_FALSE) ; | |
206 pcm_test_24bit ("24bit_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_24, SF_FALSE) ; | |
207 pcm_test_24bit ("24bit_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_24, SF_FALSE) ; | |
208 pcm_test_int ("int_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_32, SF_FALSE) ; | |
209 pcm_test_int ("int_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_PCM_32, SF_FALSE) ; | |
210 | |
211 /* Lite remove start */ | |
212 pcm_test_float ("float_le.raw" , SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_FLOAT , SF_FALSE) ; | |
213 pcm_test_float ("float_be.raw" , SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_FLOAT , SF_FALSE) ; | |
214 | |
215 pcm_test_double ("double_le.raw", SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
216 pcm_test_double ("double_be.raw", SF_ENDIAN_BIG | SF_FORMAT_RAW | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
217 /* Lite remove end */ | |
218 test_count++ ; | |
219 } ; | |
220 | |
221 /* Lite remove start */ | |
222 if (do_all || ! strcmp (argv [1], "paf")) | |
223 { pcm_test_char ("char_le.paf", SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
224 pcm_test_char ("char_be.paf", SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
225 pcm_test_short ("short_le.paf", SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
226 pcm_test_short ("short_be.paf", SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
227 pcm_test_24bit ("24bit_le.paf", SF_ENDIAN_LITTLE | SF_FORMAT_PAF | SF_FORMAT_PCM_24, SF_TRUE) ; | |
228 pcm_test_24bit ("24bit_be.paf", SF_ENDIAN_BIG | SF_FORMAT_PAF | SF_FORMAT_PCM_24, SF_TRUE) ; | |
229 test_count++ ; | |
230 } ; | |
231 | |
232 if (do_all || ! strcmp (argv [1], "svx")) | |
233 { pcm_test_char ("char.svx" , SF_FORMAT_SVX | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
234 pcm_test_short ("short.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_16, SF_FALSE) ; | |
235 | |
236 empty_file_test ("empty_char.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_S8) ; | |
237 empty_file_test ("empty_short.svx", SF_FORMAT_SVX | SF_FORMAT_PCM_16) ; | |
238 | |
239 test_count++ ; | |
240 } ; | |
241 | |
242 if (do_all || ! strcmp (argv [1], "nist")) | |
243 { pcm_test_short ("short_le.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_PCM_16, SF_FALSE) ; | |
244 pcm_test_short ("short_be.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_PCM_16, SF_FALSE) ; | |
245 pcm_test_24bit ("24bit_le.nist", SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_PCM_24, SF_FALSE) ; | |
246 pcm_test_24bit ("24bit_be.nist", SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_PCM_24, SF_FALSE) ; | |
247 pcm_test_int ("int_le.nist" , SF_ENDIAN_LITTLE | SF_FORMAT_NIST | SF_FORMAT_PCM_32, SF_FALSE) ; | |
248 pcm_test_int ("int_be.nist" , SF_ENDIAN_BIG | SF_FORMAT_NIST | SF_FORMAT_PCM_32, SF_FALSE) ; | |
249 | |
250 test_count++ ; | |
251 } ; | |
252 | |
253 if (do_all || ! strcmp (argv [1], "ircam")) | |
254 { pcm_test_short ("short_be.ircam" , SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_PCM_16, SF_FALSE) ; | |
255 pcm_test_short ("short_le.ircam" , SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_PCM_16, SF_FALSE) ; | |
256 pcm_test_int ("int_be.ircam" , SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_PCM_32, SF_FALSE) ; | |
257 pcm_test_int ("int_le.ircam" , SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_PCM_32, SF_FALSE) ; | |
258 pcm_test_float ("float_be.ircam" , SF_ENDIAN_BIG | SF_FORMAT_IRCAM | SF_FORMAT_FLOAT , SF_FALSE) ; | |
259 pcm_test_float ("float_le.ircam" , SF_ENDIAN_LITTLE | SF_FORMAT_IRCAM | SF_FORMAT_FLOAT , SF_FALSE) ; | |
260 | |
261 test_count++ ; | |
262 } ; | |
263 | |
264 if (do_all || ! strcmp (argv [1], "voc")) | |
265 { pcm_test_char ("char.voc" , SF_FORMAT_VOC | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
266 pcm_test_short ("short.voc", SF_FORMAT_VOC | SF_FORMAT_PCM_16, SF_FALSE) ; | |
267 | |
268 test_count++ ; | |
269 } ; | |
270 | |
271 if (do_all || ! strcmp (argv [1], "mat4")) | |
272 { pcm_test_short ("short_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_PCM_16, SF_FALSE) ; | |
273 pcm_test_short ("short_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_PCM_16, SF_FALSE) ; | |
274 pcm_test_int ("int_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_PCM_32, SF_FALSE) ; | |
275 pcm_test_int ("int_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_PCM_32, SF_FALSE) ; | |
276 pcm_test_float ("float_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_FLOAT , SF_FALSE) ; | |
277 pcm_test_float ("float_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_FLOAT , SF_FALSE) ; | |
278 pcm_test_double ("double_be.mat4" , SF_ENDIAN_BIG | SF_FORMAT_MAT4 | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
279 pcm_test_double ("double_le.mat4" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT4 | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
280 | |
281 empty_file_test ("empty_short.mat4", SF_FORMAT_MAT4 | SF_FORMAT_PCM_16) ; | |
282 empty_file_test ("empty_float.mat4", SF_FORMAT_MAT4 | SF_FORMAT_FLOAT) ; | |
283 test_count++ ; | |
284 } ; | |
285 | |
286 if (do_all || ! strcmp (argv [1], "mat5")) | |
287 { pcm_test_char ("char_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
288 pcm_test_char ("char_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
289 pcm_test_short ("short_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_PCM_16, SF_FALSE) ; | |
290 pcm_test_short ("short_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_PCM_16, SF_FALSE) ; | |
291 pcm_test_int ("int_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_PCM_32, SF_FALSE) ; | |
292 pcm_test_int ("int_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_PCM_32, SF_FALSE) ; | |
293 pcm_test_float ("float_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_FLOAT , SF_FALSE) ; | |
294 pcm_test_float ("float_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_FLOAT , SF_FALSE) ; | |
295 pcm_test_double ("double_be.mat5" , SF_ENDIAN_BIG | SF_FORMAT_MAT5 | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
296 pcm_test_double ("double_le.mat5" , SF_ENDIAN_LITTLE | SF_FORMAT_MAT5 | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
297 | |
298 increment_open_file_count () ; | |
299 | |
300 empty_file_test ("empty_char.mat5", SF_FORMAT_MAT5 | SF_FORMAT_PCM_U8) ; | |
301 empty_file_test ("empty_short.mat5", SF_FORMAT_MAT5 | SF_FORMAT_PCM_16) ; | |
302 empty_file_test ("empty_float.mat5", SF_FORMAT_MAT5 | SF_FORMAT_FLOAT) ; | |
303 | |
304 test_count++ ; | |
305 } ; | |
306 | |
307 if (do_all || ! strcmp (argv [1], "pvf")) | |
308 { pcm_test_char ("char.pvf" , SF_FORMAT_PVF | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
309 pcm_test_short ("short.pvf", SF_FORMAT_PVF | SF_FORMAT_PCM_16, SF_FALSE) ; | |
310 pcm_test_int ("int.pvf" , SF_FORMAT_PVF | SF_FORMAT_PCM_32, SF_FALSE) ; | |
311 test_count++ ; | |
312 } ; | |
313 | |
314 if (do_all || ! strcmp (argv [1], "htk")) | |
315 { pcm_test_short ("short.htk", SF_FORMAT_HTK | SF_FORMAT_PCM_16, SF_FALSE) ; | |
316 test_count++ ; | |
317 } ; | |
318 | |
319 if (do_all || ! strcmp (argv [1], "mpc2k")) | |
320 { pcm_test_short ("short.mpc", SF_FORMAT_MPC2K | SF_FORMAT_PCM_16, SF_FALSE) ; | |
321 test_count++ ; | |
322 } ; | |
323 | |
324 if (do_all || ! strcmp (argv [1], "avr")) | |
325 { pcm_test_char ("char_u8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
326 pcm_test_char ("char_s8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
327 pcm_test_short ("short.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_16, SF_FALSE) ; | |
328 test_count++ ; | |
329 } ; | |
330 /* Lite remove end */ | |
331 | |
332 if (do_all || ! strcmp (argv [1], "w64")) | |
333 { pcm_test_char ("char.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
334 pcm_test_short ("short.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_16, SF_FALSE) ; | |
335 pcm_test_24bit ("24bit.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_24, SF_FALSE) ; | |
336 pcm_test_int ("int.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_32, SF_FALSE) ; | |
337 /* Lite remove start */ | |
338 pcm_test_float ("float.w64" , SF_FORMAT_W64 | SF_FORMAT_FLOAT , SF_FALSE) ; | |
339 pcm_test_double ("double.w64" , SF_FORMAT_W64 | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
340 /* Lite remove end */ | |
341 | |
342 empty_file_test ("empty_char.w64", SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ; | |
343 empty_file_test ("empty_short.w64", SF_FORMAT_W64 | SF_FORMAT_PCM_16) ; | |
344 empty_file_test ("empty_float.w64", SF_FORMAT_W64 | SF_FORMAT_FLOAT) ; | |
345 | |
346 test_count++ ; | |
347 } ; | |
348 | |
349 if (do_all || ! strcmp (argv [1], "sds")) | |
350 { pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_FALSE) ; | |
351 pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_FALSE) ; | |
352 pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_FALSE) ; | |
353 | |
354 empty_file_test ("empty_char.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_S8) ; | |
355 empty_file_test ("empty_short.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ; | |
356 | |
357 test_count++ ; | |
358 } ; | |
359 | |
360 if (do_all || ! strcmp (argv [1], "sd2")) | |
361 { pcm_test_char ("char.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_S8, SF_TRUE) ; | |
362 pcm_test_short ("short.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_16, SF_TRUE) ; | |
363 pcm_test_24bit ("24bit.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_24, SF_TRUE) ; | |
364 pcm_test_int ("32bit.sd2" , SF_FORMAT_SD2 | SF_FORMAT_PCM_32, SF_TRUE) ; | |
365 test_count++ ; | |
366 } ; | |
367 | |
368 if (do_all || ! strcmp (argv [1], "flac")) | |
369 { if (HAVE_EXTERNAL_XIPH_LIBS) | |
370 { pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ; | |
371 pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ; | |
372 pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ; | |
373 } | |
374 else | |
375 puts (" No FLAC tests because FLAC support was not compiled in.") ; | |
376 test_count++ ; | |
377 } ; | |
378 | |
379 if (do_all || ! strcmp (argv [1], "rf64")) | |
380 { pcm_test_char ("char.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_U8, SF_FALSE) ; | |
381 pcm_test_short ("short.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_16, SF_FALSE) ; | |
382 pcm_test_24bit ("24bit.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_24, SF_FALSE) ; | |
383 pcm_test_int ("int.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_32, SF_FALSE) ; | |
384 | |
385 /* Lite remove start */ | |
386 pcm_test_float ("float.rf64" , SF_FORMAT_RF64 | SF_FORMAT_FLOAT , SF_FALSE) ; | |
387 pcm_test_double ("double.rf64" , SF_FORMAT_RF64 | SF_FORMAT_DOUBLE, SF_FALSE) ; | |
388 empty_file_test ("empty_char.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_U8) ; | |
389 empty_file_test ("empty_short.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ; | |
390 empty_file_test ("empty_float.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ; | |
391 /* Lite remove end */ | |
392 | |
393 test_count++ ; | |
394 } ; | |
395 | |
396 if (test_count == 0) | |
397 { printf ("Mono : ************************************\n") ; | |
398 printf ("Mono : * No '%s' test defined.\n", argv [1]) ; | |
399 printf ("Mono : ************************************\n") ; | |
400 return 1 ; | |
401 } ; | |
402 | |
403 /* Only open file descriptors should be stdin, stdout and stderr. */ | |
404 check_open_file_count_or_die (__LINE__) ; | |
405 | |
406 return 0 ; | |
407 } /* main */ | |
408 | |
409 /*============================================================================================ | |
410 ** Helper functions and macros. | |
411 */ | |
412 | |
413 static void create_short_file (const char *filename) ; | |
414 | |
415 #define CHAR_ERROR(x, y) (abs ((x) - (y)) > 255) | |
416 #define INT_ERROR(x, y) (((x) - (y)) != 0) | |
417 #define BIT_20_ERROR(x, y) (abs ((x) - (y)) > 4095) | |
418 #define TRIBYTE_ERROR(x, y) (abs ((x) - (y)) > 255) | |
419 #define FLOAT_ERROR(x, y) (fabs ((x) - (y)) > 1e-5) | |
420 | |
421 #define CONVERT_DATA(k, len, new, orig) \ | |
422 { for ((k) = 0 ; (k) < (len) ; (k) ++) \ | |
423 (new) [k] = (orig) [k] ; \ | |
424 } | |
425 | |
426 [+ FOR data_type | |
427 +] | |
428 /*====================================================================================== | |
429 */ | |
430 | |
431 static void mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ; | |
432 static void stereo_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ; | |
433 static void mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) ; | |
434 static void new_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int allow_fd) ; | |
435 static void multi_seek_test (const char * filename, int format) ; | |
436 static void write_seek_extend_test (const char * filename, int format) ; | |
437 | |
438 static void | |
439 pcm_test_[+ (get "type_name") +] (const char *filename, int format, int long_file_ok) | |
440 { SF_INFO sfinfo ; | |
441 [+ (get "data_type") +] *orig ; | |
442 int k, allow_fd ; | |
443 | |
444 /* Sd2 files cannot be opened from an existing file descriptor. */ | |
445 allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; | |
446 | |
447 print_test_name ("pcm_test_[+ (get "type_name") +]", filename) ; | |
448 | |
449 sfinfo.samplerate = 44100 ; | |
450 sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ | |
451 sfinfo.channels = 1 ; | |
452 sfinfo.format = format ; | |
453 | |
454 test_sf_format_or_die (&sfinfo, __LINE__) ; | |
455 | |
456 gen_windowed_sine_double (orig_data.d, DATA_LENGTH, [+ (get "max_val") +]) ; | |
457 | |
458 orig = orig_data.[+ (get "data_field") +] ; | |
459 | |
460 /* Make this a macro so gdb steps over it in one go. */ | |
461 CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; | |
462 | |
463 /* Some test broken out here. */ | |
464 | |
465 mono_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; | |
466 | |
467 /* Sub format DWVW does not allow seeking. */ | |
468 if ((format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_16 || | |
469 (format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_24) | |
470 { unlink (filename) ; | |
471 printf ("no seek : ok\n") ; | |
472 return ; | |
473 } ; | |
474 | |
475 if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC | |
476 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_16 | |
477 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_20 | |
478 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_24 | |
479 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_32 | |
480 ) | |
481 mono_rdwr_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; | |
482 | |
483 /* If the format doesn't support stereo we're done. */ | |
484 sfinfo.channels = 2 ; | |
485 if (sf_format_check (&sfinfo) == 0) | |
486 { unlink (filename) ; | |
487 puts ("no stereo : ok") ; | |
488 return ; | |
489 } ; | |
490 | |
491 stereo_[+ (get "type_name") +]_test (filename, format, long_file_ok, allow_fd) ; | |
492 | |
493 /* New read/write test. Not sure if this is needed yet. */ | |
494 | |
495 if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PAF | |
496 && (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_VOC | |
497 && (format & SF_FORMAT_TYPEMASK) != SF_FORMAT_FLAC | |
498 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_16 | |
499 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_20 | |
500 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_24 | |
501 && (format & SF_FORMAT_SUBMASK) != SF_FORMAT_ALAC_32 | |
502 ) | |
503 new_rdwr_[+ (get "type_name") +]_test (filename, format, allow_fd) ; | |
504 | |
505 delete_file (format, filename) ; | |
506 | |
507 puts ("ok") ; | |
508 return ; | |
509 } /* pcm_test_[+ (get "type_name") +] */ | |
510 | |
511 static void | |
512 mono_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) | |
513 { SNDFILE *file ; | |
514 SF_INFO sfinfo ; | |
515 [+ (get "data_type") +] *orig, *test ; | |
516 sf_count_t count ; | |
517 int k, items, total ; | |
518 | |
519 sfinfo.samplerate = 44100 ; | |
520 sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ | |
521 sfinfo.channels = 1 ; | |
522 sfinfo.format = format ; | |
523 | |
524 orig = orig_data.[+ (get "data_field") +] ; | |
525 test = test_data.[+ (get "data_field") +] ; | |
526 | |
527 items = DATA_LENGTH ; | |
528 | |
529 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; | |
530 | |
531 if (sfinfo.frames || sfinfo.sections || sfinfo.seekable) | |
532 { printf ("\n\nLine %d : Weird SF_INFO fields.\n", __LINE__) ; | |
533 exit (1) ; | |
534 } ; | |
535 | |
536 sf_set_string (file, SF_STR_ARTIST, "Your name here") ; | |
537 | |
538 test_write_[+ (get "data_type") +]_or_die (file, 0, orig, items, __LINE__) ; | |
539 sf_write_sync (file) ; | |
540 test_write_[+ (get "data_type") +]_or_die (file, 0, orig, items, __LINE__) ; | |
541 sf_write_sync (file) ; | |
542 | |
543 /* Add non-audio data after the audio. */ | |
544 sf_set_string (file, SF_STR_COPYRIGHT, "Copyright (c) 2003") ; | |
545 | |
546 sf_close (file) ; | |
547 | |
548 memset (test, 0, items * sizeof ([+ (get "data_type") +])) ; | |
549 | |
550 if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) | |
551 memset (&sfinfo, 0, sizeof (sfinfo)) ; | |
552 | |
553 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; | |
554 | |
555 if (sfinfo.format != format) | |
556 { printf ("\n\nLine %d : Mono : Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, format, sfinfo.format) ; | |
557 exit (1) ; | |
558 } ; | |
559 | |
560 if (sfinfo.frames < 2 * items) | |
561 { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, items) ; | |
562 exit (1) ; | |
563 } ; | |
564 | |
565 if (! long_file_ok && sfinfo.frames > 2 * items) | |
566 { printf ("\n\nLine %d : Mono : Incorrect number of frames in file (too long). (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, items) ; | |
567 exit (1) ; | |
568 } ; | |
569 | |
570 if (sfinfo.channels != 1) | |
571 { printf ("\n\nLine %d : Mono : Incorrect number of channels in file.\n", __LINE__) ; | |
572 exit (1) ; | |
573 } ; | |
574 | |
575 if (sfinfo.seekable != 1) | |
576 { printf ("\n\nLine %d : File should be seekable.\n", __LINE__) ; | |
577 exit (1) ; | |
578 } ; | |
579 | |
580 check_log_buffer_or_die (file, __LINE__) ; | |
581 | |
582 test_read_[+ (get "data_type") +]_or_die (file, 0, test, items, __LINE__) ; | |
583 for (k = 0 ; k < items ; k++) | |
584 if ([+ (get "error_func") +] (orig [k], test [k])) | |
585 { printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; | |
586 oct_save_[+ (get "data_type") +] (orig, test, items) ; | |
587 exit (1) ; | |
588 } ; | |
589 | |
590 /* Test multiple short reads. */ | |
591 test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; | |
592 | |
593 total = 0 ; | |
594 for (k = 1 ; k <= 32 ; k++) | |
595 { int ik ; | |
596 | |
597 test_read_[+ (get "data_type") +]_or_die (file, 0, test + total, k, __LINE__) ; | |
598 total += k ; | |
599 | |
600 for (ik = 0 ; ik < total ; ik++) | |
601 if ([+ (get "error_func") +] (orig [ik], test [ik])) | |
602 { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, ik, orig [ik], test [ik]) ; | |
603 exit (1) ; | |
604 } ; | |
605 } ; | |
606 | |
607 /* Seek to start of file. */ | |
608 test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; | |
609 | |
610 test_read_[+ (get "data_type") +]_or_die (file, 0, test, 4, __LINE__) ; | |
611 for (k = 0 ; k < 4 ; k++) | |
612 if ([+ (get "error_func") +] (orig [k], test [k])) | |
613 { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; | |
614 exit (1) ; | |
615 } ; | |
616 | |
617 /* For some codecs we can't go past here. */ | |
618 if ((format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_16 || | |
619 (format & SF_FORMAT_SUBMASK) == SF_FORMAT_DWVW_24) | |
620 { sf_close (file) ; | |
621 unlink (filename) ; | |
622 printf ("no seek : ") ; | |
623 return ; | |
624 } ; | |
625 | |
626 /* Seek to offset from start of file. */ | |
627 test_seek_or_die (file, items + 10, SEEK_SET, items + 10, sfinfo.channels, __LINE__) ; | |
628 | |
629 test_read_[+ (get "data_type") +]_or_die (file, 0, test + 10, 4, __LINE__) ; | |
630 for (k = 10 ; k < 14 ; k++) | |
631 if ([+ (get "error_func") +] (orig [k], test [k])) | |
632 { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, test [k], orig [k]) ; | |
633 exit (1) ; | |
634 } ; | |
635 | |
636 /* Seek to offset from current position. */ | |
637 test_seek_or_die (file, 6, SEEK_CUR, items + 20, sfinfo.channels, __LINE__) ; | |
638 | |
639 test_read_[+ (get "data_type") +]_or_die (file, 0, test + 20, 4, __LINE__) ; | |
640 for (k = 20 ; k < 24 ; k++) | |
641 if ([+ (get "error_func") +] (orig [k], test [k])) | |
642 { printf ("\n\nLine %d : Mono : Incorrect sample A (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, test [k], orig [k]) ; | |
643 exit (1) ; | |
644 } ; | |
645 | |
646 /* Seek to offset from end of file. */ | |
647 test_seek_or_die (file, -1 * (sfinfo.frames - 10), SEEK_END, 10, sfinfo.channels, __LINE__) ; | |
648 | |
649 test_read_[+ (get "data_type") +]_or_die (file, 0, test + 10, 4, __LINE__) ; | |
650 for (k = 10 ; k < 14 ; k++) | |
651 if ([+ (get "error_func") +] (orig [k], test [k])) | |
652 { printf ("\n\nLine %d : Mono : Incorrect sample D (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, test [k], orig [k]) ; | |
653 exit (1) ; | |
654 } ; | |
655 | |
656 /* Check read past end of file followed by sf_seek (sndfile, 0, SEEK_CUR). */ | |
657 test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; | |
658 | |
659 count = 0 ; | |
660 while (count < sfinfo.frames) | |
661 count += sf_read_[+ (get "data_type") +] (file, test, 311) ; | |
662 | |
663 /* Check that no error has occurred. */ | |
664 if (sf_error (file)) | |
665 { printf ("\n\nLine %d : Mono : error where there shouldn't have been one.\n", __LINE__) ; | |
666 puts (sf_strerror (file)) ; | |
667 exit (1) ; | |
668 } ; | |
669 | |
670 /* Check that we haven't read beyond EOF. */ | |
671 if (count > sfinfo.frames) | |
672 { printf ("\n\nLines %d : read past end of file (%" PRId64 " should be %" PRId64 ")\n", __LINE__, count, sfinfo.frames) ; | |
673 exit (1) ; | |
674 } ; | |
675 | |
676 test_seek_or_die (file, 0, SEEK_CUR, sfinfo.frames, sfinfo.channels, __LINE__) ; | |
677 | |
678 sf_close (file) ; | |
679 | |
680 multi_seek_test (filename, format) ; | |
681 write_seek_extend_test (filename, format) ; | |
682 | |
683 } /* mono_[+ (get "type_name") +]_test */ | |
684 | |
685 static void | |
686 stereo_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) | |
687 { SNDFILE *file ; | |
688 SF_INFO sfinfo ; | |
689 [+ (get "data_type") +] *orig, *test ; | |
690 int k, items, frames ; | |
691 | |
692 sfinfo.samplerate = 44100 ; | |
693 sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ | |
694 sfinfo.channels = 2 ; | |
695 sfinfo.format = format ; | |
696 | |
697 gen_windowed_sine_double (orig_data.d, DATA_LENGTH, [+ (get "max_val") +]) ; | |
698 | |
699 orig = orig_data.[+ (get "data_field") +] ; | |
700 test = test_data.[+ (get "data_field") +] ; | |
701 | |
702 /* Make this a macro so gdb steps over it in one go. */ | |
703 CONVERT_DATA (k, DATA_LENGTH, orig, orig_data.d) ; | |
704 | |
705 items = DATA_LENGTH ; | |
706 frames = items / sfinfo.channels ; | |
707 | |
708 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; | |
709 | |
710 sf_set_string (file, SF_STR_ARTIST, "Your name here") ; | |
711 | |
712 test_writef_[+ (get "data_type") +]_or_die (file, 0, orig, frames, __LINE__) ; | |
713 | |
714 sf_set_string (file, SF_STR_COPYRIGHT, "Copyright (c) 2003") ; | |
715 | |
716 sf_close (file) ; | |
717 | |
718 memset (test, 0, items * sizeof ([+ (get "data_type") +])) ; | |
719 | |
720 if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_RAW) | |
721 memset (&sfinfo, 0, sizeof (sfinfo)) ; | |
722 | |
723 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, allow_fd, __LINE__) ; | |
724 | |
725 if (sfinfo.format != format) | |
726 { printf ("\n\nLine %d : Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", | |
727 __LINE__, format, sfinfo.format) ; | |
728 exit (1) ; | |
729 } ; | |
730 | |
731 if (sfinfo.frames < frames) | |
732 { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too short). (%" PRId64 " should be %d)\n", | |
733 __LINE__, sfinfo.frames, frames) ; | |
734 exit (1) ; | |
735 } ; | |
736 | |
737 if (! long_file_ok && sfinfo.frames > frames) | |
738 { printf ("\n\nLine %d : Stereo : Incorrect number of frames in file (too long). (%" PRId64 " should be %d)\n", | |
739 __LINE__, sfinfo.frames, frames) ; | |
740 exit (1) ; | |
741 } ; | |
742 | |
743 if (sfinfo.channels != 2) | |
744 { printf ("\n\nLine %d : Stereo : Incorrect number of channels in file.\n", __LINE__) ; | |
745 exit (1) ; | |
746 } ; | |
747 | |
748 check_log_buffer_or_die (file, __LINE__) ; | |
749 | |
750 test_readf_[+ (get "data_type") +]_or_die (file, 0, test, frames, __LINE__) ; | |
751 for (k = 0 ; k < items ; k++) | |
752 if ([+ (get "error_func") +] (test [k], orig [k])) | |
753 { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; | |
754 exit (1) ; | |
755 } ; | |
756 | |
757 /* Seek to start of file. */ | |
758 test_seek_or_die (file, 0, SEEK_SET, 0, sfinfo.channels, __LINE__) ; | |
759 | |
760 test_readf_[+ (get "data_type") +]_or_die (file, 0, test, 2, __LINE__) ; | |
761 for (k = 0 ; k < 4 ; k++) | |
762 if ([+ (get "error_func") +] (test [k], orig [k])) | |
763 { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; | |
764 exit (1) ; | |
765 } ; | |
766 | |
767 /* Seek to offset from start of file. */ | |
768 test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; | |
769 | |
770 /* Check for errors here. */ | |
771 if (sf_error (file)) | |
772 { printf ("Line %d: Should NOT return an error.\n", __LINE__) ; | |
773 puts (sf_strerror (file)) ; | |
774 exit (1) ; | |
775 } ; | |
776 | |
777 if (sf_read_[+ (get "data_type") +] (file, test, 1) > 0) | |
778 { printf ("Line %d: Should return 0.\n", __LINE__) ; | |
779 exit (1) ; | |
780 } ; | |
781 | |
782 if (! sf_error (file)) | |
783 { printf ("Line %d: Should return an error.\n", __LINE__) ; | |
784 exit (1) ; | |
785 } ; | |
786 /*-----------------------*/ | |
787 | |
788 test_readf_[+ (get "data_type") +]_or_die (file, 0, test + 10, 2, __LINE__) ; | |
789 for (k = 20 ; k < 24 ; k++) | |
790 if ([+ (get "error_func") +] (test [k], orig [k])) | |
791 { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; | |
792 exit (1) ; | |
793 } ; | |
794 | |
795 /* Seek to offset from current position. */ | |
796 test_seek_or_die (file, 8, SEEK_CUR, 20, sfinfo.channels, __LINE__) ; | |
797 | |
798 test_readf_[+ (get "data_type") +]_or_die (file, 0, test + 20, 2, __LINE__) ; | |
799 for (k = 40 ; k < 44 ; k++) | |
800 if ([+ (get "error_func") +] (test [k], orig [k])) | |
801 { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; | |
802 exit (1) ; | |
803 } ; | |
804 | |
805 /* Seek to offset from end of file. */ | |
806 test_seek_or_die (file, -1 * (sfinfo.frames - 10), SEEK_END, 10, sfinfo.channels, __LINE__) ; | |
807 | |
808 test_readf_[+ (get "data_type") +]_or_die (file, 0, test + 20, 2, __LINE__) ; | |
809 for (k = 20 ; k < 24 ; k++) | |
810 if ([+ (get "error_func") +] (test [k], orig [k])) | |
811 { printf ("\n\nLine %d : Stereo : Incorrect sample (#%d : [+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, k, orig [k], test [k]) ; | |
812 exit (1) ; | |
813 } ; | |
814 | |
815 sf_close (file) ; | |
816 } /* stereo_[+ (get "type_name") +]_test */ | |
817 | |
818 static void | |
819 mono_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int long_file_ok, int allow_fd) | |
820 { SNDFILE *file ; | |
821 SF_INFO sfinfo ; | |
822 [+ (get "data_type") +] *orig, *test ; | |
823 int k, pass ; | |
824 | |
825 switch (format & SF_FORMAT_SUBMASK) | |
826 { case SF_FORMAT_ALAC_16 : | |
827 case SF_FORMAT_ALAC_20 : | |
828 case SF_FORMAT_ALAC_24 : | |
829 case SF_FORMAT_ALAC_32 : | |
830 allow_fd = 0 ; | |
831 break ; | |
832 | |
833 default : | |
834 break ; | |
835 } ; | |
836 | |
837 orig = orig_data.[+ (get "data_field") +] ; | |
838 test = test_data.[+ (get "data_field") +] ; | |
839 | |
840 sfinfo.samplerate = SAMPLE_RATE ; | |
841 sfinfo.frames = DATA_LENGTH ; | |
842 sfinfo.channels = 1 ; | |
843 sfinfo.format = format ; | |
844 | |
845 if ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW | |
846 || (format & SF_FORMAT_TYPEMASK) == SF_FORMAT_AU | |
847 || (format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) | |
848 unlink (filename) ; | |
849 else | |
850 { /* Create a short file. */ | |
851 create_short_file (filename) ; | |
852 | |
853 /* Opening a already existing short file (ie invalid header) RDWR is disallowed. | |
854 ** If this returns a valif pointer sf_open() screwed up. | |
855 */ | |
856 if ((file = sf_open (filename, SFM_RDWR, &sfinfo))) | |
857 { printf ("\n\nLine %d: sf_open should (SFM_RDWR) have failed but didn't.\n", __LINE__) ; | |
858 exit (1) ; | |
859 } ; | |
860 | |
861 /* Truncate the file to zero bytes. */ | |
862 if (truncate (filename, 0) < 0) | |
863 { printf ("\n\nLine %d: truncate (%s) failed", __LINE__, filename) ; | |
864 perror (NULL) ; | |
865 exit (1) ; | |
866 } ; | |
867 } ; | |
868 | |
869 /* Opening a zero length file RDWR is allowed, but the SF_INFO struct must contain | |
870 ** all the usual data required when opening the file in WRITE mode. | |
871 */ | |
872 sfinfo.samplerate = SAMPLE_RATE ; | |
873 sfinfo.frames = DATA_LENGTH ; | |
874 sfinfo.channels = 1 ; | |
875 sfinfo.format = format ; | |
876 | |
877 file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ; | |
878 | |
879 /* Do 3 writes followed by reads. After each, check the data and the current | |
880 ** read and write offsets. | |
881 */ | |
882 for (pass = 1 ; pass <= 3 ; pass ++) | |
883 { orig [20] = pass * 2 ; | |
884 | |
885 /* Write some data. */ | |
886 test_write_[+ (get "data_type") +]_or_die (file, pass, orig, DATA_LENGTH, __LINE__) ; | |
887 | |
888 test_read_write_position_or_die (file, __LINE__, pass, (pass - 1) * DATA_LENGTH, pass * DATA_LENGTH) ; | |
889 | |
890 /* Read what we just wrote. */ | |
891 test_read_[+ (get "data_type") +]_or_die (file, 0, test, DATA_LENGTH, __LINE__) ; | |
892 | |
893 /* Check the data. */ | |
894 for (k = 0 ; k < DATA_LENGTH ; k++) | |
895 if ([+ (get "error_func") +] (orig [k], test [k])) | |
896 { printf ("\n\nLine %d (pass %d) A : Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ; | |
897 oct_save_[+ (get "data_type") +] (orig, test, DATA_LENGTH) ; | |
898 exit (1) ; | |
899 } ; | |
900 | |
901 test_read_write_position_or_die (file, __LINE__, pass, pass * DATA_LENGTH, pass * DATA_LENGTH) ; | |
902 } ; /* for (pass ...) */ | |
903 | |
904 sf_close (file) ; | |
905 | |
906 /* Open the file again to check the data. */ | |
907 file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ; | |
908 | |
909 if (sfinfo.format != format) | |
910 { printf ("\n\nLine %d : Returned format incorrect (0x%08X => 0x%08X).\n", __LINE__, format, sfinfo.format) ; | |
911 exit (1) ; | |
912 } ; | |
913 | |
914 if (sfinfo.frames < 3 * DATA_LENGTH) | |
915 { printf ("\n\nLine %d : Not enough frames in file. (%" PRId64 " < %d)\n", __LINE__, sfinfo.frames, 3 * DATA_LENGTH) ; | |
916 exit (1) ; | |
917 } | |
918 | |
919 if (! long_file_ok && sfinfo.frames != 3 * DATA_LENGTH) | |
920 { printf ("\n\nLine %d : Incorrect number of frames in file. (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, 3 * DATA_LENGTH) ; | |
921 exit (1) ; | |
922 } ; | |
923 | |
924 if (sfinfo.channels != 1) | |
925 { printf ("\n\nLine %d : Incorrect number of channels in file.\n", __LINE__) ; | |
926 exit (1) ; | |
927 } ; | |
928 | |
929 if (! long_file_ok) | |
930 test_read_write_position_or_die (file, __LINE__, 0, 0, 3 * DATA_LENGTH) ; | |
931 else | |
932 test_seek_or_die (file, 3 * DATA_LENGTH, SFM_WRITE | SEEK_SET, 3 * DATA_LENGTH, sfinfo.channels, __LINE__) ; | |
933 | |
934 for (pass = 1 ; pass <= 3 ; pass ++) | |
935 { orig [20] = pass * 2 ; | |
936 | |
937 test_read_write_position_or_die (file, __LINE__, pass, (pass - 1) * DATA_LENGTH, 3 * DATA_LENGTH) ; | |
938 | |
939 /* Read what we just wrote. */ | |
940 test_read_[+ (get "data_type") +]_or_die (file, pass, test, DATA_LENGTH, __LINE__) ; | |
941 | |
942 /* Check the data. */ | |
943 for (k = 0 ; k < DATA_LENGTH ; k++) | |
944 if ([+ (get "error_func") +] (orig [k], test [k])) | |
945 { printf ("\n\nLine %d (pass %d) B : Error at sample %d ([+ (get "format_char") +] => [+ (get "format_char") +]).\n", __LINE__, pass, k, orig [k], test [k]) ; | |
946 oct_save_[+ (get "data_type") +] (orig, test, DATA_LENGTH) ; | |
947 exit (1) ; | |
948 } ; | |
949 | |
950 } ; /* for (pass ...) */ | |
951 | |
952 sf_close (file) ; | |
953 } /* mono_rdwr_[+ (get "data_type") +]_test */ | |
954 | |
955 static void | |
956 new_rdwr_[+ (get "type_name") +]_test (const char *filename, int format, int allow_fd) | |
957 { SNDFILE *wfile, *rwfile ; | |
958 SF_INFO sfinfo ; | |
959 [+ (get "data_type") +] *orig, *test ; | |
960 int items, frames ; | |
961 | |
962 orig = orig_data.[+ (get "data_field") +] ; | |
963 test = test_data.[+ (get "data_field") +] ; | |
964 | |
965 sfinfo.samplerate = 44100 ; | |
966 sfinfo.frames = SILLY_WRITE_COUNT ; /* Wrong length. Library should correct this on sf_close. */ | |
967 sfinfo.channels = 2 ; | |
968 sfinfo.format = format ; | |
969 | |
970 items = DATA_LENGTH ; | |
971 frames = items / sfinfo.channels ; | |
972 | |
973 wfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, allow_fd, __LINE__) ; | |
974 sf_command (wfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) ; | |
975 test_writef_[+ (get "data_type") +]_or_die (wfile, 1, orig, frames, __LINE__) ; | |
976 sf_write_sync (wfile) ; | |
977 test_writef_[+ (get "data_type") +]_or_die (wfile, 2, orig, frames, __LINE__) ; | |
978 sf_write_sync (wfile) ; | |
979 | |
980 rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ; | |
981 if (sfinfo.frames != 2 * frames) | |
982 { printf ("\n\nLine %d : incorrect number of frames in file (%" PRId64 " should be %d)\n\n", __LINE__, sfinfo.frames, 2 * frames) ; | |
983 exit (1) ; | |
984 } ; | |
985 | |
986 test_writef_[+ (get "data_type") +]_or_die (wfile, 3, orig, frames, __LINE__) ; | |
987 | |
988 test_readf_[+ (get "data_type") +]_or_die (rwfile, 1, test, frames, __LINE__) ; | |
989 test_readf_[+ (get "data_type") +]_or_die (rwfile, 2, test, frames, __LINE__) ; | |
990 | |
991 sf_close (wfile) ; | |
992 sf_close (rwfile) ; | |
993 } /* new_rdwr_[+ (get "type_name") +]_test */ | |
994 | |
995 [+ ENDFOR data_type +] | |
996 | |
997 /*---------------------------------------------------------------------------------------- | |
998 */ | |
999 | |
1000 static void | |
1001 empty_file_test (const char *filename, int format) | |
1002 { SNDFILE *file ; | |
1003 SF_INFO info ; | |
1004 int allow_fd ; | |
1005 | |
1006 /* Sd2 files cannot be opened from an existing file descriptor. */ | |
1007 allow_fd = ((format & SF_FORMAT_TYPEMASK) == SF_FORMAT_SD2) ? SF_FALSE : SF_TRUE ; | |
1008 | |
1009 print_test_name ("empty_file_test", filename) ; | |
1010 | |
1011 unlink (filename) ; | |
1012 | |
1013 info.samplerate = 48000 ; | |
1014 info.channels = 2 ; | |
1015 info.format = format ; | |
1016 info.frames = 0 ; | |
1017 | |
1018 if (sf_format_check (&info) == SF_FALSE) | |
1019 { info.channels = 1 ; | |
1020 if (sf_format_check (&info) == SF_FALSE) | |
1021 { puts ("invalid file format") ; | |
1022 return ; | |
1023 } ; | |
1024 } ; | |
1025 | |
1026 /* Create an empty file. */ | |
1027 file = test_open_file_or_die (filename, SFM_WRITE, &info, allow_fd, __LINE__) ; | |
1028 sf_close (file) ; | |
1029 | |
1030 /* Open for read and check the length. */ | |
1031 file = test_open_file_or_die (filename, SFM_READ, &info, allow_fd, __LINE__) ; | |
1032 | |
1033 if (info.frames != 0) | |
1034 { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; | |
1035 exit (1) ; | |
1036 } ; | |
1037 | |
1038 sf_close (file) ; | |
1039 | |
1040 /* Open for read/write and check the length. */ | |
1041 file = test_open_file_or_die (filename, SFM_RDWR, &info, allow_fd, __LINE__) ; | |
1042 | |
1043 if (info.frames != 0) | |
1044 { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; | |
1045 exit (1) ; | |
1046 } ; | |
1047 | |
1048 sf_close (file) ; | |
1049 | |
1050 /* Open for read and check the length. */ | |
1051 file = test_open_file_or_die (filename, SFM_READ, &info, allow_fd, __LINE__) ; | |
1052 | |
1053 if (info.frames != 0) | |
1054 { printf ("\n\nError : frame count (%" PRId64 ") should be zero.\n", info.frames) ; | |
1055 exit (1) ; | |
1056 } ; | |
1057 | |
1058 sf_close (file) ; | |
1059 | |
1060 check_open_file_count_or_die (__LINE__) ; | |
1061 | |
1062 unlink (filename) ; | |
1063 puts ("ok") ; | |
1064 | |
1065 return ; | |
1066 } /* empty_file_test */ | |
1067 | |
1068 | |
1069 /*---------------------------------------------------------------------------------------- | |
1070 */ | |
1071 | |
1072 static void | |
1073 create_short_file (const char *filename) | |
1074 { FILE *file ; | |
1075 | |
1076 if (! (file = fopen (filename, "w"))) | |
1077 { printf ("create_short_file : fopen (%s, \"w\") failed.", filename) ; | |
1078 fflush (stdout) ; | |
1079 perror (NULL) ; | |
1080 exit (1) ; | |
1081 } ; | |
1082 | |
1083 fprintf (file, "This is the file data.\n") ; | |
1084 | |
1085 fclose (file) ; | |
1086 } /* create_short_file */ | |
1087 | |
1088 | |
1089 static void | |
1090 multi_seek_test (const char * filename, int format) | |
1091 { SNDFILE * file ; | |
1092 SF_INFO info ; | |
1093 sf_count_t pos ; | |
1094 int k ; | |
1095 | |
1096 /* This test doesn't work on the following. */ | |
1097 switch (format & SF_FORMAT_TYPEMASK) | |
1098 { case SF_FORMAT_RAW : | |
1099 return ; | |
1100 | |
1101 default : | |
1102 break ; | |
1103 } ; | |
1104 | |
1105 memset (&info, 0, sizeof (info)) ; | |
1106 | |
1107 generate_file (filename, format, 88200) ; | |
1108 | |
1109 file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ; | |
1110 | |
1111 for (k = 0 ; k < 10 ; k++) | |
1112 { pos = info.frames / (k + 2) ; | |
1113 test_seek_or_die (file, pos, SEEK_SET, pos, info.channels, __LINE__) ; | |
1114 } ; | |
1115 | |
1116 sf_close (file) ; | |
1117 } /* multi_seek_test */ | |
1118 | |
1119 static void | |
1120 write_seek_extend_test (const char * filename, int format) | |
1121 { SNDFILE * file ; | |
1122 SF_INFO info ; | |
1123 short *orig, *test ; | |
1124 unsigned items, k ; | |
1125 | |
1126 /* This test doesn't work on the following container formats. */ | |
1127 switch (format & SF_FORMAT_TYPEMASK) | |
1128 { case SF_FORMAT_FLAC : | |
1129 case SF_FORMAT_HTK : | |
1130 case SF_FORMAT_PAF : | |
1131 case SF_FORMAT_SDS : | |
1132 case SF_FORMAT_SVX : | |
1133 return ; | |
1134 | |
1135 default : | |
1136 break ; | |
1137 } ; | |
1138 | |
1139 /* This test doesn't work on the following codec formats. */ | |
1140 switch (format & SF_FORMAT_SUBMASK) | |
1141 { case SF_FORMAT_ALAC_16 : | |
1142 case SF_FORMAT_ALAC_20 : | |
1143 case SF_FORMAT_ALAC_24 : | |
1144 case SF_FORMAT_ALAC_32 : | |
1145 return ; | |
1146 | |
1147 default : | |
1148 break ; | |
1149 } ; | |
1150 | |
1151 memset (&info, 0, sizeof (info)) ; | |
1152 | |
1153 info.samplerate = 48000 ; | |
1154 info.channels = 1 ; | |
1155 info.format = format ; | |
1156 | |
1157 items = 512 ; | |
1158 exit_if_true (items > ARRAY_LEN (orig_data.s), "Line %d : Bad assumption.\n", __LINE__) ; | |
1159 | |
1160 orig = orig_data.s ; | |
1161 test = test_data.s ; | |
1162 | |
1163 for (k = 0 ; k < ARRAY_LEN (orig_data.s) ; k++) | |
1164 orig [k] = 0x3fff ; | |
1165 | |
1166 file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_FALSE, __LINE__) ; | |
1167 test_write_short_or_die (file, 0, orig, items, __LINE__) ; | |
1168 | |
1169 /* Extend the file using a seek. */ | |
1170 test_seek_or_die (file, 2 * items, SEEK_SET, 2 * items, info.channels, __LINE__) ; | |
1171 | |
1172 test_writef_short_or_die (file, 0, orig, items, __LINE__) ; | |
1173 sf_close (file) ; | |
1174 | |
1175 file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ; | |
1176 test_read_short_or_die (file, 0, test, 3 * items, __LINE__) ; | |
1177 sf_close (file) ; | |
1178 | |
1179 /* Can't do these formats due to scaling. */ | |
1180 switch (format & SF_FORMAT_SUBMASK) | |
1181 { case SF_FORMAT_PCM_S8 : | |
1182 case SF_FORMAT_PCM_U8 : | |
1183 return ; | |
1184 default : | |
1185 break ; | |
1186 } ; | |
1187 | |
1188 for (k = 0 ; k < items ; k++) | |
1189 { exit_if_true (test [k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, k, test [k]) ; | |
1190 exit_if_true (test [items + k] != 0, "Line %d : test [%d] == %d, should be 0.\n", __LINE__, items + k, test [items + k]) ; | |
1191 exit_if_true (test [2 * items + k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, 2 * items + k, test [2 * items + k]) ; | |
1192 } ; | |
1193 | |
1194 return ; | |
1195 } /* write_seek_extend_test */ | |
1196 | |
1197 |