message: add the running-time to the async-done message

Add the running-time of the buffer that caused the async operation to complete
to the async-done message.
Update bin to handle the new async-done message.
This commit is contained in:
Wim Taymans 2012-06-13 10:52:48 +02:00
parent 9c8ee44f9b
commit 7b6ebd4b5b
4 changed files with 31 additions and 25 deletions

View file

@ -221,7 +221,7 @@ static void gst_bin_state_changed (GstElement * element, GstState oldstate,
static GstStateChangeReturn gst_bin_get_state_func (GstElement * element,
GstState * state, GstState * pending, GstClockTime timeout);
static void bin_handle_async_done (GstBin * bin, GstStateChangeReturn ret,
gboolean flag_pending, gboolean reset_time);
gboolean flag_pending, GstClockTime running_time);
static void bin_handle_async_start (GstBin * bin);
static void bin_push_state_continue (BinContinueData * data);
static void bin_do_eos (GstBin * bin);
@ -1134,7 +1134,7 @@ gst_bin_add_func (GstBin * bin, GstElement * element)
}
case GST_STATE_CHANGE_NO_PREROLL:
/* ignore all async elements we might have and commit our state */
bin_handle_async_done (bin, ret, FALSE, FALSE);
bin_handle_async_done (bin, ret, FALSE, GST_CLOCK_TIME_NONE);
break;
case GST_STATE_CHANGE_FAILURE:
break;
@ -1451,7 +1451,7 @@ gst_bin_remove_func (GstBin * bin, GstElement * element)
else
ret = GST_STATE_CHANGE_SUCCESS;
bin_handle_async_done (bin, ret, FALSE, FALSE);
bin_handle_async_done (bin, ret, FALSE, GST_CLOCK_TIME_NONE);
} else {
GST_DEBUG_OBJECT (bin,
"recalc state preroll: %d, other async: %d, this async %d",
@ -2696,7 +2696,8 @@ done:
bin_remove_messages (bin, NULL, GST_MESSAGE_ASYNC_DONE);
GST_DEBUG_OBJECT (bin, "async elements commited");
bin_handle_async_done (bin, GST_STATE_CHANGE_SUCCESS, FALSE, FALSE);
bin_handle_async_done (bin, GST_STATE_CHANGE_SUCCESS, FALSE,
GST_CLOCK_TIME_NONE);
}
state_end:
@ -2955,7 +2956,7 @@ was_no_preroll:
*/
static void
bin_handle_async_done (GstBin * bin, GstStateChangeReturn ret,
gboolean flag_pending, gboolean reset_time)
gboolean flag_pending, GstClockTime running_time)
{
GstState current, pending, target;
GstStateChangeReturn old_ret;
@ -2983,7 +2984,7 @@ bin_handle_async_done (GstBin * bin, GstStateChangeReturn ret,
target = GST_STATE_TARGET (bin);
pending = GST_STATE_PENDING (bin) = target;
amessage = gst_message_new_async_done (GST_OBJECT_CAST (bin), reset_time);
amessage = gst_message_new_async_done (GST_OBJECT_CAST (bin), running_time);
old_state = GST_STATE (bin);
/* this is the state we should go to next */
@ -3413,13 +3414,13 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message)
}
case GST_MESSAGE_ASYNC_DONE:
{
gboolean reset_time;
GstClockTime running_time;
GstState target;
GST_DEBUG_OBJECT (bin, "ASYNC_DONE message %p, %s", message,
src ? GST_OBJECT_NAME (src) : "(NULL)");
gst_message_parse_async_done (message, &reset_time);
gst_message_parse_async_done (message, &running_time);
GST_OBJECT_LOCK (bin);
bin_do_message_forward (bin, message);
@ -3441,7 +3442,8 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message)
* need to set the pending_done flag so that at the end of the state
* change we can see if we need to verify pending async elements, hence
* the TRUE argument here. */
bin_handle_async_done (bin, GST_STATE_CHANGE_SUCCESS, TRUE, reset_time);
bin_handle_async_done (bin, GST_STATE_CHANGE_SUCCESS, TRUE,
running_time);
} else {
GST_DEBUG_OBJECT (bin, "there are more async elements pending");
}

