diff options
-rw-r--r-- | src/pulseaudio-mgr.c | 1 | ||||
-rw-r--r-- | src/slider-menu-item.c | 25 |
2 files changed, 14 insertions, 12 deletions
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c index ba83c71..3a80cbd 100644 --- a/src/pulseaudio-mgr.c +++ b/src/pulseaudio-mgr.c @@ -174,7 +174,6 @@ reconnect_to_pulse (gpointer user_data) void pm_update_volume (gint sink_index, pa_cvolume new_volume) { - // LP: #850662 if (sink_index < 0 || pulse_context == NULL){ return; } diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 165c3d5..7efdf74 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -77,7 +77,6 @@ slider_menu_item_init (SliderMenuItem *self) priv->index = NOT_ACTIVE; priv->name = NULL; - return; } @@ -147,21 +146,25 @@ 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); + 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 |