From a47e20f02d9fbcd21089ba3aabe98314dd337352 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Wed, 26 Jan 2005 03:17:28 +0000 Subject: [PATCH] fix another seeking bug that can happen rarely when seeking past the end of the stream --- src/libFLAC/seekable_stream_decoder.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libFLAC/seekable_stream_decoder.c b/src/libFLAC/seekable_stream_decoder.c index 1f4da73c..2c899f20 100644 --- a/src/libFLAC/seekable_stream_decoder.c +++ b/src/libFLAC/seekable_stream_decoder.c @@ -744,7 +744,7 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, if(seekable_stream_decoder->private_->eof_callback(seekable_stream_decoder, seekable_stream_decoder->private_->client_data)) { *bytes = 0; #if 0 -@@@@@@ verify that this is not needed + /*@@@@@@ verify that this is not needed */ seekable_stream_decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM; #endif return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; @@ -757,7 +757,7 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, if(*bytes == 0) { if(seekable_stream_decoder->private_->eof_callback(seekable_stream_decoder, seekable_stream_decoder->private_->client_data)) { #if 0 -@@@@@@ verify that this is not needed + /*@@@@@@ verify that this is not needed */ seekable_stream_decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM; #endif return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; @@ -1062,7 +1062,8 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__ } } /* our write callback will change the state when it gets to the target frame */ - if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_SEEKING) { + /* actually, we could have got_a_frame if our decoder is at FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM so we need to check for that also */ + if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_SEEKING && decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM) { break; } else { /* we need to narrow the search */