changeset 3807:62ff6b6f9ce0 trunk

Branch merge.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 01 Oct 2007 21:34:07 +0300
parents fbe7468efaea (current diff) e82ad057d1db (diff)
children b5d550755bad
files
diffstat 3 files changed, 17 insertions(+), 116 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/main.c	Mon Oct 01 21:25:24 2007 +0300
+++ b/src/audacious/main.c	Mon Oct 01 21:34:07 2007 +0300
@@ -1445,7 +1445,7 @@
 
     if (options.headless != 1)
     {
-        read_volume(VOLSET_STARTUP);
+        ui_main_set_initial_volume();
 
         /* FIXME: delayed, because it deals directly with the plugin
          * interface to set menu items */
--- a/src/audacious/ui_main.c	Mon Oct 01 21:25:24 2007 +0300
+++ b/src/audacious/ui_main.c	Mon Oct 01 21:34:07 2007 +0300
@@ -1537,7 +1537,6 @@
 {
     mainwin_release_info_text();
     setting_volume = FALSE;
-    read_volume(VOLUME_ADJUSTED);
 }
 
 void
@@ -1571,7 +1570,6 @@
 {
     mainwin_release_info_text();
     setting_volume = FALSE;
-    read_volume(VOLUME_ADJUSTED);
 }
 
 void
@@ -1633,7 +1631,6 @@
     setting_volume = FALSE;
     mainwin_set_volume_slider(vol);
     equalizerwin_set_volume_slider(vol);
-    read_volume(VOLUME_SET);
 }
 
 void
@@ -1645,7 +1642,6 @@
     setting_volume = FALSE;
     mainwin_set_balance_slider(b);
     equalizerwin_set_balance_slider(b);
-    read_volume(VOLUME_SET);
 }
 
 void
@@ -1984,114 +1980,28 @@
 }
 
 void
-read_volume(gint when)
+ui_main_set_initial_volume(void)
 {
-    static gint pvl = 0, pvr = 0;
-    static gint times = VOLSET_DISP_TIMES;
-    static gboolean changing = FALSE;
-
     gint vl, vr, b, v;
 
     input_get_volume(&vl, &vr);
 
-    switch (when) {
-    case VOLSET_STARTUP:
-        vl = CLAMP(vl, 0, 100);
-        vr = CLAMP(vr, 0, 100);
-        pvl = vl;
-        pvr = vr;
-        v = MAX(vl, vr);
-        if (vl > vr)
-            b = (gint) rint(((gdouble) vr / vl) * 100) - 100;
-        else if (vl < vr)
-            b = 100 - (gint) rint(((gdouble) vl / vr) * 100);
-        else
-            b = 0;
-
-        balance = b;
-        mainwin_set_volume_slider(v);
-        equalizerwin_set_volume_slider(v);
-        mainwin_set_balance_slider(b);
-        equalizerwin_set_balance_slider(b);
-        return;
-
-    case VOLSET_UPDATE:
-        if (vl == -1 || vr == -1)
-            return;
-
-        if (setting_volume) {
-            pvl = vl;
-            pvr = vr;
-            return;
-        }
-
-        if (pvr == vr && pvl == vl && changing) {
-            if (times < VOLSET_DISP_TIMES)
-                times++;
-            else {
-                mainwin_release_info_text();
-                changing = FALSE;
-            }
-        }
-        else if (pvr != vr || pvl != vl) {
-            gchar *tmp;
-
-            v = MAX(vl, vr);
-            if (vl > vr)
-                b = (gint) rint(((gdouble) vr / vl) * 100) - 100;
-            else if (vl < vr)
-                b = 100 - (gint) rint(((gdouble) vl / vr) * 100);
-            else
-                b = 0;
-
-            if (MAX(vl, vr) != MAX(pvl, pvr))
-                tmp = g_strdup_printf(_("VOLUME: %d%%"), v);
-            else {
-                if (vl > vr) {
-                    tmp = g_strdup_printf(_("BALANCE: %d%% LEFT"), -b);
-                }
-                else if (vr == vl)
-                    tmp = g_strdup_printf(_("BALANCE: CENTER"));
-                else {          /* (vl < vr) */
-                    tmp = g_strdup_printf(_("BALANCE: %d%% RIGHT"), b);
-                }
-            }
-            mainwin_lock_info_text(tmp);
-            g_free(tmp);
-
-            pvr = vr;
-            pvl = vl;
-            times = 0;
-            changing = TRUE;
-            mainwin_set_volume_slider(v);
-            equalizerwin_set_volume_slider(v);
-
-            /* Don't change the balance slider if the volume has been
-             * set to zero.  The balance can be anything, and our best
-             * guess is what is was before. */
-            if (v > 0) {
-                balance = b;
-                mainwin_set_balance_slider(b);
-                equalizerwin_set_balance_slider(b);
-            }
-        }
-        break;
-
-    case VOLUME_ADJUSTED:
-        pvl = vl;
-        pvr = vr;
-        break;
-
-    case VOLUME_SET:
-        times = 0;
-        changing = TRUE;
-        pvl = vl;
-        pvr = vr;
-        break;
-    }
+    vl = CLAMP(vl, 0, 100);
+    vr = CLAMP(vr, 0, 100);
+    v = MAX(vl, vr);
+    if (vl > vr)
+        b = (gint) rint(((gdouble) vr / vl) * 100) - 100;
+    else if (vl < vr)
+        b = 100 - (gint) rint(((gdouble) vl / vr) * 100);
+    else
+        b = 0;
+
+    mainwin_set_volume_slider(v);
+    equalizerwin_set_volume_slider(v);
+    mainwin_set_balance_slider(b);
+    equalizerwin_set_balance_slider(b);
 }
 
-
 /* TODO: HAL! */
 gboolean
 can_play_cd(void)
@@ -2664,17 +2574,8 @@
 static gboolean
 mainwin_idle_func(gpointer data)
 {
-    static gint count = 0;
-
     GDK_THREADS_ENTER();
 
-    if (!count) {
-        read_volume(VOLSET_UPDATE);
-        count = 10;
-    }
-    else
-        count--;
-
     /* tristate buttons seek */
     if ( seek_state != MAINWIN_SEEK_NIL )
     {
--- a/src/audacious/ui_main.h	Mon Oct 01 21:25:24 2007 +0300
+++ b/src/audacious/ui_main.h	Mon Oct 01 21:34:07 2007 +0300
@@ -114,7 +114,7 @@
 extern GtkWidget *mainwin_position, *mainwin_sposition;
 
 void mainwin_create(void);
-void read_volume(gint when);
+void ui_main_set_initial_volume(void);
 
 void mainwin_quit_cb(void);
 void mainwin_lock_info_text(const gchar * text);