gnome-settings-daemon r275 - in trunk: . plugins/media-keys plugins/media-keys/actions
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r275 - in trunk: . plugins/media-keys plugins/media-keys/actions
- Date: Mon, 7 Apr 2008 21:38:32 +0100 (BST)
Author: jensg
Date: Mon Apr 7 21:38:32 2008
New Revision: 275
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=275&view=rev
Log:
2008-04-07 Jens Granseuer <jensgr gmx net>
Currently, the percentage by which to lower or raise the volume when
hitting the multimedia keys is taken from GConf, with 6 being the
default. We don't have any settings dialogs to actually change it,
though. If the user now selects a mixer that supports fewer volume
levels than the GConf setting implies (100/6) it becomes impossible
to change the volume (without fiddling with the GConf setting). This
patch adds a "threshold" property to the AcmeVolume class that denotes
the minimum percentage required to actually affect the volume. The
plugin now uses the step size read from GConf or the mixer threshold,
depending on which one is bigger. (bug #441910)
* plugins/media-keys/actions/acme-volume-alsa.c:
(acme_volume_alsa_get_threshold), (acme_volume_alsa_class_init):
* plugins/media-keys/actions/acme-volume-dummy.c:
(acme_volume_dummy_get_threshold), (acme_volume_dummy_class_init):
* plugins/media-keys/actions/acme-volume-gstreamer.c:
(acme_volume_gstreamer_get_threshold),
(acme_volume_gstreamer_class_init):
* plugins/media-keys/actions/acme-volume-oss.c:
(acme_volume_oss_get_threshold), (acme_volume_oss_class_init),
(acme_volume_oss_mixer_check):
* plugins/media-keys/actions/acme-volume.c:
(acme_volume_get_threshold):
* plugins/media-keys/actions/acme-volume.h: add get_threshold method
* plugins/media-keys/gsd-media-keys-manager.c: (do_sound_action): use
gconf value or threshold, depending on what's bigger
Modified:
trunk/ChangeLog
trunk/plugins/media-keys/actions/acme-volume-alsa.c
trunk/plugins/media-keys/actions/acme-volume-dummy.c
trunk/plugins/media-keys/actions/acme-volume-gstreamer.c
trunk/plugins/media-keys/actions/acme-volume-oss.c
trunk/plugins/media-keys/actions/acme-volume.c
trunk/plugins/media-keys/actions/acme-volume.h
trunk/plugins/media-keys/gsd-media-keys-manager.c
Modified: trunk/plugins/media-keys/actions/acme-volume-alsa.c
==============================================================================
--- trunk/plugins/media-keys/actions/acme-volume-alsa.c (original)
+++ trunk/plugins/media-keys/actions/acme-volume-alsa.c Mon Apr 7 21:38:32 2008
@@ -180,6 +180,21 @@
acme_volume_alsa_close (self);
}
+static int
+acme_volume_alsa_get_threshold (AcmeVolume *vol)
+{
+ AcmeVolumeAlsa *self = (AcmeVolumeAlsa *) vol;
+ int steps;
+
+ if (acme_volume_alsa_open (self) == FALSE)
+ return 1;
+
+ acme_volume_alsa_close (self);
+
+ steps = self->_priv->pmax - self->_priv->pmin;
+ return (steps > 0) ? 100 / steps + 1 : 1;
+}
+
static gboolean
acme_volume_alsa_close_real (AcmeVolumeAlsa *self)
{
@@ -310,5 +325,6 @@
volume_class->get_volume = acme_volume_alsa_get_volume;
volume_class->set_mute = acme_volume_alsa_set_mute;
volume_class->get_mute = acme_volume_alsa_get_mute;
+ volume_class->get_threshold = acme_volume_alsa_get_threshold;
}
Modified: trunk/plugins/media-keys/actions/acme-volume-dummy.c
==============================================================================
--- trunk/plugins/media-keys/actions/acme-volume-dummy.c (original)
+++ trunk/plugins/media-keys/actions/acme-volume-dummy.c Mon Apr 7 21:38:32 2008
@@ -58,6 +58,13 @@
{
}
+/* minimum step size (in percent) required to actually affect volume */
+static int
+acme_volume_dummy_get_threshold (AcmeVolume *vol)
+{
+ return 1;
+}
+
static void
acme_volume_dummy_init (AcmeVolumeDummy *vol)
{
@@ -75,4 +82,5 @@
volume_class->get_volume = acme_volume_dummy_get_volume;
volume_class->set_mute = acme_volume_dummy_set_mute;
volume_class->get_mute = acme_volume_dummy_get_mute;
+ volume_class->get_threshold = acme_volume_dummy_get_threshold;
}
Modified: trunk/plugins/media-keys/actions/acme-volume-gstreamer.c
==============================================================================
--- trunk/plugins/media-keys/actions/acme-volume-gstreamer.c (original)
+++ trunk/plugins/media-keys/actions/acme-volume-gstreamer.c Mon Apr 7 21:38:32 2008
@@ -212,6 +212,29 @@
acme_volume_gstreamer_close (self);
}
+static int
+acme_volume_gstreamer_get_threshold (AcmeVolume *vol)
+{
+ AcmeVolumeGStreamer *self = (AcmeVolumeGStreamer *) vol;
+ GList *t;
+ int steps = 101;
+
+ if (acme_volume_gstreamer_open (self) == FALSE)
+ return 1;
+
+ for (t = self->_priv->mixer_tracks; t != NULL; t = t->next)
+ {
+ GstMixerTrack *track = GST_MIXER_TRACK (t->data);
+ int track_steps = track->max_volume - track->min_volume;
+ if (track_steps > 0 && track_steps < steps)
+ steps = track_steps;
+ }
+
+ acme_volume_gstreamer_close (self);
+
+ return 100 / steps + 1;
+}
+
static gboolean
acme_volume_gstreamer_close_real (AcmeVolumeGStreamer *self)
{
@@ -430,5 +453,5 @@
volume_class->get_volume = acme_volume_gstreamer_get_volume;
volume_class->set_mute = acme_volume_gstreamer_set_mute;
volume_class->get_mute = acme_volume_gstreamer_get_mute;
+ volume_class->get_threshold = acme_volume_gstreamer_get_threshold;
}
-
Modified: trunk/plugins/media-keys/actions/acme-volume-oss.c
==============================================================================
--- trunk/plugins/media-keys/actions/acme-volume-oss.c (original)
+++ trunk/plugins/media-keys/actions/acme-volume-oss.c Mon Apr 7 21:38:32 2008
@@ -155,6 +155,12 @@
}
}
+static int
+acme_volume_oss_get_threshold (AcmeVolume *vol)
+{
+ return 1;
+}
+
static void
acme_volume_oss_init (AcmeVolumeOss *self)
{
@@ -193,6 +199,7 @@
volume_class->get_volume = acme_volume_oss_get_volume;
volume_class->set_mute = acme_volume_oss_set_mute;
volume_class->get_mute = acme_volume_oss_get_mute;
+ volume_class->get_threshold = acme_volume_oss_get_threshold;
}
static gboolean
@@ -210,4 +217,3 @@
retval = (!self->_priv->mixerpb);
return retval;
}
-
Modified: trunk/plugins/media-keys/actions/acme-volume.c
==============================================================================
--- trunk/plugins/media-keys/actions/acme-volume.c (original)
+++ trunk/plugins/media-keys/actions/acme-volume.c Mon Apr 7 21:38:32 2008
@@ -95,6 +95,15 @@
ACME_VOLUME_GET_CLASS (self)->set_mute (self, !muted);
}
+int
+acme_volume_get_threshold (AcmeVolume *self)
+{
+ g_return_val_if_fail (self != NULL, 0);
+ g_return_val_if_fail (ACME_IS_VOLUME (self), 0);
+
+ return ACME_VOLUME_GET_CLASS (self)->get_threshold (self);
+}
+
AcmeVolume *acme_volume_new (void)
{
AcmeVolume *vol;
Modified: trunk/plugins/media-keys/actions/acme-volume.h
==============================================================================
--- trunk/plugins/media-keys/actions/acme-volume.h (original)
+++ trunk/plugins/media-keys/actions/acme-volume.h Mon Apr 7 21:38:32 2008
@@ -45,6 +45,7 @@
int (* get_volume) (AcmeVolume *self);
void (* set_mute) (AcmeVolume *self, gboolean val);
int (* get_mute) (AcmeVolume *self);
+ int (* get_threshold) (AcmeVolume *self);
} AcmeVolumeClass;
GType acme_volume_get_type (void);
@@ -53,7 +54,8 @@
gboolean acme_volume_get_mute (AcmeVolume *self);
void acme_volume_set_mute (AcmeVolume *self,
gboolean val);
-void acme_volume_mute_toggle (AcmeVolume * self);
+void acme_volume_mute_toggle (AcmeVolume *self);
+int acme_volume_get_threshold (AcmeVolume *self);
AcmeVolume *acme_volume_new (void);
G_END_DECLS
Modified: trunk/plugins/media-keys/gsd-media-keys-manager.c
==============================================================================
--- trunk/plugins/media-keys/gsd-media-keys-manager.c (original)
+++ trunk/plugins/media-keys/gsd-media-keys-manager.c Mon Apr 7 21:38:32 2008
@@ -705,6 +705,12 @@
g_error_free (error);
}
+ if (vol_step > 0) {
+ int threshold = acme_volume_get_threshold (manager->priv->volume);
+ if (vol_step < threshold)
+ vol_step = threshold;
+ }
+
/* FIXME: this is racy */
vol = acme_volume_get_volume (manager->priv->volume);
muted = acme_volume_get_mute (manager->priv->volume);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]