audiolatency: Fix wave detection in buffers

-1/1000 is 0, so we were *always* detecting a buffer.
This commit is contained in:
Nirbheek Chauhan 2018-04-03 23:54:41 +05:30
parent 2ee16a5810
commit 8649cef462

View file

@ -335,7 +335,7 @@ buffer_has_wave (GstBuffer * buffer, GstPad * pad)
gst_buffer_unmap (buffer, &minfo); gst_buffer_unmap (buffer, &minfo);
/* Return offset in microseconds */ /* Return offset in microseconds */
return offset / 1000; return (offset > 0) ? offset / 1000 : -1;
} }
static GstPadProbeReturn static GstPadProbeReturn
@ -406,12 +406,7 @@ gst_audiolatency_sink_chain (GstPad * pad, GstObject * parent,
if (offset < 0) if (offset < 0)
goto out; goto out;
pts += offset; self->recv_pts = pts + offset;
/* Only measure latency using the first buffer of each tick wave */
if (pts - self->recv_pts <= 950 * 1000)
goto out;
self->recv_pts = pts;
latency = (self->recv_pts - self->send_pts); latency = (self->recv_pts - self->send_pts);
gst_audiolatency_set_latency (self, latency); gst_audiolatency_set_latency (self, latency);