[vlc-commits] audiobargraph_a: split function

Rafaël Carré git at videolan.org
Wed Apr 16 14:46:41 CEST 2014


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Wed Apr 16 14:35:59 2014 +0200| [fd18a305cbb5fe8e882d8bfd95905e1799d42a3b] | committer: Rafaël Carré

audiobargraph_a: split function

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fd18a305cbb5fe8e882d8bfd95905e1799d42a3b
---

 modules/audio_filter/audiobargraph_a.c |   34 ++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/modules/audio_filter/audiobargraph_a.c b/modules/audio_filter/audiobargraph_a.c
index e7f4795..64cab12 100644
--- a/modules/audio_filter/audiobargraph_a.c
+++ b/modules/audio_filter/audiobargraph_a.c
@@ -139,6 +139,24 @@ static int Open( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
+static void SendValues(filter_t *p_filter, float *value, int nbChannels)
+{
+    char message[256];
+    size_t len = 0;
+
+    for (int i = 0; i < nbChannels; i++) {
+        if (len >= sizeof(message))
+            break;
+        len += snprintf(message + len, sizeof (message),"%f:", value[i]);
+    }
+
+    message[len-1] = '\0';
+    msg_Dbg(p_filter, "values: %s", message);
+
+    var_SetString(p_filter->p_libvlc, "audiobargraph_v-i_values",
+            message);
+}
+
 /*****************************************************************************
  * DoWork: treat an audio buffer
  ****************************************************************************/
@@ -210,22 +228,8 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
     }
 
     if (p_sys->bargraph && nbChannels > 0 && p_sys->counter++ > p_sys->bargraph_repetition) {
-        /* 6 - send the message with the values for the BarGraph */
+        SendValues(p_filter, i_value, nbChannels);
         p_sys->counter = 0;
-        char message[256];
-        size_t len = 0;
-
-        for (int i = 0; i < nbChannels; i++) {
-            if (len >= sizeof(message))
-                break;
-            len += snprintf(message + len, sizeof (message),"%f:", i_value[i]);
-        }
-
-        message[len-1] = '\0';
-        msg_Dbg(p_filter, "values: %s", message);
-
-        var_SetString(p_filter->p_libvlc, "audiobargraph_v-i_values",
-                message);
     }
 
     return p_in_buf;



More information about the vlc-commits mailing list