[MPlayer-cvslog] r27459 - trunk/libmpdemux/demux_lavf.c

aurel subversion at mplayerhq.hu
Wed Aug 13 02:01:31 CEST 2008


Author: aurel
Date: Wed Aug 13 02:01:31 2008
New Revision: 27459

Log:
demux_lavf: fix mp_seek behavior in case of seeking error
When trying to seek past the end of file, the ByteIOContext expect
that the stream is left in the same state as it was before the
seek tentative. stream_seek() don't meet this expectation.
It changes current position when seeking past the end of file.
Thus, it's necessary to reset the stream in it's previous state
after a seek failure.


Modified:
   trunk/libmpdemux/demux_lavf.c

Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c	(original)
+++ trunk/libmpdemux/demux_lavf.c	Wed Aug 13 02:01:31 2008
@@ -97,6 +97,7 @@ static int mp_read(void *opaque, uint8_t
 
 static offset_t mp_seek(void *opaque, offset_t pos, int whence) {
     stream_t *stream = opaque;
+    offset_t current_pos;
     mp_msg(MSGT_HEADER,MSGL_DBG2,"mp_seek(%p, %d, %d)\n", stream, (int)pos, whence);
     if(whence == SEEK_CUR)
         pos +=stream_tell(stream);
@@ -113,8 +114,12 @@ static offset_t mp_seek(void *opaque, of
         return -1;
     if(pos<stream->end_pos && stream->eof)
         stream_reset(stream);
-    if(stream_seek(stream, pos)==0)
+    current_pos = stream_tell(stream);
+    if(stream_seek(stream, pos)==0) {
+        stream_reset(stream);
+        stream_seek(stream, current_pos);
         return -1;
+    }
 
     return pos - stream->start_pos;
 }



More information about the MPlayer-cvslog mailing list