gst_element_query_position doesn't always return the right frame number
Submitted by Gregoire
Link to original bug (#763522)
Description
Created attachment 323743
Log amc*:6
This might not be a bug, I don't know. It seems that on some rare occasions, gst_element_query_position returns the real frame number+1 or the real frame number-1.
My pipeline on Android 6.0.1 with gstreamer-1.7.90 is:
filesrc location=path ! queue ! decodebin ! queue ! identity ! glimagesink
On the identity element, I have a pad callback:
GstPad *pad = gst_element_get_static_pad(identity, "sink");
gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, (GstPadProbeCallback)cb_have_data_0, data, NULL);
in which I do:
frameNbInc++;
gst_element_query_position(pipeline, GST_FORMAT_DEFAULT, &frameNb);
GST_DEBUG("%lld %lld %lld", frameNb, frameNbInc, frameNb - frameNbInc);
The debug log of amc*6 is attached.
On line 53 and 138, I have frameNb - frameNbInc == 1 while the delta between an internal incremental counter frameNbInc and the frame number returned by gst_element_query_position should be 2 and is 2 almost all the time.
The delta of -1 always happens after the "Queueing buffer", for instance lines 41 to 52, or lines 123 to 137.
Sometimes, the delta is +1 like on line 264. It seems that there was a race condition between line 263 and 264.
Is this a bug? Or how can I be sure to have gst_element_query_position to return the equivalent of an incremental number with the condition that the system is not late, aka. everything runs smoothly like in this trace.
Attachment 323743, "Log amc*:6":
log
Version: 1.7.90