diff options
author | Jens Granseuer <jensgr@gmx.net> | 2008-04-07 20:38:32 +0000 |
---|---|---|
committer | Jens Granseuer <jensg@src.gnome.org> | 2008-04-07 20:38:32 +0000 |
commit | 3500654dcd75a335fc057f0efa85d1da91510d26 (patch) | |
tree | eb2f334bdba0545b94e3389c346eccc815de7efa /plugins | |
parent | 719342308dbd0c5b004d994ea294063464727172 (diff) | |
download | gnome-settings-daemon-3500654dcd75a335fc057f0efa85d1da91510d26.tar.gz |
Currently, the percentage by which to lower or raise the volume when
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
svn path=/trunk/; revision=275
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/media-keys/actions/acme-volume-alsa.c | 16 | ||||
-rw-r--r-- | plugins/media-keys/actions/acme-volume-dummy.c | 8 | ||||
-rw-r--r-- | plugins/media-keys/actions/acme-volume-gstreamer.c | 25 | ||||
-rw-r--r-- | plugins/media-keys/actions/acme-volume-oss.c | 8 | ||||
-rw-r--r-- | plugins/media-keys/actions/acme-volume.c | 9 | ||||
-rw-r--r-- | plugins/media-keys/actions/acme-volume.h | 4 | ||||
-rw-r--r-- | plugins/media-keys/gsd-media-keys-manager.c | 6 |
7 files changed, 73 insertions, 3 deletions
diff --git a/plugins/media-keys/actions/acme-volume-alsa.c b/plugins/media-keys/actions/acme-volume-alsa.c index bb709695..fb6e7a3b 100644 --- a/plugins/media-keys/actions/acme-volume-alsa.c +++ b/plugins/media-keys/actions/acme-volume-alsa.c @@ -180,6 +180,21 @@ acme_volume_alsa_set_volume (AcmeVolume *vol, int val) 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 @@ acme_volume_alsa_class_init (AcmeVolumeAlsaClass *klass) 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; } diff --git a/plugins/media-keys/actions/acme-volume-dummy.c b/plugins/media-keys/actions/acme-volume-dummy.c index 49ecc806..a3db38ce 100644 --- a/plugins/media-keys/actions/acme-volume-dummy.c +++ b/plugins/media-keys/actions/acme-volume-dummy.c @@ -58,6 +58,13 @@ acme_volume_dummy_set_volume (AcmeVolume *vol, int val) { } +/* 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 @@ acme_volume_dummy_class_init (AcmeVolumeDummyClass *klass) 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; } diff --git a/plugins/media-keys/actions/acme-volume-gstreamer.c b/plugins/media-keys/actions/acme-volume-gstreamer.c index f5d6b0db..11a8aebe 100644 --- a/plugins/media-keys/actions/acme-volume-gstreamer.c +++ b/plugins/media-keys/actions/acme-volume-gstreamer.c @@ -212,6 +212,29 @@ acme_volume_gstreamer_set_volume (AcmeVolume *vol, int val) 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 @@ acme_volume_gstreamer_class_init (AcmeVolumeGStreamerClass *klass) 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; } - diff --git a/plugins/media-keys/actions/acme-volume-oss.c b/plugins/media-keys/actions/acme-volume-oss.c index 8c18c97a..b6bf9d8b 100644 --- a/plugins/media-keys/actions/acme-volume-oss.c +++ b/plugins/media-keys/actions/acme-volume-oss.c @@ -155,6 +155,12 @@ acme_volume_oss_set_volume (AcmeVolume *vol, int val) } } +static int +acme_volume_oss_get_threshold (AcmeVolume *vol) +{ + return 1; +} + static void acme_volume_oss_init (AcmeVolumeOss *self) { @@ -193,6 +199,7 @@ acme_volume_oss_class_init (AcmeVolumeOssClass *klass) 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 @@ acme_volume_oss_mixer_check (AcmeVolumeOss *self, int fd) retval = (!self->_priv->mixerpb); return retval; } - diff --git a/plugins/media-keys/actions/acme-volume.c b/plugins/media-keys/actions/acme-volume.c index 0170b170..73e21c4e 100644 --- a/plugins/media-keys/actions/acme-volume.c +++ b/plugins/media-keys/actions/acme-volume.c @@ -95,6 +95,15 @@ acme_volume_mute_toggle (AcmeVolume *self) 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; diff --git a/plugins/media-keys/actions/acme-volume.h b/plugins/media-keys/actions/acme-volume.h index 00445b65..ec5ee3dd 100644 --- a/plugins/media-keys/actions/acme-volume.h +++ b/plugins/media-keys/actions/acme-volume.h @@ -45,6 +45,7 @@ typedef struct { 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 @@ void acme_volume_set_volume (AcmeVolume *self, int val); 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 diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c index 2b7e5e74..84134502 100644 --- a/plugins/media-keys/gsd-media-keys-manager.c +++ b/plugins/media-keys/gsd-media-keys-manager.c @@ -705,6 +705,12 @@ do_sound_action (GsdMediaKeysManager *manager, 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); |