aboutsummaryrefslogtreecommitdiff
path: root/src/slider-menu-item.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2012-02-22 20:15:17 +0000
committerConor Curran <conor.curran@canonical.com>2012-02-22 20:15:17 +0000
commitdae2c851253dc74a92b50a2464340a80fdf26a20 (patch)
tree8fc5be64f80a0da462972b72e74c175c55b1525a /src/slider-menu-item.c
parentbd74119fe73c955a458b414b12ac92d580a15344 (diff)
parentb7038fe83944c2dc6a8d00222fd8db228d191c40 (diff)
downloadayatana-indicator-sound-dae2c851253dc74a92b50a2464340a80fdf26a20.tar.gz
ayatana-indicator-sound-dae2c851253dc74a92b50a2464340a80fdf26a20.tar.bz2
ayatana-indicator-sound-dae2c851253dc74a92b50a2464340a80fdf26a20.zip
merge the ui fixes on the indicator side
Diffstat (limited to 'src/slider-menu-item.c')
-rw-r--r--src/slider-menu-item.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index 165c3d5..dc0671c 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -147,21 +147,31 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update)
static void
slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent)
{
+ g_return_if_fail (IS_SLIDER_MENU_ITEM (self));
-/*
- g_debug ("slider menu item update volume - about to set the volume to %f", percent);
-*/
-
- pa_cvolume new_volume;
- pa_cvolume_init(&new_volume);
- new_volume.channels = 1;
+ pa_cvolume mono_new_volume;
+ pa_cvolume_init(&mono_new_volume);
+ mono_new_volume.channels = 1;
pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100);
- pa_cvolume_set(&new_volume, 1, new_volume_value);
+
+ if (new_volume_value == PA_VOLUME_INVALID || new_volume_value >= PA_VOLUME_MAX){
+ g_warning ("slider_menu_item_update_volume - volume is out of range !");
+ return;
+ }
+
+ pa_cvolume_set(&mono_new_volume, 1, new_volume_value);
SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
-
+ if (!pa_cvolume_valid (&mono_new_volume)){
+ g_warning ("Invalid volume - ignore it!");
+ return;
+ }
+ if (!pa_channel_map_valid(&priv->channel_map)){
+ g_warning ("Invalid channel map - ignore update volume!");
+ return;
+ }
pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value);
- pm_update_volume (priv->index, new_volume);
+ pm_update_volume (priv->index, mono_new_volume);
}
// To the UI