changeset 8655:f8e53f8cb8b2

bunkus: Fixed Ogg/Ogm seeking by discarding the first packet after the seek which may be incomplete
author mosu
date Mon, 30 Dec 2002 08:59:33 +0000
parents 2c4cebb8637d
children 82e448c3a478
files libmpdemux/demux_ogg.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ogg.c	Mon Dec 30 01:34:20 2002 +0000
+++ b/libmpdemux/demux_ogg.c	Mon Dec 30 08:59:33 2002 +0000
@@ -901,7 +901,7 @@
   sh_audio_t* sh_audio = demuxer->audio->sh;
   ogg_packet op;
   float rate;
-  int i,sp;
+  int i,sp,first;
   vorbis_info* vi = NULL;
   int64_t gp = 0;
   off_t pos;
@@ -961,6 +961,7 @@
   ogg_d->pos = pos;
   ogg_d->last_size = 0;
 
+  first = 1;
   while(1) {
     int np;
     ogg_d->pos += ogg_d->last_size;
@@ -992,7 +993,13 @@
 	continue;
       else if(np == 0)
 	break;
-
+      if (first) { /* Discard the first packet as it's probably broken,
+           and we don't have any other means to decide whether it is
+           complete or not. */
+        first = 0;
+        break;
+      }
+      
       if( ((*op.packet & PACKET_IS_SYNCPOINT)  || os->vorbis )  &&
 	  (!ogg_d->syncpoints || op.granulepos >= gp) ) {
 	demux_ogg_add_packet(ds,os,&op);