View file

@ -870,24 +870,26 @@ gst_message_new_async_start (GstObject * src)
/**
* gst_message_new_async_done:
* @src: (transfer none): The object originating the message.
* @reset_time: if the running_time should be reset
* @running_time: the desired running_time
*
* The message is posted when elements completed an ASYNC state change.
* @reset_time is set to TRUE when the element requests a new running_time
* before going to PLAYING.
* @running_time contains the time of the desired running_time when this
* elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
* means that the element has no clock interaction and thus doesn't care about
* the running_time of the pipeline.
*
* Returns: (transfer full): The new async_done message.
*
* MT safe.
*/
GstMessage *
gst_message_new_async_done (GstObject * src, gboolean reset_time)
gst_message_new_async_done (GstObject * src, GstClockTime running_time)
{
GstMessage *message;
GstStructure *structure;
structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
GST_QUARK (RESET_TIME), G_TYPE_BOOLEAN, reset_time, NULL);
GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
return message;
@ -1542,14 +1544,14 @@ gst_message_parse_duration (GstMessage * message, GstFormat * format,
/**
* gst_message_parse_async_done:
* @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
* @reset_time: (out): Result location for the reset_time or NULL
* @running_time: (out): Result location for the running_time or NULL
*
* Extract the reset_time from the async_done message.
* Extract the running_time from the async_done message.
*
* MT safe.
*/
void
gst_message_parse_async_done (GstMessage * message, gboolean * reset_time)
gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
{
GstStructure *structure;
@ -1557,10 +1559,10 @@ gst_message_parse_async_done (GstMessage * message, gboolean * reset_time)
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
structure = GST_MESSAGE_STRUCTURE (message);
if (reset_time)
*reset_time =
g_value_get_boolean (gst_structure_id_get_value (structure,
GST_QUARK (RESET_TIME)));
if (running_time)
*running_time =
g_value_get_uint64 (gst_structure_id_get_value (structure,
GST_QUARK (RUNNING_TIME)));
}
/**

View file

@ -502,8 +502,8 @@ GstMessage * gst_message_new_latency (GstObject * src) G_GNUC_MALLOC;
GstMessage * gst_message_new_async_start (GstObject * src) G_GNUC_MALLOC;
/* ASYNC_DONE */
GstMessage * gst_message_new_async_done (GstObject * src, gboolean reset_time) G_GNUC_MALLOC;
void gst_message_parse_async_done (GstMessage *message, gboolean *reset_time);
GstMessage * gst_message_new_async_done (GstObject * src, GstClockTime running_time) G_GNUC_MALLOC;
void gst_message_parse_async_done (GstMessage *message, GstClockTime *running_time);
/* STRUCTURE CHANGE */
GstMessage * gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,

View file

@ -1465,7 +1465,8 @@ gst_base_sink_commit_state (GstBaseSink * basesink)
if (post_async_done) {
GST_DEBUG_OBJECT (basesink, "posting async-done message");
gst_element_post_message (GST_ELEMENT_CAST (basesink),
gst_message_new_async_done (GST_OBJECT_CAST (basesink), FALSE));
gst_message_new_async_done (GST_OBJECT_CAST (basesink),
GST_CLOCK_TIME_NONE));
}
if (post_playing) {
GST_DEBUG_OBJECT (basesink, "posting PLAYING state change message");
@ -4804,7 +4805,8 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
GST_STATE_PLAYING, GST_STATE_PAUSED, GST_STATE_READY));
gst_element_post_message (GST_ELEMENT_CAST (basesink),
gst_message_new_async_done (GST_OBJECT_CAST (basesink), FALSE));
gst_message_new_async_done (GST_OBJECT_CAST (basesink),
GST_CLOCK_TIME_NONE));
}
priv->commited = TRUE;
} else {