mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
plugins/multiqueue: Cache input/output time, avoid expensive calls.
* Cache the input/output time * Only recalculate it when needed. Avoids 50% calls to gst_segment_to_running_time
This commit is contained in:
parent
cfb4aa4627
commit
c15879f94e
1 changed files with 41 additions and 9 deletions
|
@ -133,9 +133,16 @@ struct _GstSingleQueue
|
||||||
|
|
||||||
/* flowreturn of previous srcpad push */
|
/* flowreturn of previous srcpad push */
|
||||||
GstFlowReturn srcresult;
|
GstFlowReturn srcresult;
|
||||||
|
|
||||||
|
/* segments */
|
||||||
GstSegment sink_segment;
|
GstSegment sink_segment;
|
||||||
GstSegment src_segment;
|
GstSegment src_segment;
|
||||||
|
|
||||||
|
/* position of src/sink */
|
||||||
|
GstClockTime sinktime, srctime;
|
||||||
|
/* TRUE if either position needs to be recalculated */
|
||||||
|
gboolean sink_tainted, src_tainted;
|
||||||
|
|
||||||
/* queue of data */
|
/* queue of data */
|
||||||
GstDataQueue *queue;
|
GstDataQueue *queue;
|
||||||
GstDataQueueSize max_size, extra_size;
|
GstDataQueueSize max_size, extra_size;
|
||||||
|
@ -592,6 +599,7 @@ gst_single_queue_flush (GstMultiQueue * mq, GstSingleQueue * sq, gboolean flush)
|
||||||
|
|
||||||
GST_LOG_OBJECT (mq, "SingleQueue %d : pausing task", sq->id);
|
GST_LOG_OBJECT (mq, "SingleQueue %d : pausing task", sq->id);
|
||||||
result = gst_pad_pause_task (sq->srcpad);
|
result = gst_pad_pause_task (sq->srcpad);
|
||||||
|
sq->sink_tainted = sq->src_tainted = TRUE;
|
||||||
} else {
|
} else {
|
||||||
gst_data_queue_flush (sq->queue);
|
gst_data_queue_flush (sq->queue);
|
||||||
gst_segment_init (&sq->sink_segment, GST_FORMAT_TIME);
|
gst_segment_init (&sq->sink_segment, GST_FORMAT_TIME);
|
||||||
|
@ -622,16 +630,25 @@ update_time_level (GstMultiQueue * mq, GstSingleQueue * sq)
|
||||||
{
|
{
|
||||||
gint64 sink_time, src_time;
|
gint64 sink_time, src_time;
|
||||||
|
|
||||||
sink_time =
|
if (sq->sink_tainted) {
|
||||||
gst_segment_to_running_time (&sq->sink_segment, GST_FORMAT_TIME,
|
sink_time = sq->sinktime =
|
||||||
sq->sink_segment.last_stop);
|
gst_segment_to_running_time (&sq->sink_segment, GST_FORMAT_TIME,
|
||||||
if (sink_time == GST_CLOCK_TIME_NONE)
|
sq->sink_segment.last_stop);
|
||||||
goto beach;
|
if (sink_time == GST_CLOCK_TIME_NONE)
|
||||||
|
goto beach;
|
||||||
|
sq->sink_tainted = FALSE;
|
||||||
|
} else
|
||||||
|
sink_time = sq->sinktime;
|
||||||
|
|
||||||
src_time = gst_segment_to_running_time (&sq->src_segment, GST_FORMAT_TIME,
|
if (sq->src_tainted) {
|
||||||
sq->src_segment.last_stop);
|
src_time = sq->srctime =
|
||||||
if (src_time == GST_CLOCK_TIME_NONE)
|
gst_segment_to_running_time (&sq->src_segment, GST_FORMAT_TIME,
|
||||||
goto beach;
|
sq->src_segment.last_stop);
|
||||||
|
if (src_time == GST_CLOCK_TIME_NONE)
|
||||||
|
goto beach;
|
||||||
|
sq->src_tainted = FALSE;
|
||||||
|
} else
|
||||||
|
src_time = sq->srctime;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mq,
|
GST_DEBUG_OBJECT (mq,
|
||||||
"queue %d, sink %" GST_TIME_FORMAT ", src %" GST_TIME_FORMAT, sq->id,
|
"queue %d, sink %" GST_TIME_FORMAT ", src %" GST_TIME_FORMAT, sq->id,
|
||||||
|
@ -680,6 +697,11 @@ apply_segment (GstMultiQueue * mq, GstSingleQueue * sq, GstEvent * event,
|
||||||
gst_segment_set_newsegment_full (segment, update,
|
gst_segment_set_newsegment_full (segment, update,
|
||||||
rate, arate, format, start, stop, time);
|
rate, arate, format, start, stop, time);
|
||||||
|
|
||||||
|
if (segment == &sq->sink_segment)
|
||||||
|
sq->sink_tainted = TRUE;
|
||||||
|
else
|
||||||
|
sq->src_tainted = TRUE;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mq,
|
GST_DEBUG_OBJECT (mq,
|
||||||
"queue %d, configured NEWSEGMENT %" GST_SEGMENT_FORMAT, sq->id, segment);
|
"queue %d, configured NEWSEGMENT %" GST_SEGMENT_FORMAT, sq->id, segment);
|
||||||
|
|
||||||
|
@ -710,6 +732,11 @@ apply_buffer (GstMultiQueue * mq, GstSingleQueue * sq, GstClockTime timestamp,
|
||||||
|
|
||||||
gst_segment_set_last_stop (segment, GST_FORMAT_TIME, timestamp);
|
gst_segment_set_last_stop (segment, GST_FORMAT_TIME, timestamp);
|
||||||
|
|
||||||
|
if (segment == &sq->sink_segment)
|
||||||
|
sq->sink_tainted = TRUE;
|
||||||
|
else
|
||||||
|
sq->src_tainted = TRUE;
|
||||||
|
|
||||||
/* calc diff with other end */
|
/* calc diff with other end */
|
||||||
update_time_level (mq, sq);
|
update_time_level (mq, sq);
|
||||||
GST_MULTI_QUEUE_MUTEX_UNLOCK (mq);
|
GST_MULTI_QUEUE_MUTEX_UNLOCK (mq);
|
||||||
|
@ -1440,6 +1467,11 @@ gst_single_queue_new (GstMultiQueue * mqueue)
|
||||||
sq->oldid = 0;
|
sq->oldid = 0;
|
||||||
sq->turn = g_cond_new ();
|
sq->turn = g_cond_new ();
|
||||||
|
|
||||||
|
sq->sinktime = GST_CLOCK_TIME_NONE;
|
||||||
|
sq->srctime = GST_CLOCK_TIME_NONE;
|
||||||
|
sq->sink_tainted = TRUE;
|
||||||
|
sq->src_tainted = TRUE;
|
||||||
|
|
||||||
tmp = g_strdup_printf ("sink%d", sq->id);
|
tmp = g_strdup_printf ("sink%d", sq->id);
|
||||||
sq->sinkpad = gst_pad_new_from_static_template (&sinktemplate, tmp);
|
sq->sinkpad = gst_pad_new_from_static_template (&sinktemplate, tmp);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
|
Loading…
Reference in a new issue