From 6cca87bb7bbed034e79f5919690d1002ec13ab50 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Tue, 29 Jan 2002 17:56:03 +0000 Subject: [PATCH] fix bug when seeking a file that is already at END_OF_FILE --- src/libFLAC/file_decoder.c | 18 ++++++++++-------- src/libFLAC/seekable_stream_decoder.c | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libFLAC/file_decoder.c b/src/libFLAC/file_decoder.c index cdd9ffb..1039cdf 100644 --- a/src/libFLAC/file_decoder.c +++ b/src/libFLAC/file_decoder.c @@ -359,16 +359,10 @@ FLAC__bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decode return ret; } -/*********************************************************************** - * - * Private class methods - * - ***********************************************************************/ - FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__uint64 sample) { FLAC__ASSERT(decoder != 0); - FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK); + 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... */ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR; @@ -379,10 +373,18 @@ FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__ui decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR; return false; } - else + else { + decoder->protected_->state = FLAC__FILE_DECODER_OK; return true; + } } +/*********************************************************************** + * + * Private class methods + * + ***********************************************************************/ + FLAC__SeekableStreamDecoderReadStatus read_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) { FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data; diff --git a/src/libFLAC/seekable_stream_decoder.c b/src/libFLAC/seekable_stream_decoder.c index c174bb5..4dfe78b 100644 --- a/src/libFLAC/seekable_stream_decoder.c +++ b/src/libFLAC/seekable_stream_decoder.c @@ -404,7 +404,7 @@ FLAC__bool FLAC__seekable_stream_decoder_seek_absolute(FLAC__SeekableStreamDecod FLAC__uint64 length; FLAC__ASSERT(decoder != 0); - FLAC__ASSERT(decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_OK); + FLAC__ASSERT(decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_OK || decoder->protected_->state == END_OF_STREAM); decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_SEEKING; -- 2.7.4