diff --git a/include/FLAC/encoder.h b/include/FLAC/encoder.h index e1171b4c..2f2656cf 100644 --- a/include/FLAC/encoder.h +++ b/include/FLAC/encoder.h @@ -24,11 +24,12 @@ typedef enum { FLAC__ENCODER_WRITE_OK = 0, - FLAC__ENCODER_WRITE_FATAL_ERROR = 1 + FLAC__ENCODER_WRITE_FATAL_ERROR } FLAC__EncoderWriteStatus; +extern const char *FLAC__EncoderWriteStatusString[]; typedef enum { - FLAC__ENCODER_OK, + FLAC__ENCODER_OK = 0, FLAC__ENCODER_UNINITIALIZED, FLAC__ENCODER_INVALID_NUMBER_OF_CHANNELS, FLAC__ENCODER_INVALID_BITS_PER_SAMPLE, @@ -44,6 +45,7 @@ typedef enum { FLAC__ENCODER_FATAL_ERROR_WHILE_WRITING, /* that is, the write_callback returned an error */ FLAC__ENCODER_MEMORY_ALLOCATION_ERROR } FLAC__EncoderState; +extern const char *FLAC__EncoderStateString[]; struct FLAC__EncoderPrivate; typedef struct { diff --git a/include/FLAC/file_decoder.h b/include/FLAC/file_decoder.h index 54aa1ece..1c3d7ee2 100644 --- a/include/FLAC/file_decoder.h +++ b/include/FLAC/file_decoder.h @@ -23,7 +23,7 @@ #include "stream_decoder.h" typedef enum { - FLAC__FILE_DECODER_OK, + FLAC__FILE_DECODER_OK = 0, FLAC__FILE_DECODER_SEEKING, FLAC__FILE_DECODER_END_OF_FILE, FLAC__FILE_DECODER_ERROR_OPENING_FILE, @@ -32,6 +32,7 @@ typedef enum { FLAC__FILE_DECODER_STREAM_ERROR, FLAC__FILE_DECODER_UNINITIALIZED } FLAC__FileDecoderState; +extern const char *FLAC__FileDecoderStateString[]; struct FLAC__FileDecoderPrivate; typedef struct { diff --git a/include/FLAC/stream_decoder.h b/include/FLAC/stream_decoder.h index 8ac06095..60436790 100644 --- a/include/FLAC/stream_decoder.h +++ b/include/FLAC/stream_decoder.h @@ -23,7 +23,7 @@ #include "format.h" typedef enum { - FLAC__STREAM_DECODER_SEARCH_FOR_METADATA, + FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0, FLAC__STREAM_DECODER_READ_METADATA, FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC, FLAC__STREAM_DECODER_READ_FRAME, @@ -34,21 +34,25 @@ typedef enum { FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR, FLAC__STREAM_DECODER_UNINITIALIZED } FLAC__StreamDecoderState; +extern const char *FLAC__StreamDecoderStateString[]; typedef enum { FLAC__STREAM_DECODER_READ_CONTINUE, FLAC__STREAM_DECODER_READ_END_OF_STREAM, FLAC__STREAM_DECODER_READ_ABORT } FLAC__StreamDecoderReadStatus; +extern const char *FLAC__StreamDecoderReadStatusString[]; typedef enum { FLAC__STREAM_DECODER_WRITE_CONTINUE, FLAC__STREAM_DECODER_WRITE_ABORT } FLAC__StreamDecoderWriteStatus; +extern const char *FLAC__StreamDecoderWriteStatusString[]; typedef enum { FLAC__STREAM_DECODER_ERROR_LOST_SYNC } FLAC__StreamDecoderErrorStatus; +extern const char *FLAC__StreamDecoderErrorStatusString[]; struct FLAC__StreamDecoderPrivate; typedef struct { diff --git a/src/libFLAC/encoder.c b/src/libFLAC/encoder.c index 512b626c..c27191f5 100644 --- a/src/libFLAC/encoder.c +++ b/src/libFLAC/encoder.c @@ -79,6 +79,29 @@ static bool encoder_generate_verbatim_subframe_(const FLAC__SubframeHeader *head static void encoder_promote_candidate_subframe_(FLAC__Encoder *encoder); static bool encoder_set_partitioned_rice_(const int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameter, const unsigned partition_order, unsigned parameters[], unsigned *bits); +const char *FLAC__EncoderWriteStatusString[] = { + "FLAC__ENCODER_WRITE_OK", + "FLAC__ENCODER_WRITE_FATAL_ERROR" +}; + +const char *FLAC__EncoderStateString[] = { + "FLAC__ENCODER_OK", + "FLAC__ENCODER_UNINITIALIZED", + "FLAC__ENCODER_INVALID_NUMBER_OF_CHANNELS", + "FLAC__ENCODER_INVALID_BITS_PER_SAMPLE", + "FLAC__ENCODER_INVALID_SAMPLE_RATE", + "FLAC__ENCODER_INVALID_BLOCK_SIZE", + "FLAC__ENCODER_INVALID_QLP_COEFF_PRECISION", + "FLAC__ENCODER_MID_SIDE_CHANNELS_MISMATCH", + "FLAC__ENCODER_MID_SIDE_SAMPLE_SIZE_MISMATCH", + "FLAC__ENCODER_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER", + "FLAC__ENCODER_NOT_STREAMABLE", + "FLAC__ENCODER_FRAMING_ERROR", + "FLAC__ENCODER_FATAL_ERROR_WHILE_ENCODING", + "FLAC__ENCODER_FATAL_ERROR_WHILE_WRITING", + "FLAC__ENCODER_MEMORY_ALLOCATION_ERROR" +}; + bool encoder_resize_buffers_(FLAC__Encoder *encoder, unsigned new_size) { diff --git a/src/libFLAC/file_decoder.c b/src/libFLAC/file_decoder.c index aed796c5..8f5be04d 100644 --- a/src/libFLAC/file_decoder.c +++ b/src/libFLAC/file_decoder.c @@ -43,6 +43,17 @@ static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__S static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); static bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, uint64 target_sample); +const char *FLAC__FileDecoderStateString[] = { + "FLAC__FILE_DECODER_OK", + "FLAC__FILE_DECODER_SEEKING", + "FLAC__FILE_DECODER_END_OF_FILE", + "FLAC__FILE_DECODER_ERROR_OPENING_FILE", + "FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR", + "FLAC__FILE_DECODER_SEEK_ERROR", + "FLAC__FILE_DECODER_STREAM_ERROR", + "FLAC__FILE_DECODER_UNINITIALIZED" +}; + FLAC__FileDecoder *FLAC__file_decoder_get_new_instance() { FLAC__FileDecoder *decoder = (FLAC__FileDecoder*)malloc(sizeof(FLAC__FileDecoder)); diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index eaf35bf7..2a3664f0 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -61,6 +61,34 @@ static bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder * static bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder); static bool read_callback_(byte buffer[], unsigned *bytes, void *client_data); +const char *FLAC__StreamDecoderStateString[] = { + "FLAC__STREAM_DECODER_SEARCH_FOR_METADATA", + "FLAC__STREAM_DECODER_READ_METADATA", + "FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC", + "FLAC__STREAM_DECODER_READ_FRAME", + "FLAC__STREAM_DECODER_RESYNC_IN_HEADER", + "FLAC__STREAM_DECODER_END_OF_STREAM", + "FLAC__STREAM_DECODER_ABORTED", + "FLAC__STREAM_DECODER_UNPARSEABLE_STREAM", + "FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR", + "FLAC__STREAM_DECODER_UNINITIALIZED" +}; + +const char *FLAC__StreamDecoderReadStatusString[] = { + "FLAC__STREAM_DECODER_READ_CONTINUE", + "FLAC__STREAM_DECODER_READ_END_OF_STREAM", + "FLAC__STREAM_DECODER_READ_ABORT" +}; + +const char *FLAC__StreamDecoderWriteStatusString[] = { + "FLAC__STREAM_DECODER_WRITE_CONTINUE", + "FLAC__STREAM_DECODER_WRITE_ABORT" +}; + +const char *FLAC__StreamDecoderErrorStatusString[] = { + "FLAC__STREAM_DECODER_ERROR_LOST_SYNC" +}; + FLAC__StreamDecoder *FLAC__stream_decoder_get_new_instance() { FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)malloc(sizeof(FLAC__StreamDecoder));