Skip to content
Snippets Groups Projects

alphacombine: De-couple flush-start/stop events handling

Merged Philippe Normand requested to merge philn/gstreamer:issue-4174 into main
@@ -174,6 +174,31 @@ pad_blocked (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
@@ -174,6 +174,31 @@ pad_blocked (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
return GST_PAD_PROBE_OK;
return GST_PAD_PROBE_OK;
}
}
 
/* Has to be called with buffer_lock held */
 
static void
 
gst_alpha_combine_clear_sink_pad_probe (GstAlphaCombine * self)
 
{
 
if (!self->pad_block_id)
 
return;
 
 
g_assert (self->blocked_pad);
 
gst_pad_remove_probe (self->blocked_pad, self->pad_block_id);
 
self->pad_block_id = 0;
 
self->blocked_pad = NULL;
 
}
 
 
/* Has to be called with buffer_lock held */
 
static void
 
gst_alpha_combine_unlock_reset_flushing_state (GstAlphaCombine * self)
 
{
 
self->flushing = FALSE;
 
self->flush_stops = 0;
 
 
/* Reset the format cookies to ensure they are equal */
 
self->sink_format_cookie = 0;
 
self->alpha_format_cookie = 0;
 
}
 
static void
static void
gst_alpha_combine_unlock_stop (GstAlphaCombine * self, GstPad * pad)
gst_alpha_combine_unlock_stop (GstAlphaCombine * self, GstPad * pad)
{
{
@@ -185,11 +210,7 @@ gst_alpha_combine_unlock_stop (GstAlphaCombine * self, GstPad * pad)
@@ -185,11 +210,7 @@ gst_alpha_combine_unlock_stop (GstAlphaCombine * self, GstPad * pad)
if (self->flush_stops == 2) {
if (self->flush_stops == 2) {
GST_DEBUG_OBJECT (self,
GST_DEBUG_OBJECT (self,
"Both sink pads received FLUSH_STOP, unblocking them");
"Both sink pads received FLUSH_STOP, unblocking them");
g_assert (self->pad_block_id);
gst_alpha_combine_clear_sink_pad_probe (self);
g_assert (self->blocked_pad);
gst_pad_remove_probe (self->blocked_pad, self->pad_block_id);
self->pad_block_id = 0;
self->blocked_pad = NULL;
} else {
} else {
GST_DEBUG_OBJECT (pad, "FLUSH_STOP received, blocking");
GST_DEBUG_OBJECT (pad, "FLUSH_STOP received, blocking");
g_assert (!self->pad_block_id);
g_assert (!self->pad_block_id);
@@ -203,22 +224,19 @@ gst_alpha_combine_unlock_stop (GstAlphaCombine * self, GstPad * pad)
@@ -203,22 +224,19 @@ gst_alpha_combine_unlock_stop (GstAlphaCombine * self, GstPad * pad)
}
}
}
}
self->flushing = FALSE;
gst_alpha_combine_unlock_reset_flushing_state (self);
self->flush_stops = 0;
/* Reset the format cookies to ensure they are equal */
self->sink_format_cookie = 0;
self->alpha_format_cookie = 0;
g_mutex_unlock (&self->buffer_lock);
g_mutex_unlock (&self->buffer_lock);
}
}
static void
static void
gst_alpha_combine_reset (GstAlphaCombine * self)
gst_alpha_combine_reset (GstAlphaCombine * self)
{
{
 
g_mutex_lock (&self->buffer_lock);
 
gst_alpha_combine_clear_sink_pad_probe (self);
gst_buffer_replace (&self->alpha_buffer, NULL);
gst_buffer_replace (&self->alpha_buffer, NULL);
gst_buffer_replace (&self->last_alpha_buffer, NULL);
gst_buffer_replace (&self->last_alpha_buffer, NULL);
self->last_flow_ret = GST_FLOW_OK;
self->last_flow_ret = GST_FLOW_OK;
 
g_mutex_unlock (&self->buffer_lock);
}
}
/*
/*
@@ -627,7 +645,9 @@ gst_alpha_combine_change_state (GstElement * element, GstStateChange transition)
@@ -627,7 +645,9 @@ gst_alpha_combine_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
case GST_STATE_CHANGE_READY_TO_PAUSED:
gst_alpha_combine_unlock_stop (self, NULL);
g_mutex_lock (&self->buffer_lock);
 
gst_alpha_combine_unlock_reset_flushing_state (self);
 
g_mutex_unlock (&self->buffer_lock);
break;
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_alpha_combine_unlock (self);
gst_alpha_combine_unlock (self);
Loading