changeset 4848:b2ee645f3e59

Hook up the equalizer (bug #24)
author John Lindgren <john.lindgren@tds.net>
date Sun, 12 Apr 2009 23:03:39 -0400
parents d13bf8d71b99
children 123b35cd71ab
files src/audlegacy/equalizer.c src/audlegacy/equalizer.h src/audlegacy/hook.c src/audlegacy/main.c
diffstat 4 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/audlegacy/equalizer.c	Sun Apr 12 19:58:12 2009 -0400
+++ b/src/audlegacy/equalizer.c	Sun Apr 12 23:03:39 2009 -0400
@@ -18,11 +18,23 @@
  */
 
 #include "equalizer.h"
+#include "hook.h"
 #include "output.h"
 
 #include "audconfig.h"
 #include "legacy/ui_equalizer.h"
 
+static void change_equalizer (void) {
+   output_set_eq (cfg.equalizer_active, cfg.equalizer_preamp,
+    cfg.equalizer_bands);
+}
+
+void init_equalizer (void) {
+   hook_register ("equalizer changed");
+   if (hook_associate ("equalizer changed", (HookFunction) change_equalizer, 0))
+      abort ();
+}
+
 gfloat
 equalizer_get_preamp(void)
 {
--- a/src/audlegacy/equalizer.h	Sun Apr 12 19:58:12 2009 -0400
+++ b/src/audlegacy/equalizer.h	Sun Apr 12 23:03:39 2009 -0400
@@ -22,6 +22,8 @@
 
 #include <glib.h>
 
+void init_equalizer (void);
+
 gfloat equalizer_get_preamp(void);
 void equalizer_set_preamp(gfloat preamp);
 gfloat equalizer_get_band(gint band);
--- a/src/audlegacy/hook.c	Sun Apr 12 19:58:12 2009 -0400
+++ b/src/audlegacy/hook.c	Sun Apr 12 23:03:39 2009 -0400
@@ -17,6 +17,7 @@
  *  Audacious or using our public API to be a derived work.
  */
 
+#include <stdio.h>
 #include <glib.h>
 #include "hook.h"
 
@@ -122,8 +123,10 @@
 
     hook = hook_find(name);
 
-    if (hook == NULL)
+    if (hook == NULL) {
+        printf ("Warning: no hook found for \"%s\"\n", name);
         return;
+    }
 
     for (iter = hook->items; iter != NULL; iter = g_slist_next(iter))
     {
--- a/src/audlegacy/main.c	Sun Apr 12 19:58:12 2009 -0400
+++ b/src/audlegacy/main.c	Sun Apr 12 23:03:39 2009 -0400
@@ -51,6 +51,7 @@
 
 #include "build_stamp.h"
 #include "configdb.h"
+#include "equalizer.h"
 #include "input.h"
 #include "logger.h"
 #include "output.h"
@@ -569,6 +570,7 @@
 
     output_set_volume((cfg.saved_volume & 0xff00) >> 8,
                       (cfg.saved_volume & 0x00ff));
+    init_equalizer ();
 
     g_message("Setting default icon");
     aud_set_default_icon();