From 721e415fd203807a2c1b51435b08574bd7b963fc Mon Sep 17 00:00:00 2001 From: Thomas Jones Date: Fri, 10 Jun 2016 22:50:41 -0400 Subject: [PATCH] audiovisualizer: fix timestamp calculation for audio channels > 1 We have to use bps*channels instead of just bps, which is exactly what bpf is for. https://bugzilla.gnome.org/show_bug.cgi?id=767507 --- gst-libs/gst/pbutils/gstaudiovisualizer.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/pbutils/gstaudiovisualizer.c b/gst-libs/gst/pbutils/gstaudiovisualizer.c index 39b6b8a..134ea2e 100644 --- a/gst-libs/gst/pbutils/gstaudiovisualizer.c +++ b/gst-libs/gst/pbutils/gstaudiovisualizer.c @@ -1036,7 +1036,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent, guint64 dist, ts; guint avail, sbpf; gpointer adata; - gint bps, channels, rate; + gint bpf, channels, rate; scope = GST_AUDIO_VISUALIZER (parent); klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope)); @@ -1058,9 +1058,9 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent, channels = GST_AUDIO_INFO_CHANNELS (&scope->ainfo); rate = GST_AUDIO_INFO_RATE (&scope->ainfo); - bps = GST_AUDIO_INFO_BPS (&scope->ainfo); + bpf = GST_AUDIO_INFO_BPF (&scope->ainfo); - if (bps == 0) { + if (bpf == 0) { ret = GST_FLOW_NOT_NEGOTIATED; goto beach; } @@ -1087,8 +1087,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent, ts = gst_adapter_prev_pts (scope->priv->adapter, &dist); if (GST_CLOCK_TIME_IS_VALID (ts)) { /* convert bytes to time */ - dist /= bps; - ts += gst_util_uint64_scale_int (dist, GST_SECOND, rate); + ts += gst_util_uint64_scale_int (dist, GST_SECOND, rate * bpf); } /* check for QoS, don't compute buffers that are known to be late */ -- 2.7.4