***************
*** 430,461 ****
  
    ogg_mux = GST_OGG_MUX (gst_pad_get_parent (pad));
  
-   /* FIXME: When a request pad is released while paused or playing, 
-    * we probably need to do something to finalise its stream in the
-    * ogg data we're producing, but I'm not sure what */
- 
    /* Find out GstOggPad in the collect pads info and clean it up */
  
    GST_OBJECT_LOCK (ogg_mux->collect);
    for (walk = ogg_mux->collect->data; walk; walk = g_slist_next (walk)) {
      GstOggPad *oggpad = (GstOggPad *) walk->data;
      GstCollectData *cdata = (GstCollectData *) walk->data;
-     GstBuffer *buf;
  
      if (cdata->pad == pad) {
-       ogg_stream_clear (&oggpad->stream);
- 
-       while ((buf = g_queue_pop_head (oggpad->pagebuffers)) != NULL) {
-         gst_buffer_unref (buf);
-       }
- 
-       g_queue_free (oggpad->pagebuffers);
-       oggpad->pagebuffers = NULL;
      }
    }
    GST_OBJECT_UNLOCK (ogg_mux->collect);
- 
-   gst_collect_pads_remove_pad (ogg_mux->collect, pad);
  }
  
  /* handle events */
--- 436,453 ----
  
    ogg_mux = GST_OGG_MUX (gst_pad_get_parent (pad));
  
    /* Find out GstOggPad in the collect pads info and clean it up */
  
    GST_OBJECT_LOCK (ogg_mux->collect);
    for (walk = ogg_mux->collect->data; walk; walk = g_slist_next (walk)) {
      GstOggPad *oggpad = (GstOggPad *) walk->data;
      GstCollectData *cdata = (GstCollectData *) walk->data;
  
      if (cdata->pad == pad) {
+       oggpad->removed = TRUE;
      }
    }
    GST_OBJECT_UNLOCK (ogg_mux->collect);
  }
  
  /* handle events */
***************
*** 777,782 ****
            ogg_page page;
            GstFlowReturn ret;
  
            /* Just gone to EOS. Flush existing page(s) */
            pad->eos = TRUE;
  
--- 807,815 ----
            ogg_page page;
            GstFlowReturn ret;
  
+           /* it's no longer active */
+           g_atomic_int_dec_and_test (&ogg_mux->active_pads);
+ 
            /* Just gone to EOS. Flush existing page(s) */
            pad->eos = TRUE;
  
