From 6894d29e66396ef47b246347fcae1132e5daf84e Mon Sep 17 00:00:00 2001 From: tobigun Date: Thu, 3 Jun 2010 15:58:43 +0000 Subject: better EOF handling for FFmpeg audio decoding (EOF handled like it is done in UVideo) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2438 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/media/UAudioDecoder_FFmpeg.pas | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/media/UAudioDecoder_FFmpeg.pas') diff --git a/src/media/UAudioDecoder_FFmpeg.pas b/src/media/UAudioDecoder_FFmpeg.pas index 7ca98885..f7f9c661 100644 --- a/src/media/UAudioDecoder_FFmpeg.pas +++ b/src/media/UAudioDecoder_FFmpeg.pas @@ -812,9 +812,18 @@ begin Exit; end; - // no error -> wait for user input - SDL_Delay(100); - Continue; + // url_feof() does not detect an EOF for some files + // so we have to do it this way. + if ((FormatCtx^.file_size <> 0) and + (ByteIOCtx^.pos >= FormatCtx^.file_size)) then + begin + PacketQueue.PutStatus(PKT_STATUS_FLAG_EOF, nil); + Exit; + end; + + // unknown error occured, exit + PacketQueue.PutStatus(PKT_STATUS_FLAG_ERROR, nil); + Exit; end; if (Packet.stream_index = AudioStreamIndex) then -- cgit v1.2.3