mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 10:10:32 +00:00
vdpaumpegdec: use gst_pad_get_parent for threadsafety
This commit is contained in:
parent
702cc4a03f
commit
3fa60712f2
1 changed files with 41 additions and 23 deletions
|
@ -161,7 +161,7 @@ gst_vdp_mpeg_packetizer_init (GstVdpMpegPacketizer * packetizer,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vdp_mpeg_dec_set_caps (GstPad * pad, GstCaps * caps)
|
gst_vdp_mpeg_dec_set_caps (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (GST_OBJECT_PARENT (pad));
|
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (gst_pad_get_parent (pad));
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
@ -198,7 +198,7 @@ gst_vdp_mpeg_dec_set_caps (GstPad * pad, GstCaps * caps)
|
||||||
res = gst_pad_set_caps (mpeg_dec->src, src_caps);
|
res = gst_pad_set_caps (mpeg_dec->src, src_caps);
|
||||||
gst_caps_unref (src_caps);
|
gst_caps_unref (src_caps);
|
||||||
if (!res)
|
if (!res)
|
||||||
return FALSE;
|
goto done;
|
||||||
|
|
||||||
mpeg_dec->width = width;
|
mpeg_dec->width = width;
|
||||||
mpeg_dec->height = height;
|
mpeg_dec->height = height;
|
||||||
|
@ -274,9 +274,15 @@ gst_vdp_mpeg_dec_set_caps (GstPad * pad, GstCaps * caps)
|
||||||
("Could not create vdpau decoder"),
|
("Could not create vdpau decoder"),
|
||||||
("Error returned from vdpau was: %s",
|
("Error returned from vdpau was: %s",
|
||||||
device->vdp_get_error_string (status)));
|
device->vdp_get_error_string (status)));
|
||||||
return FALSE;
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
return TRUE;
|
res = TRUE;
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_object_unref (mpeg_dec);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
|
@ -605,13 +611,11 @@ gst_vdp_mpeg_dec_reset (GstVdpMpegDec * mpeg_dec)
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_vdp_mpeg_dec_chain (GstPad * pad, GstBuffer * buffer)
|
gst_vdp_mpeg_dec_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstVdpMpegDec *mpeg_dec;
|
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (gst_pad_get_parent (pad));
|
||||||
GstVdpMpegPacketizer packetizer;
|
GstVdpMpegPacketizer packetizer;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
|
|
||||||
mpeg_dec = GST_VDP_MPEG_DEC (GST_OBJECT_PARENT (pad));
|
|
||||||
|
|
||||||
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))) {
|
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))) {
|
||||||
GST_DEBUG_OBJECT (mpeg_dec, "Received discont buffer");
|
GST_DEBUG_OBJECT (mpeg_dec, "Received discont buffer");
|
||||||
gst_vdp_mpeg_dec_flush (mpeg_dec);
|
gst_vdp_mpeg_dec_flush (mpeg_dec);
|
||||||
|
@ -643,9 +647,9 @@ gst_vdp_mpeg_dec_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
case MPEG_PACKET_PICTURE:
|
case MPEG_PACKET_PICTURE:
|
||||||
GST_DEBUG_OBJECT (mpeg_dec, "MPEG_PACKET_PICTURE");
|
GST_DEBUG_OBJECT (mpeg_dec, "MPEG_PACKET_PICTURE");
|
||||||
|
|
||||||
if (!gst_vdp_mpeg_dec_parse_picture (mpeg_dec, buf)) {
|
if (!gst_vdp_mpeg_dec_parse_picture (mpeg_dec, buf))
|
||||||
return GST_FLOW_OK;
|
goto done;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MPEG_PACKET_SEQUENCE:
|
case MPEG_PACKET_SEQUENCE:
|
||||||
GST_DEBUG_OBJECT (mpeg_dec, "MPEG_PACKET_SEQUENCE");
|
GST_DEBUG_OBJECT (mpeg_dec, "MPEG_PACKET_SEQUENCE");
|
||||||
|
@ -688,6 +692,9 @@ gst_vdp_mpeg_dec_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
ret = gst_vdp_mpeg_dec_decode (mpeg_dec, GST_BUFFER_TIMESTAMP (buffer),
|
ret = gst_vdp_mpeg_dec_decode (mpeg_dec, GST_BUFFER_TIMESTAMP (buffer),
|
||||||
GST_BUFFER_SIZE (buffer));
|
GST_BUFFER_SIZE (buffer));
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_object_unref (mpeg_dec);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,16 +742,16 @@ gst_mpeg_dec_get_querytypes (GstPad * pad)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vdp_mpeg_dec_src_query (GstPad * pad, GstQuery * query)
|
gst_vdp_mpeg_dec_src_query (GstPad * pad, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (GST_OBJECT_PARENT (pad));
|
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (gst_pad_get_parent (pad));
|
||||||
gboolean res = FALSE;
|
gboolean res;
|
||||||
|
|
||||||
switch (GST_QUERY_TYPE (query)) {
|
switch (GST_QUERY_TYPE (query)) {
|
||||||
case GST_QUERY_POSITION:
|
case GST_QUERY_POSITION:
|
||||||
{
|
{
|
||||||
GstFormat format;
|
GstFormat format;
|
||||||
|
|
||||||
if (gst_pad_query_default (pad, query))
|
if ((res = gst_pad_query_default (pad, query)))
|
||||||
return TRUE;
|
goto done;
|
||||||
|
|
||||||
gst_query_parse_position (query, &format, NULL);
|
gst_query_parse_position (query, &format, NULL);
|
||||||
if (format == GST_FORMAT_TIME &&
|
if (format == GST_FORMAT_TIME &&
|
||||||
|
@ -760,8 +767,8 @@ gst_vdp_mpeg_dec_src_query (GstPad * pad, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstFormat format;
|
GstFormat format;
|
||||||
|
|
||||||
if (gst_pad_query_default (pad, query))
|
if ((res = gst_pad_query_default (pad, query)))
|
||||||
return TRUE;
|
goto done;
|
||||||
|
|
||||||
gst_query_parse_duration (query, &format, NULL);
|
gst_query_parse_duration (query, &format, NULL);
|
||||||
if (format == GST_FORMAT_TIME) {
|
if (format == GST_FORMAT_TIME) {
|
||||||
|
@ -787,13 +794,15 @@ gst_vdp_mpeg_dec_src_query (GstPad * pad, GstQuery * query)
|
||||||
res = gst_pad_query_default (pad, query);
|
res = gst_pad_query_default (pad, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_object_unref (mpeg_dec);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
normal_seek (GstPad * pad, GstEvent * event)
|
normal_seek (GstVdpMpegDec * mpeg_dec, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (GST_OBJECT_PARENT (pad));
|
|
||||||
gdouble rate;
|
gdouble rate;
|
||||||
GstFormat format, conv;
|
GstFormat format, conv;
|
||||||
GstSeekFlags flags;
|
GstSeekFlags flags;
|
||||||
|
@ -853,28 +862,33 @@ convert_failed:
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vdp_mpeg_dec_src_event (GstPad * pad, GstEvent * event)
|
gst_vdp_mpeg_dec_src_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
|
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (gst_pad_get_parent (pad));
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_SEEK:
|
case GST_EVENT_SEEK:
|
||||||
{
|
{
|
||||||
if (gst_pad_event_default (pad, event))
|
if ((res = gst_pad_event_default (pad, event)))
|
||||||
return TRUE;
|
goto done;
|
||||||
|
|
||||||
|
res = normal_seek (mpeg_dec, event);
|
||||||
|
|
||||||
res = normal_seek (pad, event);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
res = gst_pad_event_default (pad, event);
|
res = gst_pad_event_default (pad, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_object_unref (mpeg_dec);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vdp_mpeg_dec_sink_event (GstPad * pad, GstEvent * event)
|
gst_vdp_mpeg_dec_sink_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (GST_OBJECT_PARENT (pad));
|
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (gst_pad_get_parent (pad));
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
|
@ -919,7 +933,8 @@ gst_vdp_mpeg_dec_sink_event (GstPad * pad, GstEvent * event)
|
||||||
* use the calculated timestamp of the first frame for this */
|
* use the calculated timestamp of the first frame for this */
|
||||||
if (mpeg_dec->seeking) {
|
if (mpeg_dec->seeking) {
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
return TRUE;
|
res = TRUE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_error:
|
convert_error:
|
||||||
|
@ -931,6 +946,9 @@ gst_vdp_mpeg_dec_sink_event (GstPad * pad, GstEvent * event)
|
||||||
res = gst_pad_event_default (pad, event);
|
res = gst_pad_event_default (pad, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_object_unref (mpeg_dec);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue