Skip to content

Commit

Permalink
Replace COBALT with STARBOARD macros in libFLAC (#3735)
Browse files Browse the repository at this point in the history
This is to make our customizations more consistent, and retire COBALT
macro entirely.

b/324932364
  • Loading branch information
kaidokert committed Jul 3, 2024
1 parent 89d3ea5 commit 08d3772
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions third_party/flac/include/FLAC/stream_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
void *client_data
);

#ifndef COBALT
#ifndef STARBOARD
/** Initialize the decoder instance to decode Ogg FLAC streams.
*
* This flavor of initialization sets up the decoder to decode from a
Expand Down Expand Up @@ -1368,7 +1368,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
FLAC__StreamDecoderErrorCallback error_callback,
void *client_data
);
#endif // COBALT
#endif // STARBOARD

/** Finish the decoding process.
* Flushes the decoding buffer, releases resources, resets the decoder
Expand Down
4 changes: 2 additions & 2 deletions third_party/flac/include/FLAC/stream_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ FLAC__stream_encoder_get_limit_min_bitrate(const FLAC__StreamEncoder* encoder);
*/
FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);

#ifndef COBALT
#ifndef STARBOARD
/** Initialize the encoder instance to encode Ogg FLAC streams.
*
* This flavor of initialization sets up the encoder to encode to a FLAC
Expand Down Expand Up @@ -1817,7 +1817,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(FLAC__Stre
* see FLAC__StreamEncoderInitStatus for the meanings of other return values.
*/
FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
#endif // COBALT
#endif // STARBOARD

/** Finish the encoding process.
* Flushes the encoding buffer, releases resources, resets the encoder
Expand Down
4 changes: 2 additions & 2 deletions third_party/flac/src/libFLAC/bitreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ FLAC__bool FLAC__bitreader_rewind_to_after_last_seen_framesync(FLAC__BitReader *
}
}

#ifndef COBALT
#ifndef STARBOARD
void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out)
{
uint32_t i, j;
Expand Down Expand Up @@ -376,7 +376,7 @@ void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out)
}
}
}
#endif // COBALT
#endif // STARBOARD

void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed)
{
Expand Down
4 changes: 2 additions & 2 deletions third_party/flac/src/libFLAC/bitwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void FLAC__bitwriter_clear(FLAC__BitWriter *bw)
bw->words = bw->bits = 0;
}

#ifndef COBALT
#ifndef STARBOARD
void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out)
{
uint32_t i, j;
Expand All @@ -222,7 +222,7 @@ void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out)
}
}
}
#endif // COBALT
#endif // STARBOARD

FLAC__bool FLAC__bitwriter_get_write_crc16(FLAC__BitWriter *bw, FLAC__uint16 *crc)
{
Expand Down
4 changes: 2 additions & 2 deletions third_party/flac/src/libFLAC/include/private/bitreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br);
void FLAC__bitreader_set_framesync_location(FLAC__BitReader* br);
FLAC__bool FLAC__bitreader_rewind_to_after_last_seen_framesync(
FLAC__BitReader* br);
#ifndef COBALT
#ifndef STARBOARD
void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out);
#endif // COBALT
#endif // STARBOARD

/*
* CRC functions
Expand Down
4 changes: 2 additions & 2 deletions third_party/flac/src/libFLAC/include/private/bitwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ void FLAC__bitwriter_delete(FLAC__BitWriter *bw);
FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw);
void FLAC__bitwriter_free(FLAC__BitWriter *bw); /* does not 'free(buffer)' */
void FLAC__bitwriter_clear(FLAC__BitWriter *bw);
#ifndef COBALT
#ifndef STARBOARD
void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out);
#endif // COBALT
#endif // STARBOARD

/*
* CRC functions
Expand Down
36 changes: 18 additions & 18 deletions third_party/flac/src/libFLAC/stream_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ static const FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' };
***********************************************************************/

static void set_defaults_(FLAC__StreamDecoder *decoder);
#ifndef COBALT
#ifndef STARBOARD
static FILE *get_binary_stdin_(void);
#endif // COBALT
#endif // STARBOARD
static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps);
static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id);
static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder);
Expand Down Expand Up @@ -108,13 +108,13 @@ static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__u
#if FLAC__HAS_OGG
static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample);
#endif
#ifndef COBALT
#ifndef STARBOARD
static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data);
#endif // COBALT
#endif // STARBOARD

/***********************************************************************
*
Expand All @@ -133,9 +133,9 @@ typedef struct FLAC__StreamDecoderPrivate {
FLAC__StreamDecoderMetadataCallback metadata_callback;
FLAC__StreamDecoderErrorCallback error_callback;
void *client_data;
#ifndef COBALT
#ifndef STARBOARD
FILE *file; /* only used if FLAC__stream_decoder_init_file()/FLAC__stream_decoder_init_file() called, else NULL */
#endif // COBALT
#endif // STARBOARD
FLAC__BitReader *input;
FLAC__int32 *output[FLAC__MAX_CHANNELS];
FLAC__int32 *residual[FLAC__MAX_CHANNELS]; /* WATCHOUT: these are the aligned pointers; the real pointers that should be free()'d are residual_unaligned[] below */
Expand Down Expand Up @@ -298,9 +298,9 @@ FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void)
for(i = 0; i < FLAC__MAX_CHANNELS; i++)
FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&decoder->private_->partitioned_rice_contents[i]);

