After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 131158 - Volume slider always at bottom on startup
Volume slider always at bottom on startup
Status: RESOLVED FIXED
Product: gnome-media
Classification: Deprecated
Component: Gnome-CD
2.4.x
Other Linux
: High normal
: ---
Assigned To: gnome media maintainers
gnome media maintainers
: 94213 103718 131917 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-01-11 15:01 UTC by Mihael Vrbanec
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The patch to fix the volume slider (1.26 KB, patch)
2004-01-11 15:05 UTC, Mihael Vrbanec
none Details | Review

Description Mihael Vrbanec 2004-01-11 15:01:41 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),
Comment 1 Mihael Vrbanec 2004-01-11 15:05:51 UTC
Created attachment 23230 [details] [review]
The patch to fix the volume slider
Comment 2 Christian Kellner 2004-02-12 23:16:52 UTC
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. 
Comment 3 Ted Gould 2004-02-23 07:10:59 UTC
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?
Comment 4 Mihael Vrbanec 2004-02-23 22:36:47 UTC
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.

Comment 5 Ted Gould 2004-02-24 04:22:36 UTC
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.
Comment 6 Mihael Vrbanec 2004-02-24 16:39:21 UTC
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

Comment 7 Christophe Fergeau 2004-02-29 10:58:31 UTC
*** Bug 131917 has been marked as a duplicate of this bug. ***
Comment 8 Christophe Fergeau 2004-02-29 10:59:14 UTC
Bug 131917 has a similar patch.
Comment 9 Christian Fredrik Kalager Schaller 2004-02-29 21:33:44 UTC
*** Bug 103718 has been marked as a duplicate of this bug. ***
Comment 10 Christian Fredrik Kalager Schaller 2004-02-29 21:35:19 UTC
*** Bug 94213 has been marked as a duplicate of this bug. ***
Comment 11 Christian Fredrik Kalager Schaller 2004-02-29 21:38:18 UTC
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.
Comment 12 Ronald Bultje 2004-02-29 22:01:36 UTC
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. ;).
Comment 13 Ted Gould 2004-03-09 08:37:26 UTC
Applied patch to HEAD.  Thanks for the patch.