diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2012-02-22 11:41:12 -0500 |
---|---|---|
committer | Package Import Robot <package-import@ubuntu.com> | 2012-02-22 11:41:12 -0500 |
commit | 78ef933f9aaa610506943638483a6ba2f936a960 (patch) | |
tree | 9f04e17f23f154df06452d3c36bb0f68b2829b06 /src/slider-menu-item.c | |
parent | e49f20c921a9bb4b9232c495b91341a25e4a3bcb (diff) | |
parent | 87422f8fa6face6715761ab76aeb04225f5ac235 (diff) | |
download | ayatana-indicator-sound-78ef933f9aaa610506943638483a6ba2f936a960.tar.gz ayatana-indicator-sound-78ef933f9aaa610506943638483a6ba2f936a960.tar.bz2 ayatana-indicator-sound-78ef933f9aaa610506943638483a6ba2f936a960.zip |
Import upstream version 0.8.2.0
Diffstat (limited to 'src/slider-menu-item.c')
-rw-r--r-- | src/slider-menu-item.c | 30 |
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 |