audiovisualizer: Fix calculations for bytes<->samples conversions
authorThomas Jones <thomas.jones@utoronto.ca>
Sat, 11 Jun 2016 02:36:32 +0000 (22:36 -0400)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 11 Jun 2016 08:45:51 +0000 (11:45 +0300)
Use bpf instead of channels * sizeof(gint16).

https://bugzilla.gnome.org/show_bug.cgi?id=767505

gst-libs/gst/pbutils/gstaudiovisualizer.c

index 09c3d80..717c2be 100644 (file)
@@ -1036,7 +1036,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
   guint64 dist, ts;
   guint avail, sbpf;
   gpointer adata;
-  gint bpf, channels, rate;
+  gint bpf, rate;
 
   scope = GST_AUDIO_VISUALIZER (parent);
   klass = GST_AUDIO_VISUALIZER_CLASS (G_OBJECT_GET_CLASS (scope));
@@ -1056,7 +1056,6 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
     }
   }
 
-  channels = GST_AUDIO_INFO_CHANNELS (&scope->ainfo);
   rate = GST_AUDIO_INFO_RATE (&scope->ainfo);
   bpf = GST_AUDIO_INFO_BPF (&scope->ainfo);
 
@@ -1070,7 +1069,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
   g_mutex_lock (&scope->priv->config_lock);
 
   /* this is what we want */
-  sbpf = scope->req_spf * channels * sizeof (gint16);
+  sbpf = scope->req_spf * bpf;
 
   inbuf = scope->priv->inbuf;
   /* FIXME: the timestamp in the adapter would be different */
@@ -1134,7 +1133,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
     ret = default_prepare_output_buffer (scope, &outbuf);
     g_mutex_lock (&scope->priv->config_lock);
     /* recheck as the value could have changed */
-    sbpf = scope->req_spf * channels * sizeof (gint16);
+    sbpf = scope->req_spf * bpf;
 
     /* no buffer allocated, we don't care why. */
     if (ret != GST_FLOW_OK)
@@ -1192,7 +1191,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
 
   skip:
     /* recheck as the value could have changed */
-    sbpf = scope->req_spf * channels * sizeof (gint16);
+    sbpf = scope->req_spf * bpf;
     GST_LOG_OBJECT (scope, "avail: %u, bpf: %u", avail, sbpf);
     /* we want to take less or more, depending on spf : req_spf */
     if (avail - sbpf >= sbpf) {