shithub: riscv

Download patch

ref: ce80c5029e3885836ac3077a2219093e251c4993
parent: 187aad97beeb440e4dc938597370f3259b66c579
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Sep 16 16:25:01 EDT 2014

oggdec: recognize "begin of stream" packets and restart decoding

--- a/sys/src/cmd/audio/oggdec/oggdec.c
+++ b/sys/src/cmd/audio/oggdec/oggdec.c
@@ -139,7 +139,10 @@
       fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
       exit(1);
     }
-  
+
+    
+BOS:/* Begin of stream */
+
     /* Get the serial number and set up the rest of decode. */
     /* serialno first; use it to set up a logical stream */
     ogg_stream_init(&os,ogg_page_serialno(&og));
@@ -248,6 +251,14 @@
 	  fprintf(stderr,"Corrupt or missing data in bitstream; "
 		  "continuing...\n");
 	}else{
+	  if(ogg_page_bos(&og)){ /* got new start of stream */
+	    ogg_stream_clear(&os);
+	    vorbis_block_clear(&vb);
+	    vorbis_dsp_clear(&vd);
+	    vorbis_comment_clear(&vc);
+	    vorbis_info_clear(&vi);
+	    goto BOS;
+	  }
 	  ogg_stream_pagein(&os,&og); /* can safely ignore errors at
 					 this point */
 	  while(1){