diff libmpdemux/demuxer.c @ 29486:a373af1e3b24

Handle demuxers that never set filepos by using stream_tell.
author reimar
date Mon, 17 Aug 2009 05:55:40 +0000
parents fa9ca1188c50
children 940fb22fd9dd
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Mon Aug 17 02:06:00 2009 +0000
+++ b/libmpdemux/demuxer.c	Mon Aug 17 05:55:40 2009 +0000
@@ -242,7 +242,7 @@
     d->movi_end = stream->end_pos;
     d->seekable = 1;
     d->synced = 0;
-    d->filepos = 0;
+    d->filepos = -1;
     d->audio = new_demuxer_stream(d, a_id);
     d->video = new_demuxer_stream(d, v_id);
     d->sub = new_demuxer_stream(d, s_id);
@@ -1262,8 +1262,9 @@
     int res = demux_control(demuxer, DEMUXER_CTRL_GET_PERCENT_POS, &ans);
     int len = (demuxer->movi_end - demuxer->movi_start) / 100;
     if (res <= 0) {
+        off_t pos = demuxer->filepos > 0 ? demuxer->filepos : stream_tell(demuxer->stream);
         if (len > 0)
-            ans = (demuxer->filepos - demuxer->movi_start) / len;
+            ans = (pos - demuxer->movi_start) / len;
         else
             ans = 0;
     }