Merge branch 'master' into 0.11
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 18 Aug 2011 17:36:50 +0000 (19:36 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 18 Aug 2011 17:36:50 +0000 (19:36 +0200)
Conflicts:
ext/ogg/gstoggmux.c
gst/playback/gstplaysink.c

1  2 
ext/ogg/gstoggdemux.c
ext/ogg/gstoggmux.c
ext/ogg/gstoggstream.c
gst/audioresample/resample.c
gst/playback/gstplaysink.c

index 72e162447a8320279c12ec571b43ed14259e4176,eddaa44e76a480c0bad70e491c358918503ae58f..f1010015c8d6b674abd31566141a99223e30a71b
@@@ -114,8 -114,9 +114,8 @@@ static void gst_ogg_pad_finalize (GObje
  static const GstQueryType *gst_ogg_pad_query_types (GstPad * pad);
  static gboolean gst_ogg_pad_src_query (GstPad * pad, GstQuery * query);
  static gboolean gst_ogg_pad_event (GstPad * pad, GstEvent * event);
 -static GstCaps *gst_ogg_pad_getcaps (GstPad * pad);
  static GstOggPad *gst_ogg_chain_get_stream (GstOggChain * chain,
-     glong serialno);
+     guint32 serialno);
  
  static GstFlowReturn gst_ogg_demux_combine_flows (GstOggDemux * ogg,
      GstOggPad * pad, GstFlowReturn ret);
@@@ -1183,10 -1183,10 +1185,11 @@@ gst_ogg_chain_new_stream (GstOggChain 
    gst_tag_list_free (list);
  
    GST_DEBUG_OBJECT (chain->ogg,
-       "created new ogg src %p for stream with serial %08lx", ret, serialno);
+       "created new ogg src %p for stream with serial %08" G_GINT32_MODIFIER "x",
+       ret, serialno);
  
    g_array_append_val (chain->streams, ret);
 +  gst_pad_set_active (GST_PAD_CAST (ret), TRUE);
  
    return ret;
  
@@@ -2935,8 -2962,9 +2942,8 @@@ gst_ogg_demux_find_chains (GstOggDemux 
  {
    ogg_page og;
    GstPad *peer;
 -  GstFormat format;
    gboolean res;
-   gulong serialno;
+   guint32 serialno;
    GstOggChain *chain;
    GstFlowReturn ret;
  
index a87e4fc3d87c88e5d42f7bf575c05ab1e4cda578,f039efca6e2d5879a068f3c8564bc57e0577e9ee..2f043ec111a8fb572901935a7a5bd1422d962088
@@@ -1070,6 -1120,19 +1074,21 @@@ gst_ogg_mux_set_header_on_caps (GstCap
    return caps;
  }
  
 -  packet->packet = GST_BUFFER_DATA (buf);
 -  packet->bytes = GST_BUFFER_SIZE (buf);
+ static void
+ create_header_packet (ogg_packet * packet, GstBuffer * buf, GstOggPadData * pad)
+ {
++  gsize size;
++
++  packet->packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
++  packet->bytes = size;
+   packet->granulepos = 0;
+   /* mark BOS and packet number */
+   packet->b_o_s = (pad->packetno == 0);
+   packet->packetno = pad->packetno++;
+   /* mark EOS */
+   packet->e_o_s = 0;
+ }
  /*
   * For each pad we need to write out one (small) header in one
   * page that allows decoders to identify the type of the stream.
Simple merge
Simple merge
index 23e9526345c2257fe8ac2185309a3c7d2f1f60f0,019dcc3ec6d761c45c047f0728eaedb4ed7762e0..e0a540b761d1835489c86cc1dc426e2695b4502e
@@@ -171,8 -182,9 +184,10 @@@ struct _GstPlaySin
    gboolean text_pad_blocked;
    GstPad *text_srcpad_stream_synchronizer;
    GstPad *text_sinkpad_stream_synchronizer;
 +  gulong text_block_id;
  
+   guint32 pending_blocked_pads;
    /* properties */
    GstElement *audio_sink;
    GstElement *video_sink;
@@@ -2863,73 -2871,8 +2878,78 @@@ is_raw_pad (GstPad * pad
    return raw;
  }
  
 +static GstProbeReturn
 +sinkpad_blocked_cb (GstPad * blockedpad, GstProbeType type, gpointer type_data,
 +    gpointer user_data);
 +
  static void
 -sinkpad_blocked_cb (GstPad * blockedpad, gboolean blocked, gpointer user_data)
 +video_set_blocked (GstPlaySink * playsink, gboolean blocked)
 +{
 +  if (playsink->video_pad) {
 +    GstPad *opad =
 +        GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
 +            (playsink->video_pad)));
 +    if (blocked && playsink->video_block_id == 0) {
 +      playsink->video_block_id =
 +          gst_pad_add_probe (opad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
 +          gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
 +    } else if (!blocked && playsink->video_block_id) {
 +      gst_pad_remove_probe (opad, playsink->video_block_id);
++      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO_RAW);
++      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO);
 +      playsink->video_block_id = 0;
 +      playsink->video_pad_blocked = FALSE;
 +    }
 +    gst_object_unref (opad);
 +  }
 +}
 +
 +static void
 +audio_set_blocked (GstPlaySink * playsink, gboolean blocked)
 +{
 +  if (playsink->audio_pad) {
 +    GstPad *opad =
 +        GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
 +            (playsink->audio_pad)));
 +    if (blocked && playsink->audio_block_id == 0) {
 +      playsink->audio_block_id =
 +          gst_pad_add_probe (opad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
 +          gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
 +    } else if (!blocked && playsink->audio_block_id) {
 +      gst_pad_remove_probe (opad, playsink->audio_block_id);
++      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO_RAW);
++      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO);
 +      playsink->audio_block_id = 0;
 +      playsink->audio_pad_blocked = FALSE;
 +    }
 +    gst_object_unref (opad);
 +  }
 +}
 +
 +static void
 +text_set_blocked (GstPlaySink * playsink, gboolean blocked)
 +{
 +  if (playsink->text_pad) {
 +    GstPad *opad =
 +        GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
 +            (playsink->text_pad)));
 +    if (blocked && playsink->text_block_id == 0) {
 +      playsink->text_block_id =
 +          gst_pad_add_probe (opad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
 +          gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
 +    } else if (!blocked && playsink->text_block_id) {
 +      gst_pad_remove_probe (opad, playsink->text_block_id);
++      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_TEXT);
 +      playsink->text_block_id = 0;
 +      playsink->text_pad_blocked = FALSE;
 +    }
 +    gst_object_unref (opad);
 +  }
 +}
 +
 +static GstProbeReturn
 +sinkpad_blocked_cb (GstPad * blockedpad, GstProbeType type, gpointer type_data,
 +    gpointer user_data)
  {
    GstPlaySink *playsink = (GstPlaySink *) user_data;
    GstPad *pad;
  
    pad = GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (blockedpad)));
    if (pad == playsink->video_pad) {
 -    playsink->video_pad_blocked = blocked;
 -    GST_DEBUG_OBJECT (pad, "Video pad blocked: %d", blocked);
 -    if (!blocked) {
 -      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO_RAW);
 -      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_VIDEO);
 -    }
 +    playsink->video_pad_blocked = TRUE;
 +    GST_DEBUG_OBJECT (pad, "Video pad blocked");
    } else if (pad == playsink->audio_pad) {
 -    playsink->audio_pad_blocked = blocked;
 -    GST_DEBUG_OBJECT (pad, "Audio pad blocked: %d", blocked);
 -    if (!blocked) {
 -      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO_RAW);
 -      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_AUDIO);
 -    }
 +    playsink->audio_pad_blocked = TRUE;
 +    GST_DEBUG_OBJECT (pad, "Audio pad blocked");
    } else if (pad == playsink->text_pad) {
 -    playsink->text_pad_blocked = blocked;
 -    GST_DEBUG_OBJECT (pad, "Text pad blocked: %d", blocked);
 -    if (!blocked)
 -      PENDING_FLAG_UNSET (playsink, GST_PLAY_SINK_TYPE_TEXT);
 -  }
 -
 -  if (!blocked) {
 -    gst_object_unref (pad);
 -    GST_PLAY_SINK_UNLOCK (playsink);
 -    return;
 +    playsink->text_pad_blocked = TRUE;
 +    GST_DEBUG_OBJECT (pad, "Text pad blocked");
    }
  
-   if ((!playsink->video_pad || playsink->video_pad_blocked) &&
-       (!playsink->audio_pad || playsink->audio_pad_blocked) &&
-       (!playsink->text_pad || playsink->text_pad_blocked)) {
+   /* We reconfigure when for ALL streams:
+    * * there isn't a pad
+    * * OR the pad is blocked
+    * * OR there are no pending blocks on that pad
+    */
+   if ((!playsink->video_pad || playsink->video_pad_blocked
+           || !PENDING_VIDEO_BLOCK (playsink)) && (!playsink->audio_pad
+           || playsink->audio_pad_blocked || !PENDING_AUDIO_BLOCK (playsink))
+       && (!playsink->text_pad || playsink->text_pad_blocked
+           || !PENDING_TEXT_BLOCK (playsink))) {
      GST_DEBUG_OBJECT (playsink, "All pads blocked -- reconfiguring");
  
      if (playsink->video_pad) {
@@@ -3128,9 -3135,9 +3156,10 @@@ gst_play_sink_request_pad (GstPlaySink 
        GstPad *blockpad =
            GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (res)));
  
 -      gst_pad_set_blocked_async_full (blockpad, TRUE, sinkpad_blocked_cb,
 +      *block_id =
 +          gst_pad_add_probe (blockpad, GST_PROBE_TYPE_BLOCK, sinkpad_blocked_cb,
            gst_object_ref (playsink), (GDestroyNotify) gst_object_unref);
+       PENDING_FLAG_SET (playsink, type);
        gst_object_unref (blockpad);
      }
      if (!activate)