[xiph-commits] r10369 - icecast/trunk/icecast/src

karl at svn.xiph.org karl at svn.xiph.org
Mon Nov 14 16:29:27 PST 2005


Author: karl
Date: 2005-11-14 16:29:24 -0800 (Mon, 14 Nov 2005)
New Revision: 10369

Modified:
   icecast/trunk/icecast/src/format_vorbis.c
Log:
fixup granulepos on EOS case when rebuilding vorbis streams. This was causing
a short audio glitch on playback, but was not typically noticed.


Modified: icecast/trunk/icecast/src/format_vorbis.c
===================================================================
--- icecast/trunk/icecast/src/format_vorbis.c	2005-11-14 23:00:13 UTC (rev 10368)
+++ icecast/trunk/icecast/src/format_vorbis.c	2005-11-15 00:29:24 UTC (rev 10369)
@@ -42,12 +42,14 @@
 
     int rebuild_comment;
     int stream_notify;
+    int initial_audio_page;
 
     ogg_stream_state new_os;
     int page_samples_trigger;
     ogg_int64_t prev_granulepos;
     ogg_packet *prev_packet;
     ogg_int64_t granulepos;
+    ogg_int64_t initial_page_granulepos;
     ogg_int64_t samples_in_page;
     int prev_window;
     int initial_audio_packet;
@@ -216,10 +218,10 @@
 /* push last packet into stream marked with eos */
 static void initiate_flush (vorbis_codec_t *source_vorbis)
 {
-    DEBUG0 ("adding EOS packet");
     if (source_vorbis->prev_packet)
     {
         /* insert prev_packet with eos */
+        DEBUG0 ("adding EOS packet");
         source_vorbis->prev_packet->e_o_s = 1;
         add_audio_packet (source_vorbis, source_vorbis->prev_packet);
         source_vorbis->prev_packet->e_o_s = 0;
@@ -256,7 +258,25 @@
 
             add_audio_packet (source_vorbis, prev_packet);
             free_ogg_packet (prev_packet);
-            packet . granulepos = source_vorbis->granulepos;
+
+            /* check for short values on first initial page */
+            if (packet . packetno == 4)
+            {
+                if (source_vorbis->initial_page_granulepos < source_vorbis->granulepos)
+                {
+                    source_vorbis->granulepos -= source_vorbis->initial_page_granulepos;
+                    source_vorbis->samples_in_page = source_vorbis->page_samples_trigger;
+                }
+            }
+            /* check for long values on first page */
+            if (packet.granulepos == source_vorbis->initial_page_granulepos)
+            {
+                if (source_vorbis->initial_page_granulepos > source_vorbis->granulepos)
+                    source_vorbis->granulepos = source_vorbis->initial_page_granulepos;
+            }
+
+            if (packet.e_o_s == 0)
+                packet . granulepos = source_vorbis->granulepos;
         }
         else
         {
@@ -497,7 +517,14 @@
         return NULL;
     }
     if (codec->headers == 3)
+    {
+        if (source_vorbis->initial_audio_page)
+        {
+            source_vorbis->initial_page_granulepos = ogg_page_granulepos (page);
+            source_vorbis->initial_audio_page = 0;
+        }
         return NULL;
+    }
 
     while (codec->headers < 3)
     {
@@ -530,6 +557,7 @@
         /* set queued vorbis pages to contain about 1/2 of a second worth of samples */
         source_vorbis->page_samples_trigger = source_vorbis->vi.rate / 2;
         source_vorbis->process_packet = process_vorbis_headers;
+        source_vorbis->initial_audio_page = 1;
     }
     else
     {



More information about the commits mailing list