GNOME Bugzilla – Bug 131158
Volume slider always at bottom on startup
Last modified: 2004-12-22 21:47:04 UTC
When you start gnome-cd the volume slider is always at the zero-volume position regardless of the actual volume. You can hear the sound, too. When you move it it sets the volume correctly. I have looked at the code and the bug is obvious. I also browsed through bonsai an saw that the code was right someday and was "fixed" with the comment "make volume slider work correctly". It definately does not work for me and some other people I spoke with whereas my fix (and the old code) seem logically right and do actually work. Here is the patch/diff: diff -ru gnome-media-2.4.1.1/gnome-cd/callbacks.c gnome-media-2.4.1.1-miq/gnome-cd/callbacks.c--- gnome-media-2.4.1.1/gnome-cd/callbacks.c Tue Oct 14 09:09:09 2003+++ gnome-media-2.4.1.1-miq/gnome-cd/callbacks.c Thu Dec 18 02:47:51 2003@@ -1025,8 +1025,7 @@ GError *error; volume = gtk_range_get_value (range);-- if (gnome_cdrom_set_volume (gcd->cdrom, (int) -volume, &error) == FALSE) {+ if (gnome_cdrom_set_volume (gcd->cdrom, (int) volume, &error) == FALSE) { gcd_warning ("Error setting volume: %s", error); g_error_free (error); }diff -ru gnome-media-2.4.1.1/gnome-cd/gnome-cd.c gnome-media-2.4.1.1-miq/gnome-cd/gnome-cd.c--- gnome-media-2.4.1.1/gnome-cd/gnome-cd.c Tue Oct 14 09:09:09 2003+++ gnome-media-2.4.1.1-miq/gnome-cd/gnome-cd.c Thu Dec 18 02:47:41 2003@@ -528,8 +528,9 @@ gtk_box_pack_start (GTK_BOX (top_hbox), display_box, TRUE, TRUE, 0); /* Volume slider */- gcd->slider = gtk_vscale_new_with_range (-255.0, 0.0, 1.0);+ gcd->slider = gtk_vscale_new_with_range (0.0, 255.0, 1.0); gtk_scale_set_draw_value (GTK_SCALE (gcd->slider), FALSE);+ gtk_range_set_inverted(GTK_RANGE(gcd->slider), TRUE); gtk_box_pack_start (GTK_BOX (top_hbox), gcd->slider, FALSE, FALSE, 0); gtk_tooltips_set_tip (gcd->tooltips, GTK_WIDGET (gcd->slider),
Created attachment 23230 [details] [review] The patch to fix the volume slider
The value of the slider isn't at zero level in gnome-cd 2.5.2, but it looks like it doesn't remember to value correctly, so just adding the PATCH keyword here and setting priority to High.
I'm a touch confused. I think this patch only changes the range of the volume slider from being from -255, 0 to being 0, 255. How does that fix it starting at zero? Perhaps the patch got messed up?
Ok, I'll try to clarify: gnome_cdrom_get_status gets the current volume as status->volume. This value is between 0 and 255. Then the slider position is set to this value. Setting a gtk_range defined from -255 to 0 to any positive value will always set it to its maximum (which is 0). Doing gtk_range_set_value (GTK_RANGE (gcd->slider), (double) (-1) * status->volume); would fix the issue too, but looks contra-intuitive and dirty for me. Especially because the gnome_cdrom_set_volume() in callbacks.c (second part of the patch) turns around the volume back to positive. My patch just inverts the slider and leaves all the values as they are which seems correct for me and works as expected.
Here is the code that is being replaced: if (gnome_cdrom_set_volume (gcd->cdrom, (int) -volume, &error) == FALSE) { volume is already getting multiplied by -1 by doing the '-volume' (which is not as easy to read, but works). So it should be setting the value properly.
I meant the multiplication with -1 when setting initial volume, not in the callback. Current situation: -getting positive value from cdrom -setting positive value in negative gtk_range (which produces the bug) -getting negative value from gtk_range -setting the negative value multiplicated with -1, when slider is moved Proposal: -getting positive value from cdrom -setting positive value in *inverted, thus positive* gtk_range (fixing the bug) -getting positive value from gtk_range -setting positive value when slider is moved Alternative proposal (one char fix, but imho not clean and readable): -gettig positive value from cdrom -setting negative value in gtk_range (leaving the range as is, but fixing the bug) -getting negative value from gtk_range -setting negative value multiplicated with -1, when slider is moved
*** Bug 131917 has been marked as a duplicate of this bug. ***
Bug 131917 has a similar patch.
*** Bug 103718 has been marked as a duplicate of this bug. ***
*** Bug 94213 has been marked as a duplicate of this bug. ***
Ok, this bug handles the issue of volume settings getting reset to defaults each time you reboot the computer. I think the setting should be stored in GConf as that would also solve 94726 about how all mixer/volume setting applications should be aware of the changes done by others.
GNOME or GConf shouldn't do this, the system should do this. RedHat, for example, uses a script to reset mixer settings. Other distributions do this similarly. Using a desktop-specific solution for something this basic is overkill... Just MHO. ;).
Applied patch to HEAD. Thanks for the patch.