mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 16:52:42 +00:00
audiolatency: Fix string format specifier and use microseconds everywhere
Should fix warnings or build errors on 32-bit platforms and on Windows. Also clarify in logging that all timestamps are in microseconds.
This commit is contained in:
parent
307865ec7a
commit
5089ab3428
1 changed files with 13 additions and 10 deletions
|
@ -261,8 +261,8 @@ gst_audiolatency_set_latency (GstAudioLatency * self, gint64 latency)
|
||||||
avg_latency = gst_audiolatency_get_average_latency_unlocked (self);
|
avg_latency = gst_audiolatency_get_average_latency_unlocked (self);
|
||||||
|
|
||||||
if (self->print_latency)
|
if (self->print_latency)
|
||||||
g_print ("last latency: %lims, running average: %lims\n", latency / 1000,
|
g_print ("last latency: %" G_GINT64_FORMAT "ms, running average: %"
|
||||||
avg_latency / 1000);
|
G_GINT64_FORMAT "ms\n", latency / 1000, avg_latency / 1000);
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
|
||||||
/* Post an element message about it */
|
/* Post an element message about it */
|
||||||
|
@ -321,7 +321,7 @@ buffer_has_wave (GstBuffer * buffer, GstPad * pad)
|
||||||
for (ii = 1; ii < fsize; ii += channels) {
|
for (ii = 1; ii < fsize; ii += channels) {
|
||||||
if (ABS (fdata[ii]) > 0.7) {
|
if (ABS (fdata[ii]) > 0.7) {
|
||||||
/* The waveform probably starts somewhere inside the buffer,
|
/* The waveform probably starts somewhere inside the buffer,
|
||||||
* so return the offset from the buffer pts */
|
* so get the offset in nanoseconds from the buffer pts */
|
||||||
offset = gst_util_uint64_scale_int_round (duration, ii, fsize);
|
offset = gst_util_uint64_scale_int_round (duration, ii, fsize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,8 @@ buffer_has_wave (GstBuffer * buffer, GstPad * pad)
|
||||||
else
|
else
|
||||||
gst_buffer_unmap (buffer, &minfo);
|
gst_buffer_unmap (buffer, &minfo);
|
||||||
|
|
||||||
return offset;
|
/* Return offset in microseconds */
|
||||||
|
return offset / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadProbeReturn
|
static GstPadProbeReturn
|
||||||
|
@ -362,11 +363,12 @@ gst_audiolatency_src_probe (GstPad * pad, GstPadProbeInfo * info,
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
pts -= offset / 1000;
|
pts -= offset;
|
||||||
GST_INFO ("send pts: %li (after %lims, offset %lims)", pts,
|
GST_INFO ("send pts: %" G_GINT64_FORMAT "us (after %" G_GINT64_FORMAT
|
||||||
(pts - self->send_pts) / 1000, offset / 1000000);
|
"ms, offset %" G_GINT64_FORMAT "ms)", pts,
|
||||||
|
(pts - self->send_pts) / 1000, offset / 1000);
|
||||||
|
|
||||||
self->send_pts = pts + offset / 1000;
|
self->send_pts = pts + offset;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return GST_PAD_PROBE_OK;
|
return GST_PAD_PROBE_OK;
|
||||||
|
@ -390,7 +392,7 @@ gst_audiolatency_sink_chain (GstPad * pad, GstObject * parent,
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
pts += offset / 1000;
|
pts += offset;
|
||||||
/* Only measure latency using the first buffer of each tick wave */
|
/* Only measure latency using the first buffer of each tick wave */
|
||||||
if (pts - self->recv_pts <= 950 * 1000)
|
if (pts - self->recv_pts <= 950 * 1000)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -399,7 +401,8 @@ gst_audiolatency_sink_chain (GstPad * pad, GstObject * parent,
|
||||||
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);
|
||||||
|
|
||||||
GST_INFO ("recv pts: %li, latency: %lims", self->recv_pts, latency / 1000);
|
GST_INFO ("recv pts: %" G_GINT64_FORMAT "us, latency: %" G_GINT64_FORMAT "ms",
|
||||||
|
self->recv_pts, latency / 1000);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
Loading…
Reference in a new issue