#ifndef COBALT
#ifndef STARBOARD
decoder->private_->file = 0;
#endif // COBALT
#endif // STARBOARD

set_defaults_(decoder);

Expand Down Expand Up @@ -438,7 +438,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
);
}

#ifndef COBALT
#ifndef STARBOARD
FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
FLAC__StreamDecoder *decoder,
FLAC__StreamDecoderReadCallback read_callback,
Expand Down Expand Up @@ -591,7 +591,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
{
return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true);
}
#endif // COBALT
#endif // STARBOARD

FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
{
Expand Down Expand Up @@ -643,13 +643,13 @@ FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect);
#endif

#ifndef COBALT
#ifndef STARBOARD
if(0 != decoder->private_->file) {
if(decoder->private_->file != stdin)
fclose(decoder->private_->file);
decoder->private_->file = 0;
}
#endif // COBALT
#endif // STARBOARD

if(decoder->private_->do_md5_checking) {
if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5sum, 16))
Expand Down Expand Up @@ -945,10 +945,10 @@ FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder)
* not seekable.
*/
if(!decoder->private_->internal_reset_hack) {
#ifndef COBALT
#ifndef STARBOARD
if(decoder->private_->file == stdin)
return false; /* can't rewind stdin, reset fails */
#endif // COBALT
#endif // STARBOARD
if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->private_->client_data) == FLAC__STREAM_DECODER_SEEK_STATUS_ERROR)
return false; /* seekable and seek fails, reset fails */
}
Expand Down Expand Up @@ -1231,7 +1231,7 @@ void set_defaults_(FLAC__StreamDecoder *decoder)
#endif
}

#ifndef COBALT
#ifndef STARBOARD
/*
* This will forcibly set stdin to binary mode (for OSes that require it)
*/
Expand All @@ -1249,7 +1249,7 @@ FILE *get_binary_stdin_(void)

return stdin;
}
#endif // COBALT
#endif // STARBOARD

FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels, uint32_t bps)
{
Expand Down Expand Up @@ -3632,7 +3632,7 @@ FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint
}
#endif

#ifndef COBALT
#ifndef STARBOARD
FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
{
(void)client_data;
Expand Down Expand Up @@ -3704,4 +3704,4 @@ FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_d

return feof(decoder->private_->file)? true : false;
}
#endif // COBALT
#endif // STARBOARD
28 changes: 14 additions & 14 deletions third_party/flac/src/libFLAC/stream_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ static FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamD
static void verify_metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
static void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);

#ifndef COBALT
#ifndef STARBOARD
static FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
static FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
static FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
static FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data);
static FILE *get_binary_stdout_(void);
#endif // COBALT
#endif // STARBOARD


/***********************************************************************
Expand Down Expand Up @@ -383,9 +383,9 @@ typedef struct FLAC__StreamEncoderPrivate {
FLAC__StreamEncoderProgressCallback progress_callback;
void *client_data;
uint32_t first_seekpoint_to_check;
#ifndef COBALT
#ifndef STARBOARD
FILE *file; /* only used when encoding to a file */
#endif // COBALT
#endif // STARBOARD
FLAC__uint64 bytes_written;
FLAC__uint64 samples_written;
uint32_t frames_written;
Expand Down Expand Up @@ -543,9 +543,9 @@ FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void)
return 0;
}

#ifndef COBALT
#ifndef STARBOARD
encoder->private_->file = 0;
#endif // COBALT
#endif // STARBOARD

encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;

Expand Down Expand Up @@ -1289,7 +1289,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(
);
}

#ifndef COBALT
#ifndef STARBOARD
FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(
FLAC__StreamEncoder *encoder,
FLAC__StreamEncoderReadCallback read_callback,
Expand Down Expand Up @@ -1451,7 +1451,7 @@ FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(
{
return init_file_internal_(encoder, filename, progress_callback, client_data, /*is_ogg=*/true);
}
#endif // COBALT
#endif // STARBOARD

FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)
{
Expand All @@ -1469,13 +1469,13 @@ FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)
encoder->protected_->metadata = 0;
encoder->protected_->num_metadata_blocks = 0;
}
#ifndef COBALT
#ifndef STARBOARD
if(0 != encoder->private_->file) {
if(encoder->private_->file != stdout)
fclose(encoder->private_->file);
encoder->private_->file = 0;
}
#endif // COBALT
#endif // STARBOARD
return true;
}

Expand Down Expand Up @@ -1519,13 +1519,13 @@ FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)
}
}

#ifndef COBALT
#ifndef STARBOARD
if(0 != encoder->private_->file) {
if(encoder->private_->file != stdout)
fclose(encoder->private_->file);
encoder->private_->file = 0;
}
#endif // COBALT
#endif // STARBOARD

#if FLAC__HAS_OGG
if(encoder->private_->is_ogg)
Expand Down Expand Up @@ -4722,7 +4722,7 @@ void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDeco
encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR;
}

#ifndef COBALT
#ifndef STARBOARD
FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
{
(void)client_data;
Expand Down Expand Up @@ -4824,4 +4824,4 @@ FILE *get_binary_stdout_(void)

return stdout;
}
#endif // COBALT
#endif // STARBOARD

0 comments on commit 08d3772

Please sign in to comment.