Pacing sink with gst_base_sink_wait_clock()
mpaklin at hotmail.com
Thu Jan 12 10:29:48 PST 2012
I am trying to figure out the right way to do custom pipeline pacing in my
For variety of reasons default sync behavior does not work for me, so my
sink has it off with gst_base_sink_set_sync(FALSE).
After processing a buffer I calculate for how long the sink needs to block
and then it needs to do a pipeline-friendly version of sleep().
Can anyone suggest how it can be done?
Obviously calling sleep() works, but it delays state transitions by the time
of the sleep (worst case), which is not what anyone would want.
I saw gst_base_sink_wait_clock(), which seemed like the right thing to use,
but it only works when the synchronization for the sink is on.
To hack something together I wrote this
void my_sink_sleep(GstBaseSink* basesink, guint delay_ms)
if ((clock = GST_ELEMENT_CLOCK(basesink)) != NULL)
/* Get current clock time */
time = gst_clock_get_time(clock);
/* Add our sleep time */
time += GST_MSECOND * delay_ms;
/* Subtract base time as this is what gst_base_sink_wait_clock()
will add */
time -= GST_ELEMENT_CAST(basesink)->base_time;
/* BUGBUG: this does not look right, but it does what I need */
gst_base_sink_wait_clock(basesink, time, NULL);
This works, but it does not look right.
More information about the gstreamer-devel