Disable executable stack in libFLAC.so.
[flac.git] / src / test_libFLAC / encoders.c
1 /* test_libFLAC - Unit tester for libFLAC
2  * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #if HAVE_CONFIG_H
20 #  include <config.h>
21 #endif
22
23 #include <errno.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include "encoders.h"
28 #include "FLAC/assert.h"
29 #include "FLAC/stream_encoder.h"
30 #include "share/grabbag.h"
31 #include "share/compat.h"
32 #include "test_libs_common/file_utils_flac.h"
33 #include "test_libs_common/metadata_utils.h"
34
35 typedef enum {
36         LAYER_STREAM = 0, /* FLAC__stream_encoder_init_[ogg_]stream() without seeking */
37         LAYER_SEEKABLE_STREAM, /* FLAC__stream_encoder_init_[ogg_]stream() with seeking */
38         LAYER_FILE, /* FLAC__stream_encoder_init_[ogg_]FILE() */
39         LAYER_FILENAME /* FLAC__stream_encoder_init_[ogg_]file() */
40 } Layer;
41
42 static const char * const LayerString[] = {
43         "Stream",
44         "Seekable Stream",
45         "FILE*",
46         "Filename"
47 };
48
49 static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_;
50 static FLAC__StreamMetadata *metadata_sequence_[] = { &vorbiscomment_, &padding_, &seektable_, &application1_, &application2_, &cuesheet_, &picture_, &unknown_ };
51 static const unsigned num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]);
52
53 static const char *flacfilename(FLAC__bool is_ogg)
54 {
55         return is_ogg? "metadata.oga" : "metadata.flac";
56 }
57
58 static FLAC__bool die_(const char *msg)
59 {
60         printf("ERROR: %s\n", msg);
61         return false;
62 }
63
64 static FLAC__bool die_s_(const char *msg, const FLAC__StreamEncoder *encoder)
65 {
66         FLAC__StreamEncoderState state = FLAC__stream_encoder_get_state(encoder);
67
68         if(msg)
69                 printf("FAILED, %s", msg);
70         else
71                 printf("FAILED");
72
73         printf(", state = %u (%s)\n", (unsigned)state, FLAC__StreamEncoderStateString[state]);
74         if(state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) {
75                 FLAC__StreamDecoderState dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder);
76                 printf("      verify decoder state = %u (%s)\n", (unsigned)dstate, FLAC__StreamDecoderStateString[dstate]);
77         }
78
79         return false;
80 }
81
82 static void init_metadata_blocks_(void)
83 {
84         mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_);
85 }
86
87 static void free_metadata_blocks_(void)
88 {
89         mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_);
90 }
91
92 static FLAC__StreamEncoderReadStatus stream_encoder_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
93 {
94         FILE *f = (FILE*)client_data;
95         (void)encoder;
96         if(*bytes > 0) {
97                 *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, f);
98                 if(ferror(f))
99                         return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
100                 else if(*bytes == 0)
101                         return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM;
102                 else
103                         return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE;
104         }
105         else
106                 return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
107 }
108
109 static FLAC__StreamEncoderWriteStatus stream_encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data)
110 {
111         FILE *f = (FILE*)client_data;
112         (void)encoder, (void)samples, (void)current_frame;
113         if(fwrite(buffer, 1, bytes, f) != bytes)
114                 return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
115         else
116                 return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
117 }
118
119 static FLAC__StreamEncoderSeekStatus stream_encoder_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data)
120 {
121         FILE *f = (FILE*)client_data;
122         (void)encoder;
123         if(fseek(f, (long)absolute_byte_offset, SEEK_SET) < 0)
124                 return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
125         else
126                 return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
127 }
128
129 static FLAC__StreamEncoderTellStatus stream_encoder_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
130 {
131         FILE *f = (FILE*)client_data;
132         long pos;
133         (void)encoder;
134         if((pos = ftell(f)) < 0)
135                 return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
136         else {
137                 *absolute_byte_offset = (FLAC__uint64)pos;
138                 return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
139         }
140 }
141
142 static void stream_encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data)
143 {
144         (void)encoder, (void)metadata, (void)client_data;
145 }
146
147 static void stream_encoder_progress_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data)
148 {
149         (void)encoder, (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate, (void)client_data;
150 }
151
152 static FLAC__bool test_stream_encoder(Layer layer, FLAC__bool is_ogg)
153 {
154         FLAC__StreamEncoder *encoder;
155         FLAC__StreamEncoderInitStatus init_status;
156         FLAC__StreamEncoderState state;
157         FLAC__StreamDecoderState dstate;
158         FILE *file = 0;
159         FLAC__int32 samples[1024];
160         FLAC__int32 *samples_array[1];
161         unsigned i;
162
163         samples_array[0] = samples;
164
165         printf("\n+++ libFLAC unit test: FLAC__StreamEncoder (layer: %s, format: %s)\n\n", LayerString[layer], is_ogg? "Ogg FLAC":"FLAC");
166
167         printf("testing FLAC__stream_encoder_new()... ");
168         encoder = FLAC__stream_encoder_new();
169         if(0 == encoder) {
170                 printf("FAILED, returned NULL\n");
171                 return false;
172         }
173         printf("OK\n");
174
175         if(is_ogg) {
176                 printf("testing FLAC__stream_encoder_set_ogg_serial_number()... ");
177                 if(!FLAC__stream_encoder_set_ogg_serial_number(encoder, file_utils__ogg_serial_number))
178                         return die_s_("returned false", encoder);
179                 printf("OK\n");
180         }
181
182         printf("testing FLAC__stream_encoder_set_verify()... ");
183         if(!FLAC__stream_encoder_set_verify(encoder, true))
184                 return die_s_("returned false", encoder);
185         printf("OK\n");
186
187         printf("testing FLAC__stream_encoder_set_streamable_subset()... ");
188         if(!FLAC__stream_encoder_set_streamable_subset(encoder, true))
189                 return die_s_("returned false", encoder);
190         printf("OK\n");
191
192         printf("testing FLAC__stream_encoder_set_channels()... ");
193         if(!FLAC__stream_encoder_set_channels(encoder, streaminfo_.data.stream_info.channels))
194                 return die_s_("returned false", encoder);
195         printf("OK\n");
196
197         printf("testing FLAC__stream_encoder_set_bits_per_sample()... ");
198         if(!FLAC__stream_encoder_set_bits_per_sample(encoder, streaminfo_.data.stream_info.bits_per_sample))
199                 return die_s_("returned false", encoder);
200         printf("OK\n");
201
202         printf("testing FLAC__stream_encoder_set_sample_rate()... ");
203         if(!FLAC__stream_encoder_set_sample_rate(encoder, streaminfo_.data.stream_info.sample_rate))
204                 return die_s_("returned false", encoder);
205         printf("OK\n");
206
207         printf("testing FLAC__stream_encoder_set_compression_level()... ");
208         if(!FLAC__stream_encoder_set_compression_level(encoder, (unsigned)(-1)))
209                 return die_s_("returned false", encoder);
210         printf("OK\n");
211
212         printf("testing FLAC__stream_encoder_set_blocksize()... ");
213         if(!FLAC__stream_encoder_set_blocksize(encoder, streaminfo_.data.stream_info.min_blocksize))
214                 return die_s_("returned false", encoder);
215         printf("OK\n");
216
217         printf("testing FLAC__stream_encoder_set_do_mid_side_stereo()... ");
218         if(!FLAC__stream_encoder_set_do_mid_side_stereo(encoder, false))
219                 return die_s_("returned false", encoder);
220         printf("OK\n");
221
222         printf("testing FLAC__stream_encoder_set_loose_mid_side_stereo()... ");
223         if(!FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, false))
224                 return die_s_("returned false", encoder);
225         printf("OK\n");
226
227         printf("testing FLAC__stream_encoder_set_max_lpc_order()... ");
228         if(!FLAC__stream_encoder_set_max_lpc_order(encoder, 0))
229                 return die_s_("returned false", encoder);
230         printf("OK\n");
231
232         printf("testing FLAC__stream_encoder_set_qlp_coeff_precision()... ");
233         if(!FLAC__stream_encoder_set_qlp_coeff_precision(encoder, 0))
234                 return die_s_("returned false", encoder);
235         printf("OK\n");
236
237         printf("testing FLAC__stream_encoder_set_do_qlp_coeff_prec_search()... ");
238         if(!FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, false))
239                 return die_s_("returned false", encoder);
240         printf("OK\n");
241
242         printf("testing FLAC__stream_encoder_set_do_escape_coding()... ");
243         if(!FLAC__stream_encoder_set_do_escape_coding(encoder, false))
244                 return die_s_("returned false", encoder);
245         printf("OK\n");
246
247         printf("testing FLAC__stream_encoder_set_do_exhaustive_model_search()... ");
248         if(!FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, false))
249                 return die_s_("returned false", encoder);
250         printf("OK\n");
251
252         printf("testing FLAC__stream_encoder_set_min_residual_partition_order()... ");
253         if(!FLAC__stream_encoder_set_min_residual_partition_order(encoder, 0))
254                 return die_s_("returned false", encoder);
255         printf("OK\n");
256
257         printf("testing FLAC__stream_encoder_set_max_residual_partition_order()... ");
258         if(!FLAC__stream_encoder_set_max_residual_partition_order(encoder, 0))
259                 return die_s_("returned false", encoder);
260         printf("OK\n");
261
262         printf("testing FLAC__stream_encoder_set_rice_parameter_search_dist()... ");
263         if(!FLAC__stream_encoder_set_rice_parameter_search_dist(encoder, 0))
264                 return die_s_("returned false", encoder);
265         printf("OK\n");
266
267         printf("testing FLAC__stream_encoder_set_total_samples_estimate()... ");
268         if(!FLAC__stream_encoder_set_total_samples_estimate(encoder, streaminfo_.data.stream_info.total_samples))
269                 return die_s_("returned false", encoder);
270         printf("OK\n");
271
272         printf("testing FLAC__stream_encoder_set_metadata()... ");
273         if(!FLAC__stream_encoder_set_metadata(encoder, metadata_sequence_, num_metadata_))
274                 return die_s_("returned false", encoder);
275         printf("OK\n");
276
277         if(layer < LAYER_FILENAME) {
278                 printf("opening file for FLAC output... ");
279                 file = fopen(flacfilename(is_ogg), "w+b");
280                 if(0 == file) {
281                         printf("ERROR (%s)\n", strerror(errno));
282                         return false;
283                 }
284                 printf("OK\n");
285         }
286
287         switch(layer) {
288                 case LAYER_STREAM:
289                         printf("testing FLAC__stream_encoder_init_%sstream()... ", is_ogg? "ogg_":"");
290                         init_status = is_ogg?
291                                 FLAC__stream_encoder_init_ogg_stream(encoder, /*read_callback=*/0, stream_encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, stream_encoder_metadata_callback_, /*client_data=*/file) :
292                                 FLAC__stream_encoder_init_stream(encoder, stream_encoder_write_callback_, /*seek_callback=*/0, /*tell_callback=*/0, stream_encoder_metadata_callback_, /*client_data=*/file);
293                         break;
294                 case LAYER_SEEKABLE_STREAM:
295                         printf("testing FLAC__stream_encoder_init_%sstream()... ", is_ogg? "ogg_":"");
296                         init_status = is_ogg?
297                                 FLAC__stream_encoder_init_ogg_stream(encoder, stream_encoder_read_callback_, stream_encoder_write_callback_, stream_encoder_seek_callback_, stream_encoder_tell_callback_, /*metadata_callback=*/0, /*client_data=*/file) :
298                                 FLAC__stream_encoder_init_stream(encoder, stream_encoder_write_callback_, stream_encoder_seek_callback_, stream_encoder_tell_callback_, /*metadata_callback=*/0, /*client_data=*/file);
299                         break;
300                 case LAYER_FILE:
301                         printf("testing FLAC__stream_encoder_init_%sFILE()... ", is_ogg? "ogg_":"");
302                         init_status = is_ogg?
303                                 FLAC__stream_encoder_init_ogg_FILE(encoder, file, stream_encoder_progress_callback_, /*client_data=*/0) :
304                                 FLAC__stream_encoder_init_FILE(encoder, file, stream_encoder_progress_callback_, /*client_data=*/0);
305                         break;
306                 case LAYER_FILENAME:
307                         printf("testing FLAC__stream_encoder_init_%sfile()... ", is_ogg? "ogg_":"");
308                         init_status = is_ogg?
309                                 FLAC__stream_encoder_init_ogg_file(encoder, flacfilename(is_ogg), stream_encoder_progress_callback_, /*client_data=*/0) :
310                                 FLAC__stream_encoder_init_file(encoder, flacfilename(is_ogg), stream_encoder_progress_callback_, /*client_data=*/0);
311                         break;
312                 default:
313                         die_("internal error 001");
314                         return false;
315         }
316         if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
317                 return die_s_(0, encoder);
318         printf("OK\n");
319
320         printf("testing FLAC__stream_encoder_get_state()... ");
321         state = FLAC__stream_encoder_get_state(encoder);
322         printf("returned state = %u (%s)... OK\n", (unsigned)state, FLAC__StreamEncoderStateString[state]);
323
324         printf("testing FLAC__stream_encoder_get_verify_decoder_state()... ");
325         dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder);
326         printf("returned state = %u (%s)... OK\n", (unsigned)dstate, FLAC__StreamDecoderStateString[dstate]);
327
328         {
329                 FLAC__uint64 absolute_sample;
330                 unsigned frame_number;
331                 unsigned channel;
332                 unsigned sample;
333                 FLAC__int32 expected;
334                 FLAC__int32 got;
335
336                 printf("testing FLAC__stream_encoder_get_verify_decoder_error_stats()... ");
337                 FLAC__stream_encoder_get_verify_decoder_error_stats(encoder, &absolute_sample, &frame_number, &channel, &sample, &expected, &got);
338                 printf("OK\n");
339         }
340
341         printf("testing FLAC__stream_encoder_get_verify()... ");
342         if(FLAC__stream_encoder_get_verify(encoder) != true) {
343                 printf("FAILED, expected true, got false\n");
344                 return false;
345         }
346         printf("OK\n");
347
348         printf("testing FLAC__stream_encoder_get_streamable_subset()... ");
349         if(FLAC__stream_encoder_get_streamable_subset(encoder) != true) {
350                 printf("FAILED, expected true, got false\n");
351                 return false;
352         }
353         printf("OK\n");
354
355         printf("testing FLAC__stream_encoder_get_do_mid_side_stereo()... ");
356         if(FLAC__stream_encoder_get_do_mid_side_stereo(encoder) != false) {
357                 printf("FAILED, expected false, got true\n");
358                 return false;
359         }
360         printf("OK\n");
361
362         printf("testing FLAC__stream_encoder_get_loose_mid_side_stereo()... ");
363         if(FLAC__stream_encoder_get_loose_mid_side_stereo(encoder) != false) {
364                 printf("FAILED, expected false, got true\n");
365                 return false;
366         }
367         printf("OK\n");
368
369         printf("testing FLAC__stream_encoder_get_channels()... ");
370         if(FLAC__stream_encoder_get_channels(encoder) != streaminfo_.data.stream_info.channels) {
371                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.channels, FLAC__stream_encoder_get_channels(encoder));
372                 return false;
373         }
374         printf("OK\n");
375
376         printf("testing FLAC__stream_encoder_get_bits_per_sample()... ");
377         if(FLAC__stream_encoder_get_bits_per_sample(encoder) != streaminfo_.data.stream_info.bits_per_sample) {
378                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.bits_per_sample, FLAC__stream_encoder_get_bits_per_sample(encoder));
379                 return false;
380         }
381         printf("OK\n");
382
383         printf("testing FLAC__stream_encoder_get_sample_rate()... ");
384         if(FLAC__stream_encoder_get_sample_rate(encoder) != streaminfo_.data.stream_info.sample_rate) {
385                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.sample_rate, FLAC__stream_encoder_get_sample_rate(encoder));
386                 return false;
387         }
388         printf("OK\n");
389
390         printf("testing FLAC__stream_encoder_get_blocksize()... ");
391         if(FLAC__stream_encoder_get_blocksize(encoder) != streaminfo_.data.stream_info.min_blocksize) {
392                 printf("FAILED, expected %u, got %u\n", streaminfo_.data.stream_info.min_blocksize, FLAC__stream_encoder_get_blocksize(encoder));
393                 return false;
394         }
395         printf("OK\n");
396
397         printf("testing FLAC__stream_encoder_get_max_lpc_order()... ");
398         if(FLAC__stream_encoder_get_max_lpc_order(encoder) != 0) {
399                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_max_lpc_order(encoder));
400                 return false;
401         }
402         printf("OK\n");
403
404         printf("testing FLAC__stream_encoder_get_qlp_coeff_precision()... ");
405         (void)FLAC__stream_encoder_get_qlp_coeff_precision(encoder);
406         /* we asked the encoder to auto select this so we accept anything */
407         printf("OK\n");
408
409         printf("testing FLAC__stream_encoder_get_do_qlp_coeff_prec_search()... ");
410         if(FLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder) != false) {
411                 printf("FAILED, expected false, got true\n");
412                 return false;
413         }
414         printf("OK\n");
415
416         printf("testing FLAC__stream_encoder_get_do_escape_coding()... ");
417         if(FLAC__stream_encoder_get_do_escape_coding(encoder) != false) {
418                 printf("FAILED, expected false, got true\n");
419                 return false;
420         }
421         printf("OK\n");
422
423         printf("testing FLAC__stream_encoder_get_do_exhaustive_model_search()... ");
424         if(FLAC__stream_encoder_get_do_exhaustive_model_search(encoder) != false) {
425                 printf("FAILED, expected false, got true\n");
426                 return false;
427         }
428         printf("OK\n");
429
430         printf("testing FLAC__stream_encoder_get_min_residual_partition_order()... ");
431         if(FLAC__stream_encoder_get_min_residual_partition_order(encoder) != 0) {
432                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_min_residual_partition_order(encoder));
433                 return false;
434         }
435         printf("OK\n");
436
437         printf("testing FLAC__stream_encoder_get_max_residual_partition_order()... ");
438         if(FLAC__stream_encoder_get_max_residual_partition_order(encoder) != 0) {
439                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_max_residual_partition_order(encoder));
440                 return false;
441         }
442         printf("OK\n");
443
444         printf("testing FLAC__stream_encoder_get_rice_parameter_search_dist()... ");
445         if(FLAC__stream_encoder_get_rice_parameter_search_dist(encoder) != 0) {
446                 printf("FAILED, expected %u, got %u\n", 0, FLAC__stream_encoder_get_rice_parameter_search_dist(encoder));
447                 return false;
448         }
449         printf("OK\n");
450
451         printf("testing FLAC__stream_encoder_get_total_samples_estimate()... ");
452         if(FLAC__stream_encoder_get_total_samples_estimate(encoder) != streaminfo_.data.stream_info.total_samples) {
453                 printf("FAILED, expected %" PRIu64 ", got %" PRIu64 "\n", streaminfo_.data.stream_info.total_samples, FLAC__stream_encoder_get_total_samples_estimate(encoder));
454                 return false;
455         }
456         printf("OK\n");
457
458         /* init the dummy sample buffer */
459         for(i = 0; i < sizeof(samples) / sizeof(FLAC__int32); i++)
460                 samples[i] = i & 7;
461
462         printf("testing FLAC__stream_encoder_process()... ");
463         if(!FLAC__stream_encoder_process(encoder, (const FLAC__int32 * const *)samples_array, sizeof(samples) / sizeof(FLAC__int32)))
464                 return die_s_("returned false", encoder);
465         printf("OK\n");
466
467         printf("testing FLAC__stream_encoder_process_interleaved()... ");
468         if(!FLAC__stream_encoder_process_interleaved(encoder, samples, sizeof(samples) / sizeof(FLAC__int32)))
469                 return die_s_("returned false", encoder);
470         printf("OK\n");
471
472         printf("testing FLAC__stream_encoder_finish()... ");
473         if(!FLAC__stream_encoder_finish(encoder))
474                 return die_s_("returned false", encoder);
475         printf("OK\n");
476
477         if(layer < LAYER_FILE)
478                 fclose(file);
479
480         printf("testing FLAC__stream_encoder_delete()... ");
481         FLAC__stream_encoder_delete(encoder);
482         printf("OK\n");
483
484         printf("\nPASSED!\n");
485
486         return true;
487 }
488
489 FLAC__bool test_encoders(void)
490 {
491         FLAC__bool is_ogg = false;
492
493         while(1) {
494                 init_metadata_blocks_();
495
496                 if(!test_stream_encoder(LAYER_STREAM, is_ogg))
497                         return false;
498
499                 if(!test_stream_encoder(LAYER_SEEKABLE_STREAM, is_ogg))
500                         return false;
501
502                 if(!test_stream_encoder(LAYER_FILE, is_ogg))
503                         return false;
504
505                 if(!test_stream_encoder(LAYER_FILENAME, is_ogg))
506                         return false;
507
508                 (void) grabbag__file_remove_file(flacfilename(is_ogg));
509
510                 free_metadata_blocks_();
511
512                 if(!FLAC_API_SUPPORTS_OGG_FLAC || is_ogg)
513                         break;
514                 is_ogg = true;
515         }
516
517         return true;
518 }