changeset 4604:51d82bf6ba63

Use a define (AUD_EQUALIZER_NBANDS) instead of magic value 10 everywhere.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Jun 2008 22:27:06 +0300
parents fba10959a743
children 9df19c4900ba
files src/audacious/audconfig.c src/audacious/audconfig.h src/audacious/dbus.c src/audacious/objects.xml src/audacious/ui_equalizer.c src/audacious/ui_skinned_equalizer_graph.c
diffstat 6 files changed, 18 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/audconfig.c	Wed Jun 04 22:05:50 2008 +0300
+++ b/src/audacious/audconfig.c	Wed Jun 04 22:27:06 2008 +0300
@@ -510,8 +510,8 @@
 
     /* Preset */
     cfg_db_get_float(db, NULL, "equalizer_preamp", &cfg.equalizer_preamp);
-    for (i = 0; i < 10; i++) {
-        gchar eqtext[18];
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) {
+        gchar eqtext[32];
 
         g_snprintf(eqtext, sizeof(eqtext), "equalizer_band%d", i);
         cfg_db_get_float(db, NULL, eqtext, &cfg.equalizer_bands[i]);
--- a/src/audacious/audconfig.h	Wed Jun 04 22:05:50 2008 +0300
+++ b/src/audacious/audconfig.h	Wed Jun 04 22:27:06 2008 +0300
@@ -28,6 +28,8 @@
 
 #include <glib.h>
 
+#define AUD_EQUALIZER_NBANDS    (10)
+
 struct _AudConfig {
     gint player_x, player_y;
     gint equalizer_x, equalizer_y;
@@ -62,7 +64,7 @@
     gboolean allow_broken_skins;
     gboolean close_dialog_open;
     gboolean close_dialog_add;
-    gfloat equalizer_preamp, equalizer_bands[10];
+    gfloat equalizer_preamp, equalizer_bands[AUD_EQUALIZER_NBANDS];
     gfloat scale_factor;
     gchar *skin;
     gchar *outputplugin;
--- a/src/audacious/dbus.c	Wed Jun 04 22:05:50 2008 +0300
+++ b/src/audacious/dbus.c	Wed Jun 04 22:27:06 2008 +0300
@@ -558,6 +558,7 @@
     return TRUE;
 }
 
+
 // Playback Information/Manipulation
 gboolean audacious_rc_play(RemoteObject *obj, GError **error) {
     if (playback_get_paused())
@@ -947,9 +948,9 @@
     int i;
 
     *preamp = (gdouble)equalizerwin_get_preamp();
-    *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), 10);
+    *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), AUD_EQUALIZER_NBANDS);
 
-    for(i=0; i<10; i++){
+    for(i=0; i < AUD_EQUALIZER_NBANDS; i++){
         gdouble val = (gdouble)equalizerwin_get_band(i);
         g_array_append_val(*bands, val);
     }
@@ -976,7 +977,7 @@
     
     equalizerwin_set_preamp((gfloat)preamp);
 
-    for (i = 0; i < 10; i++) {
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) {
         element = g_array_index(bands, gdouble, i);
         equalizerwin_set_band(i, (gfloat)element);
     }
--- a/src/audacious/objects.xml	Wed Jun 04 22:05:50 2008 +0300
+++ b/src/audacious/objects.xml	Wed Jun 04 22:27:06 2008 +0300
@@ -473,7 +473,6 @@
 
         <!-- equalizer -->
         <method name="GetEq">
-            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
             <arg type="d" direction="out" name="preamp"/>
             <arg type="ad" direction="out" name="bands"/>
         </method>
--- a/src/audacious/ui_equalizer.c	Wed Jun 04 22:05:50 2008 +0300
+++ b/src/audacious/ui_equalizer.c	Wed Jun 04 22:27:06 2008 +0300
@@ -69,7 +69,7 @@
 
 struct _EqualizerPreset {
     gchar *name;
-    gfloat preamp, bands[10];
+    gfloat preamp, bands[AUD_EQUALIZER_NBANDS];
 };
 
 typedef struct _EqualizerPreset EqualizerPreset;
@@ -90,7 +90,7 @@
 static GtkWidget *equalizerwin_on, *equalizerwin_auto;
 
 static GtkWidget *equalizerwin_close, *equalizerwin_presets, *equalizerwin_shade;
-static GtkWidget *equalizerwin_preamp,*equalizerwin_bands[10];
+static GtkWidget *equalizerwin_preamp,*equalizerwin_bands[AUD_EQUALIZER_NBANDS];
 static GtkWidget *equalizerwin_volume, *equalizerwin_balance;
 
 static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL;
@@ -188,7 +188,7 @@
     gint i;
 
     cfg.equalizer_preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
-    for (i = 0; i < 10; i++)
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
         cfg.equalizer_bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]);
     /* um .. i think we need both of these for xmms compatibility ..
        not sure. -larne */
@@ -325,15 +325,15 @@
     g_free(filename);
 
     for (;;) {
-        gchar section[21];
+        gchar section[32];
 
         g_snprintf(section, sizeof(section), "Preset%d", p++);
         if (aud_rcfile_read_string(rcfile, "Presets", section, &name)) {
             preset = g_new0(EqualizerPreset, 1);
             preset->name = name;
             aud_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp);
-            for (i = 0; i < 10; i++) {
-                gchar band[7];
+            for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) {
+                gchar band[16];
                 g_snprintf(band, sizeof(band), "Band%d", i);
                 aud_rcfile_read_float(rcfile, name, band, &preset->bands[i]);
             }
@@ -467,7 +467,7 @@
     equalizerwin_preamp = ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 21, 38);
     ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, cfg.equalizer_preamp);
 
-    for (i = 0; i < 10; i++) {
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) {
         equalizerwin_bands[i] =
             ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 78 + (i * 18), 38);
         ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], cfg.equalizer_bands[i]);
--- a/src/audacious/ui_skinned_equalizer_graph.c	Wed Jun 04 22:05:50 2008 +0300
+++ b/src/audacious/ui_skinned_equalizer_graph.c	Wed Jun 04 22:27:06 2008 +0300
@@ -252,10 +252,10 @@
 
     skin_get_eq_spline_colors(aud_active_skin, cols);
 
-    __init_spline(x, cfg.equalizer_bands, 10, yf);
+    __init_spline(x, cfg.equalizer_bands, AUD_EQUALIZER_NBANDS, yf);
     for (i = 0; i < 109; i++) {
         y = 9 -
-            (gint) ((eval_spline(x, cfg.equalizer_bands, yf, 10, i) *
+            (gint) ((eval_spline(x, cfg.equalizer_bands, yf, AUD_EQUALIZER_NBANDS, i) *
                      9.0) / EQUALIZER_MAX_GAIN);
         if (y < 0)
             y = 0;