ext/vorbis/vorbisenc.*: Fix EOS handling. Still needs a fix in the ogg muxer to...
authorThomas Vander Stichele <thomas@apestaart.org>
Thu, 15 Sep 2005 19:59:50 +0000 (19:59 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Thu, 15 Sep 2005 19:59:50 +0000 (19:59 +0000)
Original commit message from CVS:
2005-09-15  Thomas Vander Stichele  <thomas at apestaart dot org>

* ext/vorbis/vorbisenc.c: (gst_vorbisenc_init),
(gst_vorbisenc_sink_event), (gst_vorbisenc_chain),
(gst_vorbisenc_output_buffers), (gst_vorbisenc_change_state):
* ext/vorbis/vorbisenc.h:
Fix EOS handling.  Still needs a fix in the ogg muxer to
mark the last page as eos somehow.

ChangeLog
ext/vorbis/vorbisenc.c
ext/vorbis/vorbisenc.h

index 3b371e6..5174921 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2005-09-15  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+       * ext/vorbis/vorbisenc.c: (gst_vorbisenc_init),
+       (gst_vorbisenc_sink_event), (gst_vorbisenc_chain),
+       (gst_vorbisenc_output_buffers), (gst_vorbisenc_change_state):
+       * ext/vorbis/vorbisenc.h:
+         Fix EOS handling.  Still needs a fix in the ogg muxer to
+         mark the last page as eos somehow.
+
+2005-09-15  Thomas Vander Stichele  <thomas at apestaart dot org>
+
        * common/gtk-doc-plugins.mak:
        * docs/plugins/Makefile.am:
        * docs/plugins/gst-plugins-base-plugins-sections.txt:
index a4eb94d..75f7709 100644 (file)
@@ -96,6 +96,8 @@ enum
   ARG_LAST_MESSAGE
 };
 
+static void gst_vorbisenc_output_buffers (GstVorbisEnc * vorbisenc);
+
 /* FIXME:
  * vorbis_granule_time was added between 1.0 and 1.0.1; it's too silly
  * to require a new version for such a simple function, but once we move
@@ -548,7 +550,6 @@ gst_vorbisenc_init (GstVorbisEnc * vorbisenc)
   vorbisenc->last_message = NULL;
 
   vorbisenc->setup = FALSE;
-  vorbisenc->eos = FALSE;
   vorbisenc->header_sent = FALSE;
 }
 
@@ -862,14 +863,18 @@ gst_vorbisenc_sink_event (GstPad * pad, GstEvent * event)
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_EOS:
-      /* end of file.  this can be done implicitly in the mainline,
-         but it's easier to see here in non-clever fashion.
-         Tell the library we're at end of stream so that it can handle
-         the last frame and mark end of stream in the output properly */
-      GST_DEBUG_OBJECT (vorbisenc, "received EOS, will process later");
+      /* Tell the library we're at end of stream so that it can handle
+       * the last frame and mark end of stream in the output properly */
+      GST_DEBUG_OBJECT (vorbisenc, "EOS, clearing state and sending event on");
       vorbis_analysis_wrote (&vorbisenc->vd, 0);
-      vorbisenc->eos = TRUE;
-      gst_event_unref (event);
+      gst_vorbisenc_output_buffers (vorbisenc);
+
+      /* clean up and exit.  vorbis_info_clear() must be called last */
+      vorbis_block_clear (&vorbisenc->vb);
+      vorbis_dsp_clear (&vorbisenc->vd);
+      vorbis_info_clear (&vorbisenc->vi);
+
+      res = gst_pad_event_default (pad, event);
       break;
     case GST_EVENT_TAG:
       if (vorbisenc->tags) {
@@ -978,6 +983,14 @@ gst_vorbisenc_chain (GstPad * pad, GstBuffer * buffer)
     gst_buffer_unref (buf);
   }
 
+  gst_vorbisenc_output_buffers (vorbisenc);
+
+  return GST_FLOW_OK;
+}
+
+static void
+gst_vorbisenc_output_buffers (GstVorbisEnc * vorbisenc)
+{
   /* vorbis does some data preanalysis, then divides up blocks for
      more involved (potentially parallel) processing.  Get a single
      block for encoding now */
@@ -995,17 +1008,6 @@ gst_vorbisenc_chain (GstPad * pad, GstBuffer * buffer)
       gst_vorbisenc_push_packet (vorbisenc, &op);
     }
   }
-
-  if (vorbisenc->eos) {
-    GST_DEBUG_OBJECT (vorbisenc, "EOS, clearing state and sending event on");
-    /* clean up and exit.  vorbis_info_clear() must be called last */
-    vorbis_block_clear (&vorbisenc->vb);
-    vorbis_dsp_clear (&vorbisenc->vd);
-    vorbis_info_clear (&vorbisenc->vi);
-    gst_pad_push_event (vorbisenc->srcpad, gst_event_new_eos ());
-    //gst_element_set_eos (GST_ELEMENT (vorbisenc));
-  }
-  return GST_FLOW_OK;
 }
 
 static void
@@ -1127,8 +1129,6 @@ gst_vorbisenc_change_state (GstElement * element, GstStateChange transition)
       vorbisenc->tags = gst_tag_list_new ();
       break;
     case GST_STATE_CHANGE_READY_TO_PAUSED:
-      vorbisenc->eos = FALSE;
-      break;
     case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
     default:
       break;
index 94c151d..a93cf93 100644 (file)
@@ -57,8 +57,6 @@ struct _GstVorbisEnc {
   vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
   vorbis_block     vb; /* local working space for packet->PCM decode */
 
-  gboolean         eos;
-
   gboolean         managed;
   gint             bitrate;
   gint             min_bitrate;