switch malloc+memset(0) to calloc()
[flac.git] / src / libFLAC / file_decoder.c
index 085584f..54d1bb4 100644 (file)
@@ -25,7 +25,8 @@
 #include <io.h> /* for _setmode() */
 #include <fcntl.h> /* for _O_BINARY */
 #elif defined __CYGWIN__
-#include <io.h> /* for _setmode(), O_BINARY */
+#include <io.h> /* for setmode(), O_BINARY */
+#include <fcntl.h> /* for _O_BINARY */
 #endif
 #include "FLAC/assert.h"
 #include "protected/file_decoder.h"
@@ -38,7 +39,7 @@
  *
  ***********************************************************************/
 
-static void file_decoder_set_defaults_(FLAC__FileDecoder *decoder);
+static void set_defaults_(FLAC__FileDecoder *decoder);
 static FILE *get_binary_stdin_();
 static FLAC__SeekableStreamDecoderReadStatus read_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
 static FLAC__SeekableStreamDecoderSeekStatus seek_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
@@ -56,9 +57,9 @@ static void error_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__St
  ***********************************************************************/
 
 typedef struct FLAC__FileDecoderPrivate {
-       FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-       void (*metadata_callback)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-       void (*error_callback)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+       FLAC__FileDecoderWriteCallback write_callback;
+       FLAC__FileDecoderMetadataCallback metadata_callback;
+       FLAC__FileDecoderErrorCallback error_callback;
        void *client_data;
        FILE *file;
        char *filename; /* == NULL if stdin */
@@ -71,13 +72,13 @@ typedef struct FLAC__FileDecoderPrivate {
  *
  ***********************************************************************/
 
-const char * const FLAC__FileDecoderStateString[] = {
+FLAC_API const char * const FLAC__FileDecoderStateString[] = {
        "FLAC__FILE_DECODER_OK",
        "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_SEEKABLE_STREAM_DECODER_DECODER_ERROR",
+       "FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR",
        "FLAC__FILE_DECODER_ALREADY_INITIALIZED",
        "FLAC__FILE_DECODER_INVALID_CALLBACK",
        "FLAC__FILE_DECODER_UNINITIALIZED"
@@ -89,22 +90,24 @@ const char * const FLAC__FileDecoderStateString[] = {
  *
  ***********************************************************************/
 
-FLAC__FileDecoder *FLAC__file_decoder_new()
+FLAC_API FLAC__FileDecoder *FLAC__file_decoder_new()
 {
        FLAC__FileDecoder *decoder;
 
        FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */
 
-       decoder = (FLAC__FileDecoder*)malloc(sizeof(FLAC__FileDecoder));
+       decoder = (FLAC__FileDecoder*)calloc(1, sizeof(FLAC__FileDecoder));
        if(decoder == 0) {
                return 0;
        }
-       decoder->protected_ = (FLAC__FileDecoderProtected*)malloc(sizeof(FLAC__FileDecoderProtected));
+
+       decoder->protected_ = (FLAC__FileDecoderProtected*)calloc(1, sizeof(FLAC__FileDecoderProtected));
        if(decoder->protected_ == 0) {
                free(decoder);
                return 0;
        }
-       decoder->private_ = (FLAC__FileDecoderPrivate*)malloc(sizeof(FLAC__FileDecoderPrivate));
+
+       decoder->private_ = (FLAC__FileDecoderPrivate*)calloc(1, sizeof(FLAC__FileDecoderPrivate));
        if(decoder->private_ == 0) {
                free(decoder->protected_);
                free(decoder);
@@ -112,7 +115,6 @@ FLAC__FileDecoder *FLAC__file_decoder_new()
        }
 
        decoder->private_->seekable_stream_decoder = FLAC__seekable_stream_decoder_new();
-
        if(0 == decoder->private_->seekable_stream_decoder) {
                free(decoder->private_);
                free(decoder->protected_);
@@ -122,19 +124,19 @@ FLAC__FileDecoder *FLAC__file_decoder_new()
 
        decoder->private_->file = 0;
 
-       file_decoder_set_defaults_(decoder);
+       set_defaults_(decoder);
 
        decoder->protected_->state = FLAC__FILE_DECODER_UNINITIALIZED;
 
        return decoder;
 }
 
-void FLAC__file_decoder_delete(FLAC__FileDecoder *decoder)
+FLAC_API void FLAC__file_decoder_delete(FLAC__FileDecoder *decoder)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
 
        (void)FLAC__file_decoder_finish(decoder);
 
@@ -151,9 +153,9 @@ void FLAC__file_decoder_delete(FLAC__FileDecoder *decoder)
  *
  ***********************************************************************/
 
-FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder)
+FLAC_API FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder)
 {
-       FLAC__ASSERT(decoder != 0);
+       FLAC__ASSERT(0 != decoder);
 
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return decoder->protected_->state = FLAC__FILE_DECODER_ALREADY_INITIALIZED;
@@ -185,49 +187,49 @@ FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder)
        return decoder->protected_->state = FLAC__FILE_DECODER_OK;
 }
 
-FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder)
+FLAC_API FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder)
 {
-       FLAC__ASSERT(decoder != 0);
+       FLAC__ASSERT(0 != decoder);
 
        if(decoder->protected_->state == FLAC__FILE_DECODER_UNINITIALIZED)
                return true;
 
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
 
-       if(decoder->private_->file != 0 && decoder->private_->file != stdin) {
+       if(0 != decoder->private_->file && decoder->private_->file != stdin) {
                fclose(decoder->private_->file);
                decoder->private_->file = 0;
        }
 
-       if(decoder->private_->filename != 0) {
+       if(0 != decoder->private_->filename) {
                free(decoder->private_->filename);
                decoder->private_->filename = 0;
        }
 
-       file_decoder_set_defaults_(decoder);
+       set_defaults_(decoder);
 
        decoder->protected_->state = FLAC__FILE_DECODER_UNINITIALIZED;
 
        return FLAC__seekable_stream_decoder_finish(decoder->private_->seekable_stream_decoder);
 }
 
-FLAC__bool FLAC__file_decoder_set_md5_checking(FLAC__FileDecoder *decoder, FLAC__bool value)
+FLAC_API FLAC__bool FLAC__file_decoder_set_md5_checking(FLAC__FileDecoder *decoder, FLAC__bool value)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        return FLAC__seekable_stream_decoder_set_md5_checking(decoder->private_->seekable_stream_decoder, value);
 }
 
-FLAC__bool FLAC__file_decoder_set_filename(FLAC__FileDecoder *decoder, const char *value)
+FLAC_API FLAC__bool FLAC__file_decoder_set_filename(FLAC__FileDecoder *decoder, const char *value)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(value != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != value);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        if(0 != decoder->private_->filename) {
@@ -244,190 +246,183 @@ FLAC__bool FLAC__file_decoder_set_filename(FLAC__FileDecoder *decoder, const cha
        return true;
 }
 
-FLAC__bool FLAC__file_decoder_set_write_callback(FLAC__FileDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data))
+FLAC_API FLAC__bool FLAC__file_decoder_set_write_callback(FLAC__FileDecoder *decoder, FLAC__FileDecoderWriteCallback value)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        decoder->private_->write_callback = value;
        return true;
 }
 
-FLAC__bool FLAC__file_decoder_set_metadata_callback(FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data))
+FLAC_API FLAC__bool FLAC__file_decoder_set_metadata_callback(FLAC__FileDecoder *decoder, FLAC__FileDecoderMetadataCallback value)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        decoder->private_->metadata_callback = value;
        return true;
 }
 
-FLAC__bool FLAC__file_decoder_set_error_callback(FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data))
+FLAC_API FLAC__bool FLAC__file_decoder_set_error_callback(FLAC__FileDecoder *decoder, FLAC__FileDecoderErrorCallback value)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        decoder->private_->error_callback = value;
        return true;
 }
 
-FLAC__bool FLAC__file_decoder_set_client_data(FLAC__FileDecoder *decoder, void *value)
+FLAC_API FLAC__bool FLAC__file_decoder_set_client_data(FLAC__FileDecoder *decoder, void *value)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        decoder->private_->client_data = value;
        return true;
 }
 
-FLAC__bool FLAC__file_decoder_set_metadata_respond(FLAC__FileDecoder *decoder, FLAC__MetadataType type)
+FLAC_API FLAC__bool FLAC__file_decoder_set_metadata_respond(FLAC__FileDecoder *decoder, FLAC__MetadataType type)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        return FLAC__seekable_stream_decoder_set_metadata_respond(decoder->private_->seekable_stream_decoder, type);
 }
 
-FLAC__bool FLAC__file_decoder_set_metadata_respond_application(FLAC__FileDecoder *decoder, const FLAC__byte id[4])
+FLAC_API FLAC__bool FLAC__file_decoder_set_metadata_respond_application(FLAC__FileDecoder *decoder, const FLAC__byte id[4])
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        return FLAC__seekable_stream_decoder_set_metadata_respond_application(decoder->private_->seekable_stream_decoder, id);
 }
 
-FLAC__bool FLAC__file_decoder_set_metadata_respond_all(FLAC__FileDecoder *decoder)
+FLAC_API FLAC__bool FLAC__file_decoder_set_metadata_respond_all(FLAC__FileDecoder *decoder)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        return FLAC__seekable_stream_decoder_set_metadata_respond_all(decoder->private_->seekable_stream_decoder);
 }
 
-FLAC__bool FLAC__file_decoder_set_metadata_ignore(FLAC__FileDecoder *decoder, FLAC__MetadataType type)
+FLAC_API FLAC__bool FLAC__file_decoder_set_metadata_ignore(FLAC__FileDecoder *decoder, FLAC__MetadataType type)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        return FLAC__seekable_stream_decoder_set_metadata_ignore(decoder->private_->seekable_stream_decoder, type);
 }
 
-FLAC__bool FLAC__file_decoder_set_metadata_ignore_application(FLAC__FileDecoder *decoder, const FLAC__byte id[4])
+FLAC_API FLAC__bool FLAC__file_decoder_set_metadata_ignore_application(FLAC__FileDecoder *decoder, const FLAC__byte id[4])
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        return FLAC__seekable_stream_decoder_set_metadata_ignore_application(decoder->private_->seekable_stream_decoder, id);
 }
 
-FLAC__bool FLAC__file_decoder_set_metadata_ignore_all(FLAC__FileDecoder *decoder)
+FLAC_API FLAC__bool FLAC__file_decoder_set_metadata_ignore_all(FLAC__FileDecoder *decoder)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
-       FLAC__ASSERT(decoder->private_->seekable_stream_decoder != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       FLAC__ASSERT(0 != decoder->protected_);
+       FLAC__ASSERT(0 != decoder->private_->seekable_stream_decoder);
        if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
                return false;
        return FLAC__seekable_stream_decoder_set_metadata_ignore_all(decoder->private_->seekable_stream_decoder);
 }
 
-
-FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *decoder)
+FLAC_API FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *decoder)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->protected_ != 0);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->protected_);
        return decoder->protected_->state;
 }
 
-FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder)
+FLAC_API FLAC__SeekableStreamDecoderState FLAC__file_decoder_get_seekable_stream_decoder_state(const FLAC__FileDecoder *decoder)
 {
-       FLAC__ASSERT(decoder != 0);
-       FLAC__ASSERT(decoder->private_ != 0);
-       return FLAC__seekable_stream_decoder_get_md5_checking(decoder->private_->seekable_stream_decoder);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_state(decoder->private_->seekable_stream_decoder);
 }
 
-unsigned FLAC__file_decoder_get_channels(const FLAC__FileDecoder *decoder)
+FLAC_API FLAC__StreamDecoderState FLAC__file_decoder_get_stream_decoder_state(const FLAC__FileDecoder *decoder)
 {
-    FLAC__ASSERT(decoder != 0);
-    FLAC__ASSERT(decoder->private_ != 0);
-    return FLAC__seekable_stream_decoder_get_channels(decoder->private_->seekable_stream_decoder);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_stream_decoder_state(decoder->private_->seekable_stream_decoder);
 }
 
-FLAC__ChannelAssignment FLAC__file_decoder_get_channel_assignment(const FLAC__FileDecoder *decoder)
+FLAC_API FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder)
 {
-    FLAC__ASSERT(decoder != 0);
-    FLAC__ASSERT(decoder->private_ != 0);
-    return FLAC__seekable_stream_decoder_get_channel_assignment(decoder->private_->seekable_stream_decoder);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_md5_checking(decoder->private_->seekable_stream_decoder);
 }
 
-unsigned FLAC__file_decoder_get_bits_per_sample(const FLAC__FileDecoder *decoder)
+FLAC_API unsigned FLAC__file_decoder_get_channels(const FLAC__FileDecoder *decoder)
 {
-    FLAC__ASSERT(decoder != 0);
-    FLAC__ASSERT(decoder->private_ != 0);
-    return FLAC__seekable_stream_decoder_get_bits_per_sample(decoder->private_->seekable_stream_decoder);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_channels(decoder->private_->seekable_stream_decoder);
 }
 
-unsigned FLAC__file_decoder_get_sample_rate(const FLAC__FileDecoder *decoder)
+FLAC_API FLAC__ChannelAssignment FLAC__file_decoder_get_channel_assignment(const FLAC__FileDecoder *decoder)
 {
-    FLAC__ASSERT(decoder != 0);
-    FLAC__ASSERT(decoder->private_ != 0);
-    return FLAC__seekable_stream_decoder_get_sample_rate(decoder->private_->seekable_stream_decoder);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_channel_assignment(decoder->private_->seekable_stream_decoder);
 }
 
-unsigned FLAC__file_decoder_get_blocksize(const FLAC__FileDecoder *decoder)
+FLAC_API unsigned FLAC__file_decoder_get_bits_per_sample(const FLAC__FileDecoder *decoder)
 {
-    FLAC__ASSERT(decoder != 0);
-    FLAC__ASSERT(decoder->private_ != 0);
-    return FLAC__seekable_stream_decoder_get_blocksize(decoder->private_->seekable_stream_decoder);
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_bits_per_sample(decoder->private_->seekable_stream_decoder);
 }
 
-FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder)
+FLAC_API unsigned FLAC__file_decoder_get_sample_rate(const FLAC__FileDecoder *decoder)
 {
-       FLAC__bool ret;
-       FLAC__ASSERT(decoder != 0);
-
-       if(decoder->private_->seekable_stream_decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM)
-               decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
-
-       if(decoder->protected_->state == FLAC__FILE_DECODER_END_OF_FILE)
-               return true;
-
-       FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
-
-       ret = FLAC__seekable_stream_decoder_process_whole_stream(decoder->private_->seekable_stream_decoder);
-       if(!ret)
-               decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_sample_rate(decoder->private_->seekable_stream_decoder);
+}
 
-       return ret;
+FLAC_API unsigned FLAC__file_decoder_get_blocksize(const FLAC__FileDecoder *decoder)
+{
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+       return FLAC__seekable_stream_decoder_get_blocksize(decoder->private_->seekable_stream_decoder);
 }
 
-FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder)
+FLAC_API FLAC__bool FLAC__file_decoder_process_single(FLAC__FileDecoder *decoder)
 {
        FLAC__bool ret;
-       FLAC__ASSERT(decoder != 0);
+       FLAC__ASSERT(0 != decoder);
 
        if(decoder->private_->seekable_stream_decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM)
                decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
@@ -437,17 +432,17 @@ FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder)
 
        FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
 
-       ret = FLAC__seekable_stream_decoder_process_metadata(decoder->private_->seekable_stream_decoder);
+       ret = FLAC__seekable_stream_decoder_process_single(decoder->private_->seekable_stream_decoder);
        if(!ret)
                decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
 
        return ret;
 }
 
-FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder)
+FLAC_API FLAC__bool FLAC__file_decoder_process_until_end_of_metadata(FLAC__FileDecoder *decoder)
 {
        FLAC__bool ret;
-       FLAC__ASSERT(decoder != 0);
+       FLAC__ASSERT(0 != decoder);
 
        if(decoder->private_->seekable_stream_decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM)
                decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
@@ -457,17 +452,17 @@ FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder)
 
        FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
 
-       ret = FLAC__seekable_stream_decoder_process_one_frame(decoder->private_->seekable_stream_decoder);
+       ret = FLAC__seekable_stream_decoder_process_until_end_of_metadata(decoder->private_->seekable_stream_decoder);
        if(!ret)
                decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
 
        return ret;
 }
 
-FLAC__bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder)
+FLAC_API FLAC__bool FLAC__file_decoder_process_until_end_of_file(FLAC__FileDecoder *decoder)
 {
        FLAC__bool ret;
-       FLAC__ASSERT(decoder != 0);
+       FLAC__ASSERT(0 != decoder);
 
        if(decoder->private_->seekable_stream_decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM)
                decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
@@ -477,16 +472,16 @@ FLAC__bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decode
 
        FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
 
-       ret = FLAC__seekable_stream_decoder_process_remaining_frames(decoder->private_->seekable_stream_decoder);
+       ret = FLAC__seekable_stream_decoder_process_until_end_of_stream(decoder->private_->seekable_stream_decoder);
        if(!ret)
                decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
 
        return ret;
 }
 
-FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__uint64 sample)
+FLAC_API FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__uint64 sample)
 {
-       FLAC__ASSERT(decoder != 0);
+       FLAC__ASSERT(0 != decoder);
        FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK || decoder->protected_->state == FLAC__FILE_DECODER_END_OF_FILE);
 
        if(decoder->private_->filename == 0) { /* means the file is stdin... */
@@ -504,14 +499,18 @@ FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__ui
        }
 }
 
+
 /***********************************************************************
  *
  * Private class methods
  *
  ***********************************************************************/
 
-void file_decoder_set_defaults_(FLAC__FileDecoder *decoder)
+void set_defaults_(FLAC__FileDecoder *decoder)
 {
+       FLAC__ASSERT(0 != decoder);
+       FLAC__ASSERT(0 != decoder->private_);
+
        decoder->private_->filename = 0;
        decoder->private_->write_callback = 0;
        decoder->private_->metadata_callback = 0;