add a samples_written field to the progress callback
authorJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 8 Aug 2002 22:55:45 +0000 (22:55 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 8 Aug 2002 22:55:45 +0000 (22:55 +0000)
include/FLAC++/encoder.h
include/FLAC/file_encoder.h
src/libFLAC++/file_encoder.cc
src/libFLAC/file_encoder.c
src/libOggFLAC/stream_encoder.c
src/test_libFLAC++/encoders.cc
src/test_libFLAC/encoders.c

index 7458a6813ef3aa01e5dd9726e5d763f4dad7d3cc..156f33c7d7a0a03bd8a7f4312430ad2e22a625a3 100644 (file)
@@ -340,11 +340,11 @@ namespace FLAC {
                        bool process(const FLAC__int32 * const buffer[], unsigned samples);
                        bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
                protected:
-                       virtual void progress_callback(FLAC__uint64 bytes_written, unsigned frames_written, unsigned total_frames_estimate);
+                       virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
 
                        ::FLAC__FileEncoder *encoder_;
                private:
-                       static void progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
+                       static void progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
 
                        // Private and undefined so you can't use them:
                        File(const Stream &);
index 49295cf4b1152d591c8336d601d517bdde82c9d5..8a4a12721142d1a4f4def355bb461399c184e243 100644 (file)
@@ -151,7 +151,7 @@ typedef struct {
 } FLAC__FileEncoder;
 
 /*@@@ document: */
-typedef void (*FLAC__FileEncoderProgressCallback)(const FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
+typedef void (*FLAC__FileEncoderProgressCallback)(const FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
 
 
 /***********************************************************************
index 1c1c55efcdb4986f0b8de180fd9fb50e05c73653..eaa299c25fb56d2d9e43367510c6118393aa2718 100644 (file)
@@ -312,18 +312,18 @@ namespace FLAC {
                        return (bool)::FLAC__file_encoder_process_interleaved(encoder_, buffer, samples);
                }
 
-               void File::progress_callback(FLAC__uint64 bytes_written, unsigned frames_written, unsigned total_frames_estimate)
+               void File::progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate)
                {
-                       (void)bytes_written, (void)frames_written, (void)total_frames_estimate;
+                       (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate;
                }
 
-               void File::progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data)
+               void File::progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data)
                {
                        (void)encoder;
                        FLAC__ASSERT(0 != client_data);
                        File *instance = reinterpret_cast<File *>(client_data);
                        FLAC__ASSERT(0 != instance);
-                       instance->progress_callback(bytes_written, frames_written, total_frames_estimate);
+                       instance->progress_callback(bytes_written, samples_written, frames_written, total_frames_estimate);
                }
 
        };
index a9ac2faf02578bb9af102a44b6799b7e5a98f0e8..abf1c78026688403abd197587e67c9e739692232 100644 (file)
@@ -45,6 +45,7 @@ typedef struct FLAC__FileEncoderPrivate {
        void *client_data;
        char *filename;
        FLAC__uint64 bytes_written;
+       FLAC__uint64 samples_written;
        unsigned total_frames_estimate;
        FLAC__SeekableStreamEncoder *seekable_stream_encoder;
        FILE *file;
@@ -156,6 +157,7 @@ FLAC__FileEncoderState FLAC__file_encoder_init(FLAC__FileEncoder *encoder)
                return encoder->protected_->state = FLAC__FILE_ENCODER_ERROR_OPENING_FILE;
 
        encoder->private_->bytes_written = 0;
+       encoder->private_->samples_written = 0;
 
        FLAC__seekable_stream_encoder_set_seek_callback(encoder->private_->seekable_stream_encoder, seek_callback_);
        FLAC__seekable_stream_encoder_set_write_callback(encoder->private_->seekable_stream_encoder, write_callback_);
@@ -663,8 +665,9 @@ FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__SeekableStreamEncoder
 
        if(fwrite(buffer, sizeof(FLAC__byte), bytes, file_encoder->private_->file) == bytes) {
                file_encoder->private_->bytes_written += bytes;
+               file_encoder->private_->samples_written += samples;
                if(0 != file_encoder->private_->progress_callback && samples > 0)
-                       file_encoder->private_->progress_callback(file_encoder, file_encoder->private_->bytes_written, current_frame+1, file_encoder->private_->total_frames_estimate, file_encoder->private_->client_data);
+                       file_encoder->private_->progress_callback(file_encoder, file_encoder->private_->bytes_written, file_encoder->private_->samples_written, current_frame+1, file_encoder->private_->total_frames_estimate, file_encoder->private_->client_data);
                return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
        }
        else
index e001ef889072707be40f0a4a0cec5f69fadd958d..6d38404e199db14b28f48467245ddc3bac8afcd3 100644 (file)
@@ -636,10 +636,10 @@ FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__StreamEncoder *unused
                return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
 
        while(ogg_stream_pageout(&encoder->private_->ogg.stream_state, &encoder->private_->ogg.page) != 0) {
-               if(encoder->private_->write_callback(encoder, encoder->private_->ogg.page.header, encoder->private_->ogg.page.header_len, samples, current_frame, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
+               if(encoder->private_->write_callback(encoder, encoder->private_->ogg.page.header, encoder->private_->ogg.page.header_len, 0, current_frame, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
                        return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
 
-               if(encoder->private_->write_callback(encoder, encoder->private_->ogg.page.body, encoder->private_->ogg.page.body_len, samples, current_frame, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
+               if(encoder->private_->write_callback(encoder, encoder->private_->ogg.page.body, encoder->private_->ogg.page.body_len, 0, current_frame, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
                        return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
        }
 
index d5826105fa1ac7117430251002ee04377568131e..964bdf1b0b03f6c27518f2f70d79919d69ff0abf 100644 (file)
@@ -778,12 +778,12 @@ public:
        ~FileEncoder() { }
 
        // from FLAC::Encoder::File
-       void progress_callback(FLAC__uint64 bytes_written, unsigned frames_written, unsigned total_frames_estimate);
+       void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
 
        bool die(const char *msg = 0) const;
 };
 
-void FileEncoder::progress_callback(FLAC__uint64, unsigned, unsigned)
+void FileEncoder::progress_callback(FLAC__uint64, FLAC__uint64, unsigned, unsigned)
 {
 }
 
index 7f9b75dbfbb950db890598f58652b69a2233fd93..1115701f61d658c7ccaf2034887aa98249cf1d7c 100644 (file)
@@ -796,9 +796,9 @@ static FLAC__bool test_seekable_stream_encoder()
        return true;
 }
 
-static void file_encoder_progress_callback_(const FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data)
+static void file_encoder_progress_callback_(const FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data)
 {
-       (void)encoder, (void)bytes_written, (void)frames_written, (void)total_frames_estimate, (void)client_data;
+       (void)encoder, (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate, (void)client_data;
 }
 
 static FLAC__bool test_file_encoder()