pad-monitor: add two useful macros for readability

Avoids using long macros and having to check for pad-monitor parent
existance
This commit is contained in:
Thiago Santos 2013-08-29 11:47:58 -03:00
parent f5f4635d0e
commit a426198916

View file

@ -45,6 +45,18 @@ G_DEFINE_TYPE (GstValidatePadMonitor, gst_validate_pad_monitor,
#define PENDING_FIELDS "pending-fields"
#define PAD_PARENT_IS_DEMUXER(m) \
(GST_VALIDATE_MONITOR_GET_PARENT(m) ? \
GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DEMUXER ( \
GST_VALIDATE_MONITOR_GET_PARENT(m)) : \
FALSE)
#define PAD_PARENT_IS_DECODER(m) \
(GST_VALIDATE_MONITOR_GET_PARENT(m) ? \
GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DECODER ( \
GST_VALIDATE_MONITOR_GET_PARENT(m)) : \
FALSE)
/*
* Locking the parent should always be done before locking the
* pad-monitor to prevent deadlocks in case another monitor from
@ -280,6 +292,10 @@ gst_validate_pad_monitor_pad_should_proxy_othercaps (GstValidatePadMonitor *
monitor)
{
GstValidateMonitor *parent = GST_VALIDATE_MONITOR_GET_PARENT (monitor);
if (!parent)
return FALSE;
/* We only know how to handle othercaps checks for codecs so far */
return GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DECODER (parent) ||
GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_ENCODER (parent);
@ -843,8 +859,7 @@ gst_validate_pad_monitor_check_aggregated_return (GstValidatePadMonitor *
return;
}
if (GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DEMUXER (monitor)
&& ret == GST_FLOW_EOS) {
if (PAD_PARENT_IS_DEMUXER (monitor) && ret == GST_FLOW_EOS) {
/* a demuxer can return EOS when the samples end */
return;
}
@ -1464,9 +1479,8 @@ gst_validate_pad_monitor_buffer_probe (GstPad * pad, GstBuffer * buffer,
gst_validate_pad_monitor_check_late_serialized_events (monitor,
GST_BUFFER_TIMESTAMP (buffer));
if (G_LIKELY (parent)) {
/* a GstValidatePadMonitor parent must be a GstValidateElementMonitor */
if (GST_VALIDATE_ELEMENT_MONITOR_ELEMENT_IS_DECODER (parent)) {
if (PAD_PARENT_IS_DECODER (parent)) {
/* should not push out of segment data */
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer)) &&
GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buffer)) &&
@ -1484,7 +1498,6 @@ gst_validate_pad_monitor_buffer_probe (GstPad * pad, GstBuffer * buffer,
GST_TIME_ARGS (monitor->segment.stop));
}
}
}
GST_VALIDATE_MONITOR_UNLOCK (monitor);
GST_VALIDATE_PAD_MONITOR_PARENT_UNLOCK (monitor);