Commit f1ac7d9b authored by Josh Coalson's avatar Josh Coalson

make "#if FLAC__HAS_OGG" checking consistent

parent 80011e40
......@@ -43,7 +43,7 @@
#include "decode.h"
typedef struct {
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__bool is_ogg;
#endif
......@@ -131,7 +131,7 @@ int flac__decode_aiff(const char *infilename, const char *outfilename, FLAC__boo
if(!
DecoderSession_construct(
&decoder_session,
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
options.common.is_ogg,
#else
/*is_ogg=*/false,
......@@ -168,7 +168,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
if(!
DecoderSession_construct(
&decoder_session,
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
options.common.is_ogg,
#else
/*is_ogg=*/false,
......@@ -208,7 +208,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
if(!
DecoderSession_construct(
&decoder_session,
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
options.common.is_ogg,
#else
/*is_ogg=*/false,
......@@ -240,7 +240,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename)
{
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
d->is_ogg = is_ogg;
#else
(void)is_ogg;
......@@ -334,7 +334,7 @@ FLAC__bool DecoderSession_init_decoder(DecoderSession *decoder_session, decode_o
if (decoder_session->replaygain.spec.apply)
FLAC__stream_decoder_set_metadata_respond(decoder_session->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
if(decoder_session->is_ogg) {
if(!decode_options.use_first_serial_number)
FLAC__stream_decoder_set_ogg_serial_number(decoder_session->decoder, decode_options.serial_number);
......
......@@ -38,7 +38,7 @@ typedef struct {
typedef struct {
FLAC__bool continue_through_decode_errors;
replaygain_synthesis_spec_t replaygain_synthesis_spec;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__bool is_ogg;
FLAC__bool use_first_serial_number;
long serial_number;
......
......@@ -56,7 +56,7 @@
#define CHUNK_OF_SAMPLES 2048
typedef struct {
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__bool use_ogg;
#endif
FLAC__bool verify;
......@@ -172,7 +172,7 @@ int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, con
if(!
EncoderSession_construct(
&encoder_session,
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
options.common.use_ogg,
#else
/*use_ogg=*/false,
......@@ -584,7 +584,7 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
if(!
EncoderSession_construct(
&encoder_session,
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
options.common.use_ogg,
#else
/*use_ogg=*/false,
......@@ -1105,7 +1105,7 @@ int flac__encode_raw(FILE *infile, off_t infilesize, const char *infilename, con
if(!
EncoderSession_construct(
&encoder_session,
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
options.common.use_ogg,
#else
/*use_ogg=*/false,
......@@ -1359,7 +1359,7 @@ int flac__encode_flac(FILE *infile, off_t infilesize, const char *infilename, co
if(!
EncoderSession_construct(
&encoder_session,
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
options.common.use_ogg,
#else
/*use_ogg=*/false,
......@@ -1522,7 +1522,7 @@ FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC_
* initialize instance
*/
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
e->use_ogg = use_ogg;
#else
(void)use_ogg;
......@@ -1973,7 +1973,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
FLAC__stream_encoder_disable_fixed_subframes(e->encoder, options.debug.disable_fixed_subframes);
FLAC__stream_encoder_disable_verbatim_subframes(e->encoder, options.debug.disable_verbatim_subframes);
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
if(e->use_ogg) {
FLAC__stream_encoder_set_ogg_serial_number(e->encoder, options.serial_number);
......
......@@ -62,7 +62,7 @@ typedef struct {
utils__SkipUntilSpecification skip_specification;
utils__SkipUntilSpecification until_specification;
FLAC__bool verify;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__bool use_ogg;
long serial_number;
#endif
......
......@@ -146,7 +146,7 @@ static struct share__option long_options_[] = {
{ "sector-align" , share__no_argument, 0, 0 },
{ "seekpoint" , share__required_argument, 0, 'S' },
{ "padding" , share__required_argument, 0, 'P' },
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
{ "ogg" , share__no_argument, 0, 0 },
{ "serial-number" , share__required_argument, 0, 0 },
#endif
......@@ -183,7 +183,7 @@ static struct share__option long_options_[] = {
{ "no-replay-gain" , share__no_argument, 0, 0 },
{ "no-sector-align" , share__no_argument, 0, 0 },
{ "no-lax" , share__no_argument, 0, 0 },
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
{ "no-ogg" , share__no_argument, 0, 0 },
#endif
{ "no-exhaustive-model-search", share__no_argument, 0, 0 },
......@@ -709,7 +709,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a
else if(0 == strcmp(long_option, "sector-align")) {
option_values.sector_align = true;
}
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
else if(0 == strcmp(long_option, "ogg")) {
option_values.use_ogg = true;
}
......@@ -782,7 +782,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a
else if(0 == strcmp(long_option, "no-lax")) {
option_values.lax = false;
}
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
else if(0 == strcmp(long_option, "no-ogg")) {
option_values.use_ogg = false;
}
......@@ -1123,7 +1123,7 @@ void show_help()
printf(" --delete-input-file Deletes after a successful encode/decode\n");
printf(" --skip={#|mm:ss.ss} Skip the given initial samples for each input\n");
printf(" --until={#|[+|-]mm:ss.ss} Stop at the given sample for each input file\n");
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
printf(" --ogg Use Ogg as transport layer\n");
printf(" --serial-number Serial number to use for the FLAC stream\n");
#endif
......@@ -1178,7 +1178,7 @@ void show_help()
printf(" --no-exhaustive-model-search\n");
printf(" --no-lax\n");
printf(" --no-mid-side\n");
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
printf(" --no-ogg\n");
#endif
printf(" --no-padding\n");
......@@ -1256,7 +1256,7 @@ void show_explain()
printf(" relative to the --skip point. If a `-' sign is\n");
printf(" at the beginning, the --until point is relative\n");
printf(" to end of the audio.\n");
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
printf(" --ogg When encoding, generate Ogg FLAC output instead\n");
printf(" of native FLAC. Ogg FLAC streams are FLAC\n");
printf(" streams wrapped in an Ogg transport layer. The\n");
......@@ -1480,7 +1480,7 @@ void show_explain()
printf(" --no-exhaustive-model-search\n");
printf(" --no-lax\n");
printf(" --no-mid-side\n");
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
printf(" --no-ogg\n");
#endif
printf(" --no-padding\n");
......@@ -1644,7 +1644,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
common_options.until_specification.is_relative = true;
common_options.verify = option_values.verify;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
common_options.use_ogg = option_values.use_ogg;
/* set a random serial number if one has not yet been specified */
if(!option_values.has_serial_number) {
......@@ -1800,7 +1800,7 @@ int decode_file(const char *infilename)
else
treat_as_ogg = false;
#ifndef FLAC__HAS_OGG
#if !FLAC__HAS_OGG
if(treat_as_ogg) {
flac__utils_printf(stderr, 1, "%s: Ogg support has not been built into this copy of flac\n", infilename);
return 1;
......@@ -1826,7 +1826,7 @@ int decode_file(const char *infilename)
common_options.continue_through_decode_errors = option_values.continue_through_decode_errors;
common_options.replaygain_synthesis_spec = option_values.replaygain_synthesis_spec;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
common_options.is_ogg = treat_as_ogg;
common_options.use_first_serial_number = !option_values.has_serial_number;
common_options.serial_number = option_values.serial_number;
......
......@@ -33,7 +33,7 @@
#define FLAC__PROTECTED__STREAM_DECODER_H
#include "FLAC/stream_decoder.h"
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
#include "private/ogg_decoder_aspect.h"
#endif
......@@ -45,7 +45,7 @@ typedef struct FLAC__StreamDecoderProtected {
unsigned sample_rate; /* in Hz */
unsigned blocksize; /* in samples (per channel) */
FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__OggDecoderAspect ogg_decoder_aspect;
#endif
} FLAC__StreamDecoderProtected;
......
......@@ -33,7 +33,7 @@
#define FLAC__PROTECTED__STREAM_ENCODER_H
#include "FLAC/stream_encoder.h"
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
#include "private/ogg_encoder_aspect.h"
#endif
......@@ -101,7 +101,7 @@ typedef struct FLAC__StreamEncoderProtected {
FLAC__StreamMetadata **metadata;
unsigned num_metadata_blocks;
FLAC__uint64 streaminfo_offset, seektable_offset, audio_offset;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__OggEncoderAspect ogg_encoder_aspect;
#endif
} FLAC__StreamEncoderProtected;
......
......@@ -124,14 +124,14 @@ static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned
static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual);
static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder);
static FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data);
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
static FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes);
static FLAC__OggDecoderAspectReadStatus read_callback_proxy_(const void *void_decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
#endif
static FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
static void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status);
static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample);
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample);
#endif
static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
......@@ -147,7 +147,7 @@ static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *c
***********************************************************************/
typedef struct FLAC__StreamDecoderPrivate {
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__bool is_ogg;
#endif
FLAC__StreamDecoderReadCallback read_callback;
......@@ -199,7 +199,7 @@ typedef struct FLAC__StreamDecoderPrivate {
FLAC__uint64 first_frame_offset; /* hint to the seek routine of where in the stream the first audio frame starts */
FLAC__uint64 target_sample;
unsigned unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */
#endif
} FLAC__StreamDecoderPrivate;
......@@ -385,7 +385,7 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_(
if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
return FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
#ifndef FLAC__HAS_OGG
#if !FLAC__HAS_OGG
if(is_ogg)
return FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
#endif
......@@ -398,7 +398,7 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_(
)
return FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
decoder->private_->is_ogg = is_ogg;
if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect))
return decoder->protected_->state = FLAC__STREAM_DECODER_OGG_ERROR;
......@@ -697,7 +697,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
decoder->private_->output_capacity = 0;
decoder->private_->output_channels = 0;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
if(decoder->private_->is_ogg)
FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect);
#endif
......@@ -728,7 +728,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecod
FLAC__ASSERT(0 != decoder->protected_);
if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
return false;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
/* can't check decoder->private_->is_ogg since that's not set until init time */
FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value);
return true;
......@@ -931,7 +931,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamD
FLAC__ASSERT(0 != decoder->private_);
FLAC__ASSERT(0 != position);
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
if(decoder->private_->is_ogg)
return false;
#endif
......@@ -953,7 +953,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder)
decoder->private_->samples_decoded = 0;
decoder->private_->do_md5_checking = false;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
if(decoder->private_->is_ogg)
FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect);
#endif
......@@ -980,7 +980,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder)
return false;
}
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
/*@@@ could go in !internal_reset_hack block below */
if(decoder->private_->is_ogg)
FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect);
......@@ -1209,7 +1209,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *deco
{
const FLAC__bool ok =
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
decoder->private_->is_ogg?
seek_to_absolute_sample_ogg_(decoder, length, sample) :
#endif
......@@ -1240,7 +1240,7 @@ unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecod
void set_defaults_(FLAC__StreamDecoder *decoder)
{
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
decoder->private_->is_ogg = false;
#endif
decoder->private_->read_callback = 0;
......@@ -1259,7 +1259,7 @@ void set_defaults_(FLAC__StreamDecoder *decoder)
decoder->protected_->md5_checking = false;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect);
#endif
}
......@@ -2768,7 +2768,7 @@ FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data)
}
else {
const FLAC__StreamDecoderReadStatus status =
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
decoder->private_->is_ogg?
read_callback_ogg_aspect_(decoder, buffer, bytes) :
#endif
......@@ -2816,7 +2816,7 @@ FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data)
*/
}
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes)
{
switch(FLAC__ogg_decoder_aspect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback_proxy_, decoder, decoder->private_->client_data)) {
......@@ -2871,7 +2871,7 @@ FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder
FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
decoder->private_->got_a_frame = true;
#endif
decoder->private_->last_frame = *frame; /* save the frame */
......@@ -3102,7 +3102,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
return true;
}
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample)
{
FLAC__uint64 left_pos = 0, right_pos = stream_length;
......
......@@ -64,7 +64,7 @@
#include "private/lpc.h"
#include "private/md5.h"
#include "private/memory.h"
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
#include "private/ogg_helper.h"
#include "private/ogg_mapping.h"
#endif
......@@ -673,7 +673,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_(
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED;
#ifndef FLAC__HAS_OGG
#if !FLAC__HAS_OGG
if(is_ogg)
return FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
#endif
......@@ -1438,7 +1438,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncod
FLAC__ASSERT(0 != encoder->protected_);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
/* can't check encoder->private_->is_ogg since that's not set until init time */
FLAC__ogg_encoder_aspect_set_serial_number(&encoder->protected_->ogg_encoder_aspect, value);
return true;
......
......@@ -358,7 +358,7 @@ int main(int argc, char *argv[])
for (read_mode = 0; read_mode <= 2; read_mode++) {
FLAC__bool ok;
if (strlen(filename) > 4 && 0 == strcmp(filename+strlen(filename)-4, ".ogg")) {
#ifdef FLAC__HAS_OGG
#if FLAC__HAS_OGG
ok = seek_barrage(/*is_ogg=*/true, filename, filesize, count, samples, read_mode);
#else
fprintf(stderr, "ERROR: Ogg FLAC not supported\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment