gst: Don't assume that get_current_caps() returns non-NULL caps after has_current_caps()

Remove calls to gst_pad_has_current_caps() which then go on to call
gst_pad_get_current_caps() as the caps can go to NULL in between. Instead just
use gst_pad_get_current_caps() and check for NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=759539
This commit is contained in:
Dave Craig 2015-12-16 12:40:39 +00:00 committed by Sebastian Dröge
parent 6cdbf40622
commit 211c8492b3
6 changed files with 33 additions and 24 deletions

View file

@ -766,9 +766,8 @@ gst_flac_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter)
pad = GST_AUDIO_ENCODER_SINK_PAD (enc);
if (gst_pad_has_current_caps (pad)) {
ret = gst_pad_get_current_caps (pad);
} else {
ret = gst_pad_get_current_caps (pad);
if (ret == NULL) {
ret = gst_pad_get_pad_template_caps (pad);
}
@ -1281,9 +1280,8 @@ gst_flac_enc_sink_query (GstAudioEncoder * enc, GstQuery * query)
case GST_QUERY_ACCEPT_CAPS:{
GstCaps *acceptable, *caps;
if (gst_pad_has_current_caps (pad)) {
acceptable = gst_pad_get_current_caps (pad);
} else {
acceptable = gst_pad_get_current_caps (pad);
if (acceptable == NULL) {
acceptable = gst_pad_get_pad_template_caps (pad);
}

View file

@ -830,6 +830,7 @@ tags:
if (mux->have_video) {
GstPad *video_pad = NULL;
GstCaps *caps = NULL;
GstFlvPad *cpad;
GSList *l = mux->collect->data;
@ -841,8 +842,11 @@ tags:
}
}
if (video_pad && gst_pad_has_current_caps (video_pad)) {
GstCaps *caps;
if (video_pad) {
caps = gst_pad_get_current_caps (video_pad);
}
if (caps != NULL) {
GstStructure *s;
gint size;
gint num, den;
@ -855,7 +859,6 @@ tags:
script_tag = gst_buffer_append (script_tag, tmp);
tags_written++;
caps = gst_pad_get_current_caps (video_pad);
s = gst_caps_get_structure (caps, 0);
gst_caps_unref (caps);

View file

@ -265,8 +265,8 @@ gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
GstPad *pad;
pad = self->sinkpad;
if (gst_pad_has_current_caps (pad)) {
ret = gst_pad_get_current_caps (pad);
ret = gst_pad_get_current_caps (pad);
if (ret != NULL) {
goto done;
}

View file

@ -267,6 +267,7 @@ gst_rtp_h264_set_src_caps (GstRtpH264Depay * rtph264depay)
{
gboolean res;
GstCaps *srccaps;
GstCaps *old_caps;
if (!rtph264depay->byte_stream &&
(!rtph264depay->new_codec_data ||
@ -397,10 +398,10 @@ gst_rtp_h264_set_src_caps (GstRtpH264Depay * rtph264depay)
}
if (gst_pad_has_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph264depay))) {
GstCaps *old_caps =
gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph264depay));
old_caps =
gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph264depay));
if (old_caps != NULL) {
/* Only update the caps if they are not equal. For
* AVC we don't update caps if only the codec_data
* changes. This is the same behaviour as in h264parse

View file

@ -329,8 +329,9 @@ gst_shape_wipe_video_sink_getcaps (GstShapeWipe * self, GstPad * pad,
{
GstCaps *templ, *ret, *tmp;
if (gst_pad_has_current_caps (pad))
return gst_pad_get_current_caps (pad);
ret = gst_pad_get_current_caps (pad);
if (ret != NULL)
return ret;
templ = gst_pad_get_pad_template_caps (pad);
tmp = gst_pad_peer_query_caps (self->srcpad, NULL);
@ -451,8 +452,9 @@ gst_shape_wipe_mask_sink_getcaps (GstShapeWipe * self, GstPad * pad,
GstCaps *ret, *tmp, *tcaps;
guint i, n;
if (gst_pad_has_current_caps (pad))
return gst_pad_get_current_caps (pad);
ret = gst_pad_get_current_caps (pad);
if (ret != NULL)
return ret;
tcaps = gst_pad_get_pad_template_caps (self->video_sinkpad);
tmp = gst_pad_peer_query_caps (self->video_sinkpad, NULL);
@ -535,10 +537,13 @@ gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter)
GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
GstCaps *templ, *ret, *tmp;
if (gst_pad_has_current_caps (pad))
return gst_pad_get_current_caps (pad);
else if (gst_pad_has_current_caps (self->video_sinkpad))
return gst_pad_get_current_caps (self->video_sinkpad);
ret = gst_pad_get_current_caps (pad);
if (ret != NULL)
return ret;
ret = gst_pad_get_current_caps (self->video_sinkpad);
if (ret != NULL)
return ret;
templ = gst_pad_get_pad_template_caps (self->video_sinkpad);
tmp = gst_pad_peer_query_caps (self->video_sinkpad, NULL);

View file

@ -464,8 +464,10 @@ gst_aspect_ratio_crop_set_property (GObject * object, guint prop_id,
if (recheck) {
GstCaps *caps = gst_pad_get_current_caps (aspect_ratio_crop->sink);
gst_aspect_ratio_crop_set_caps (aspect_ratio_crop, caps);
gst_caps_unref (caps);
if (caps != NULL) {
gst_aspect_ratio_crop_set_caps (aspect_ratio_crop, caps);
gst_caps_unref (caps);
}
}
}