[gnome-control-center] sound: Fix volume sliders regression
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] sound: Fix volume sliders regression
- Date: Sun, 25 Aug 2019 13:05:00 +0000 (UTC)
commit 9d612ff1c7e2d58211e25e8584bc86c5d2598eac
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Aug 13 11:11:05 2019 +1200
sound: Fix volume sliders regression
GVC added additional checks that break where we were using a NULL value instead
of a GvcMixerControl. Solution is to pass this object where appropriate.
(gnome-control-center:833): Gvc-CRITICAL **: 11:09:33.818: gvc_mixer_control_get_vol_max_norm: assertion
'GVC_IS_MIXER_CONTROL (control)' failed
Fixes #636
panels/sound/cc-sound-panel.c | 3 ++
panels/sound/cc-subwoofer-slider.c | 13 +++++++--
panels/sound/cc-subwoofer-slider.h | 8 +++--
panels/sound/cc-volume-slider.c | 60 ++++++++++++++++++++++++++------------
panels/sound/cc-volume-slider.h | 14 +++++----
5 files changed, 70 insertions(+), 28 deletions(-)
---
diff --git a/panels/sound/cc-sound-panel.c b/panels/sound/cc-sound-panel.c
index 672b2b1ab..b73e173c9 100644
--- a/panels/sound/cc-sound-panel.c
+++ b/panels/sound/cc-sound-panel.c
@@ -260,6 +260,9 @@ cc_sound_panel_init (CcSoundPanel *self)
gvc_mixer_control_open (self->mixer_control);
cc_stream_list_box_set_mixer_control (self->stream_list_box, self->mixer_control);
+ cc_volume_slider_set_mixer_control (self->input_volume_slider, self->mixer_control);
+ cc_volume_slider_set_mixer_control (self->output_volume_slider, self->mixer_control);
+ cc_subwoofer_slider_set_mixer_control (self->subwoofer_slider, self->mixer_control);
cc_device_combo_box_set_mixer_control (self->input_device_combo_box, self->mixer_control, FALSE);
cc_device_combo_box_set_mixer_control (self->output_device_combo_box, self->mixer_control, TRUE);
}
diff --git a/panels/sound/cc-subwoofer-slider.c b/panels/sound/cc-subwoofer-slider.c
index 15884b994..ac084cd5f 100644
--- a/panels/sound/cc-subwoofer-slider.c
+++ b/panels/sound/cc-subwoofer-slider.c
@@ -91,13 +91,20 @@ cc_subwoofer_slider_class_init (CcSubwooferSliderClass *klass)
void
cc_subwoofer_slider_init (CcSubwooferSlider *self)
{
- gdouble vol_max_norm;
-
g_resources_register (cc_sound_get_resource ());
gtk_widget_init_template (GTK_WIDGET (self));
+}
+
+void
+cc_subwoofer_slider_set_mixer_control (CcSubwooferSlider *self,
+ GvcMixerControl *mixer_control)
+{
+ gdouble vol_max_norm;
+
+ g_return_if_fail (CC_IS_SUBWOOFER_SLIDER (self));
- vol_max_norm = gvc_mixer_control_get_vol_max_norm (NULL);
+ vol_max_norm = gvc_mixer_control_get_vol_max_norm (mixer_control);
gtk_adjustment_set_upper (self->adjustment, vol_max_norm);
gtk_adjustment_set_page_increment (self->adjustment, vol_max_norm / 100.0);
}
diff --git a/panels/sound/cc-subwoofer-slider.h b/panels/sound/cc-subwoofer-slider.h
index 40e551043..8b462dcfb 100644
--- a/panels/sound/cc-subwoofer-slider.h
+++ b/panels/sound/cc-subwoofer-slider.h
@@ -21,13 +21,17 @@
#include <gtk/gtk.h>
#include <pulse/pulseaudio.h>
#include <gvc-channel-map.h>
+#include <gvc-mixer-control.h>
G_BEGIN_DECLS
#define CC_TYPE_SUBWOOFER_SLIDER (cc_subwoofer_slider_get_type ())
G_DECLARE_FINAL_TYPE (CcSubwooferSlider, cc_subwoofer_slider, CC, SUBWOOFER_SLIDER, GtkBox)
-void cc_subwoofer_slider_set_channel_map (CcSubwooferSlider *slider,
- GvcChannelMap *channel_map);
+void cc_subwoofer_slider_set_mixer_control (CcSubwooferSlider *slider,
+ GvcMixerControl *mixer_control);
+
+void cc_subwoofer_slider_set_channel_map (CcSubwooferSlider *slider,
+ GvcChannelMap *channel_map);
G_END_DECLS
diff --git a/panels/sound/cc-volume-slider.c b/panels/sound/cc-volume-slider.c
index ca2f70b90..7e061e540 100644
--- a/panels/sound/cc-volume-slider.c
+++ b/panels/sound/cc-volume-slider.c
@@ -34,6 +34,8 @@ struct _CcVolumeSlider
GtkAdjustment *volume_adjustment;
GtkScale *volume_scale;
+ gboolean is_amplified;
+ GvcMixerControl *mixer_control;
GvcMixerStream *stream;
guint notify_volume_handler_id;
guint notify_is_muted_handler_id;
@@ -41,6 +43,32 @@ struct _CcVolumeSlider
G_DEFINE_TYPE (CcVolumeSlider, cc_volume_slider, GTK_TYPE_BOX)
+static void
+update_ranges (CcVolumeSlider *self)
+{
+ gdouble vol_max_norm;
+
+ if (self->mixer_control == NULL)
+ return;
+
+ vol_max_norm = gvc_mixer_control_get_vol_max_norm (self->mixer_control);
+
+ gtk_scale_clear_marks (self->volume_scale);
+ if (self->is_amplified)
+ {
+ gtk_adjustment_set_upper (self->volume_adjustment, gvc_mixer_control_get_vol_max_amplified
(self->mixer_control));
+ gtk_scale_add_mark (self->volume_scale,
+ vol_max_norm,
+ GTK_POS_BOTTOM,
+ C_("volume", "100%"));
+ }
+ else
+ {
+ gtk_adjustment_set_upper (self->volume_adjustment, vol_max_norm);
+ }
+ gtk_adjustment_set_page_increment (self->volume_adjustment, vol_max_norm / 100.0);
+}
+
static void
volume_changed_cb (CcVolumeSlider *self)
{
@@ -94,6 +122,7 @@ cc_volume_slider_dispose (GObject *object)
{
CcVolumeSlider *self = CC_VOLUME_SLIDER (object);
+ g_clear_object (&self->mixer_control);
g_clear_object (&self->stream);
G_OBJECT_CLASS (cc_volume_slider_parent_class)->dispose (object);
@@ -121,15 +150,20 @@ cc_volume_slider_class_init (CcVolumeSliderClass *klass)
void
cc_volume_slider_init (CcVolumeSlider *self)
{
- gdouble vol_max_norm;
-
g_resources_register (cc_sound_get_resource ());
gtk_widget_init_template (GTK_WIDGET (self));
+}
- vol_max_norm = gvc_mixer_control_get_vol_max_norm (NULL);
- gtk_adjustment_set_upper (self->volume_adjustment, vol_max_norm);
- gtk_adjustment_set_page_increment (self->volume_adjustment, vol_max_norm / 100.0);
+void
+cc_volume_slider_set_mixer_control (CcVolumeSlider *self,
+ GvcMixerControl *mixer_control)
+{
+ g_return_if_fail (CC_IS_VOLUME_SLIDER (self));
+
+ g_set_object (&self->mixer_control, mixer_control);
+
+ update_ranges (self);
}
void
@@ -190,17 +224,7 @@ cc_volume_slider_set_is_amplified (CcVolumeSlider *self,
{
g_return_if_fail (CC_IS_VOLUME_SLIDER (self));
- gtk_scale_clear_marks (self->volume_scale);
- if (is_amplified)
- {
- gtk_adjustment_set_upper (self->volume_adjustment, gvc_mixer_control_get_vol_max_amplified (NULL));
- gtk_scale_add_mark (self->volume_scale,
- gvc_mixer_control_get_vol_max_norm (NULL),
- GTK_POS_BOTTOM,
- C_("volume", "100%"));
- }
- else
- {
- gtk_adjustment_set_upper (self->volume_adjustment, gvc_mixer_control_get_vol_max_norm (NULL));
- }
+ self->is_amplified = is_amplified;
+
+ update_ranges (self);
}
diff --git a/panels/sound/cc-volume-slider.h b/panels/sound/cc-volume-slider.h
index 68b5dc1d2..d0c627023 100644
--- a/panels/sound/cc-volume-slider.h
+++ b/panels/sound/cc-volume-slider.h
@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <pulse/pulseaudio.h>
+#include <gvc-mixer-control.h>
#include <gvc-mixer-stream.h>
#include "cc-sound-enums.h"
@@ -29,11 +30,14 @@ G_BEGIN_DECLS
#define CC_TYPE_VOLUME_SLIDER (cc_volume_slider_get_type ())
G_DECLARE_FINAL_TYPE (CcVolumeSlider, cc_volume_slider, CC, VOLUME_SLIDER, GtkBox)
-void cc_volume_slider_set_stream (CcVolumeSlider *slider,
- GvcMixerStream *stream,
- CcStreamType type);
+void cc_volume_slider_set_mixer_control (CcVolumeSlider *slider,
+ GvcMixerControl *mixer_control);
-void cc_volume_slider_set_is_amplified (CcVolumeSlider *slider,
- gboolean is_amplified);
+void cc_volume_slider_set_stream (CcVolumeSlider *slider,
+ GvcMixerStream *stream,
+ CcStreamType type);
+
+void cc_volume_slider_set_is_amplified (CcVolumeSlider *slider,
+ gboolean is_amplified);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]