2023-01-13 00:02:50 +01:00
|
|
|
/*
|
2018-10-10 16:08:37 +13:00
|
|
|
* Copyright (C) 2008 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <libintl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <pulse/pulseaudio.h>
|
|
|
|
#include <gvc-mixer-control.h>
|
|
|
|
|
2023-01-14 19:49:39 +01:00
|
|
|
#include "cc-alert-chooser-window.h"
|
2018-10-10 16:08:37 +13:00
|
|
|
#include "cc-balance-slider.h"
|
|
|
|
#include "cc-device-combo-box.h"
|
|
|
|
#include "cc-fade-slider.h"
|
|
|
|
#include "cc-level-bar.h"
|
2022-12-16 15:52:05 +01:00
|
|
|
#include "cc-output-test-window.h"
|
2018-10-10 16:08:37 +13:00
|
|
|
#include "cc-profile-combo-box.h"
|
2018-11-19 12:57:52 +13:00
|
|
|
#include "cc-sound-panel.h"
|
|
|
|
#include "cc-sound-resources.h"
|
2018-10-10 16:08:37 +13:00
|
|
|
#include "cc-subwoofer-slider.h"
|
2023-01-10 21:37:55 +01:00
|
|
|
#include "cc-volume-levels-window.h"
|
2018-10-10 16:08:37 +13:00
|
|
|
#include "cc-volume-slider.h"
|
|
|
|
|
2018-11-19 12:57:52 +13:00
|
|
|
struct _CcSoundPanel
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
|
|
|
CcPanel parent_instance;
|
|
|
|
|
2023-01-28 15:03:38 +01:00
|
|
|
AdwPreferencesGroup *output_group;
|
|
|
|
CcLevelBar *output_level_bar;
|
|
|
|
CcDeviceComboBox *output_device_combo_box;
|
2023-01-28 15:19:36 +01:00
|
|
|
AdwPreferencesRow *output_profile_row;
|
2023-01-28 15:03:38 +01:00
|
|
|
CcProfileComboBox *output_profile_combo_box;
|
|
|
|
CcVolumeSlider *output_volume_slider;
|
|
|
|
CcBalanceSlider *balance_slider;
|
2023-01-28 15:19:36 +01:00
|
|
|
AdwPreferencesRow *fade_row;
|
2023-01-28 15:03:38 +01:00
|
|
|
CcFadeSlider *fade_slider;
|
2023-01-28 15:19:36 +01:00
|
|
|
AdwPreferencesRow *subwoofer_row;
|
2023-01-28 15:03:38 +01:00
|
|
|
CcSubwooferSlider *subwoofer_slider;
|
|
|
|
AdwPreferencesGroup *output_no_devices_group;
|
|
|
|
AdwPreferencesGroup *input_group;
|
|
|
|
CcLevelBar *input_level_bar;
|
|
|
|
CcDeviceComboBox *input_device_combo_box;
|
2023-01-28 15:19:36 +01:00
|
|
|
AdwPreferencesRow *input_profile_row;
|
2023-01-28 15:03:38 +01:00
|
|
|
CcProfileComboBox *input_profile_combo_box;
|
|
|
|
CcVolumeSlider *input_volume_slider;
|
|
|
|
AdwPreferencesGroup *input_no_devices_group;
|
|
|
|
GtkLabel *alert_sound_label;
|
2018-10-10 16:08:37 +13:00
|
|
|
|
|
|
|
GvcMixerControl *mixer_control;
|
|
|
|
GSettings *sound_settings;
|
|
|
|
};
|
|
|
|
|
2018-11-19 12:57:52 +13:00
|
|
|
CC_PANEL_REGISTER (CcSoundPanel, cc_sound_panel)
|
2018-10-10 16:08:37 +13:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_PARAMETERS
|
|
|
|
};
|
|
|
|
|
|
|
|
#define KEY_SOUNDS_SCHEMA "org.gnome.desktop.sound"
|
|
|
|
|
2023-01-14 19:49:39 +01:00
|
|
|
static void
|
|
|
|
update_alert_sound_label (CcSoundPanel *self)
|
|
|
|
{
|
|
|
|
const gchar *alert_name = get_selected_alert_display_name ();
|
|
|
|
gtk_label_set_label (self->alert_sound_label, alert_name);
|
|
|
|
}
|
|
|
|
|
2018-10-10 16:08:37 +13:00
|
|
|
static void
|
2018-11-19 12:57:52 +13:00
|
|
|
allow_amplified_changed_cb (CcSoundPanel *self)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
|
|
|
cc_volume_slider_set_is_amplified (self->output_volume_slider,
|
|
|
|
g_settings_get_boolean (self->sound_settings, "allow-volume-above-100-percent"));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
set_output_stream (CcSoundPanel *self,
|
|
|
|
GvcMixerStream *stream)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
|
|
|
GvcChannelMap *map = NULL;
|
|
|
|
gboolean can_fade = FALSE, has_lfe = FALSE;
|
|
|
|
|
2019-06-14 18:07:45 +03:00
|
|
|
cc_volume_slider_set_stream (self->output_volume_slider, stream, CC_STREAM_TYPE_OUTPUT);
|
2022-09-08 18:46:08 +02:00
|
|
|
cc_level_bar_set_stream (self->output_level_bar, stream);
|
2018-10-10 16:08:37 +13:00
|
|
|
|
|
|
|
if (stream != NULL)
|
|
|
|
{
|
|
|
|
map = (GvcChannelMap *) gvc_mixer_stream_get_channel_map (stream);
|
|
|
|
can_fade = gvc_channel_map_can_fade (map);
|
|
|
|
has_lfe = gvc_channel_map_has_lfe (map);
|
|
|
|
}
|
|
|
|
cc_fade_slider_set_channel_map (self->fade_slider, map);
|
|
|
|
cc_balance_slider_set_channel_map (self->balance_slider, map);
|
|
|
|
cc_subwoofer_slider_set_channel_map (self->subwoofer_slider, map);
|
|
|
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->fade_row), can_fade);
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->subwoofer_row), has_lfe);
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
output_device_changed_cb (CcSoundPanel *self)
|
|
|
|
{
|
|
|
|
GvcMixerUIDevice *device;
|
|
|
|
GvcMixerStream *stream = NULL;
|
|
|
|
|
|
|
|
device = cc_device_combo_box_get_device (self->output_device_combo_box);
|
|
|
|
|
2023-01-28 15:03:38 +01:00
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->output_group), device != NULL);
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->output_no_devices_group), device == NULL);
|
2023-01-12 23:48:41 +01:00
|
|
|
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
if (device != NULL)
|
|
|
|
stream = gvc_mixer_control_get_stream_from_device (self->mixer_control, device);
|
|
|
|
|
|
|
|
set_output_stream (self, stream);
|
2019-03-14 10:58:59 +13:00
|
|
|
|
2019-03-14 11:28:08 +13:00
|
|
|
if (device != NULL)
|
|
|
|
gvc_mixer_control_change_output (self->mixer_control, device);
|
2018-10-10 16:08:37 +13:00
|
|
|
}
|
|
|
|
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
static void
|
|
|
|
set_input_stream (CcSoundPanel *self,
|
|
|
|
GvcMixerStream *stream)
|
|
|
|
{
|
|
|
|
cc_volume_slider_set_stream (self->input_volume_slider, stream, CC_STREAM_TYPE_INPUT);
|
2022-09-08 18:46:08 +02:00
|
|
|
cc_level_bar_set_stream (self->input_level_bar, stream);
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
}
|
|
|
|
|
2018-10-10 16:08:37 +13:00
|
|
|
static void
|
2018-11-19 12:57:52 +13:00
|
|
|
input_device_changed_cb (CcSoundPanel *self)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
|
|
|
GvcMixerUIDevice *device;
|
|
|
|
GvcMixerStream *stream = NULL;
|
|
|
|
|
|
|
|
device = cc_device_combo_box_get_device (self->input_device_combo_box);
|
|
|
|
|
2023-01-28 15:03:38 +01:00
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->input_group), device != NULL);
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->input_no_devices_group), device == NULL);
|
2023-01-12 23:48:41 +01:00
|
|
|
|
2018-10-10 16:08:37 +13:00
|
|
|
if (device != NULL)
|
|
|
|
stream = gvc_mixer_control_get_stream_from_device (self->mixer_control, device);
|
|
|
|
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
set_input_stream (self, stream);
|
2019-03-14 10:58:59 +13:00
|
|
|
|
2019-03-14 11:28:08 +13:00
|
|
|
if (device != NULL)
|
|
|
|
gvc_mixer_control_change_input (self->mixer_control, device);
|
2018-10-10 16:08:37 +13:00
|
|
|
}
|
|
|
|
|
sound: update the profile list after getting the signal from gvc
In the ubuntu 20.04, we found a regression on HDMI audio. We plug a
HDMI/DP monitor, the output device is the speaker in the output device
combo box, then we select the HDMI from the combo box, the output
device is switched to HDMI audio successfully, but the configuration
box is empty. This will not happen in the ubuntu 18.04, the profile
will show hdmi-stereo in this situation. So I think this is a
regression.
When problem happens, I could see the errors from log:
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Through debugging, I found the cc_profile_combo_box_set_device() is
called too early. In the ubuntu 18.04, this function is called after
pulseaudio changes the active_profile, but in the ubuntu 20.04, it is
called ahead of pulseaudio changes the active_profile.
To fix it, add a signal callback function, after pulseaudio changes
the active_profile, this callback function will be called, then call
cc_profile_combo_box_set_device().
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-09-04 17:06:27 +08:00
|
|
|
static void
|
|
|
|
output_device_update_cb (CcSoundPanel *self,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
GvcMixerUIDevice *device;
|
|
|
|
gboolean has_multi_profiles;
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
GvcMixerStream *stream = NULL;
|
sound: update the profile list after getting the signal from gvc
In the ubuntu 20.04, we found a regression on HDMI audio. We plug a
HDMI/DP monitor, the output device is the speaker in the output device
combo box, then we select the HDMI from the combo box, the output
device is switched to HDMI audio successfully, but the configuration
box is empty. This will not happen in the ubuntu 18.04, the profile
will show hdmi-stereo in this situation. So I think this is a
regression.
When problem happens, I could see the errors from log:
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Through debugging, I found the cc_profile_combo_box_set_device() is
called too early. In the ubuntu 18.04, this function is called after
pulseaudio changes the active_profile, but in the ubuntu 20.04, it is
called ahead of pulseaudio changes the active_profile.
To fix it, add a signal callback function, after pulseaudio changes
the active_profile, this callback function will be called, then call
cc_profile_combo_box_set_device().
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-09-04 17:06:27 +08:00
|
|
|
|
|
|
|
device = cc_device_combo_box_get_device (self->output_device_combo_box);
|
|
|
|
cc_profile_combo_box_set_device (self->output_profile_combo_box, self->mixer_control, device);
|
|
|
|
has_multi_profiles = (cc_profile_combo_box_get_profile_count (self->output_profile_combo_box) > 1);
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->output_profile_row),
|
|
|
|
has_multi_profiles);
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
|
|
|
|
if (cc_volume_slider_get_stream (self->output_volume_slider) == NULL)
|
|
|
|
stream = gvc_mixer_control_get_stream_from_device (self->mixer_control, device);
|
|
|
|
if (stream != NULL)
|
|
|
|
set_output_stream (self, stream);
|
sound: update the profile list after getting the signal from gvc
In the ubuntu 20.04, we found a regression on HDMI audio. We plug a
HDMI/DP monitor, the output device is the speaker in the output device
combo box, then we select the HDMI from the combo box, the output
device is switched to HDMI audio successfully, but the configuration
box is empty. This will not happen in the ubuntu 18.04, the profile
will show hdmi-stereo in this situation. So I think this is a
regression.
When problem happens, I could see the errors from log:
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Through debugging, I found the cc_profile_combo_box_set_device() is
called too early. In the ubuntu 18.04, this function is called after
pulseaudio changes the active_profile, but in the ubuntu 20.04, it is
called ahead of pulseaudio changes the active_profile.
To fix it, add a signal callback function, after pulseaudio changes
the active_profile, this callback function will be called, then call
cc_profile_combo_box_set_device().
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-09-04 17:06:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
input_device_update_cb (CcSoundPanel *self,
|
|
|
|
guint id)
|
|
|
|
{
|
|
|
|
GvcMixerUIDevice *device;
|
|
|
|
gboolean has_multi_profiles;
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
GvcMixerStream *stream = NULL;
|
sound: update the profile list after getting the signal from gvc
In the ubuntu 20.04, we found a regression on HDMI audio. We plug a
HDMI/DP monitor, the output device is the speaker in the output device
combo box, then we select the HDMI from the combo box, the output
device is switched to HDMI audio successfully, but the configuration
box is empty. This will not happen in the ubuntu 18.04, the profile
will show hdmi-stereo in this situation. So I think this is a
regression.
When problem happens, I could see the errors from log:
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Through debugging, I found the cc_profile_combo_box_set_device() is
called too early. In the ubuntu 18.04, this function is called after
pulseaudio changes the active_profile, but in the ubuntu 20.04, it is
called ahead of pulseaudio changes the active_profile.
To fix it, add a signal callback function, after pulseaudio changes
the active_profile, this callback function will be called, then call
cc_profile_combo_box_set_device().
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-09-04 17:06:27 +08:00
|
|
|
|
|
|
|
device = cc_device_combo_box_get_device (self->input_device_combo_box);
|
|
|
|
cc_profile_combo_box_set_device (self->input_profile_combo_box, self->mixer_control, device);
|
|
|
|
has_multi_profiles = (cc_profile_combo_box_get_profile_count (self->input_profile_combo_box) > 1);
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->input_profile_row),
|
|
|
|
has_multi_profiles);
|
sound: update the volume-slider after getting a valid stream
In the ubuntu 20.04, we met an issue about the output volume-slider
on the machine with the legacy HDA audio driver, the output device
is the Speaker first (analog-stereo pa sink), then we connect a hdmi
monitor, the HDMI audio is in the output combo-box, we select the
hdmi audio (hdmi-stereo pa sink) from the combo-box, the hdmi audio
becomes the active output device now, we adjust the output volume from
the volume-slider, the slider UI is changed, but the output sound
is not changed with the UI.
The root cause is when the speaker is active, the pulseaudio only
keeps the analog-stereo sink, the sink hdmi-stereo is unlinked, when
users select the hdmi audio from UI, the pulseaudio will unlink
analo-stereo sink and create hdmi-stereo sink, but before hdmi-stereo
is created, the output_device_changed_cb() is called and
gvc_mixer_control_get_stream_from_device() returns a NULL since the
hdmi-stereo sink is not created yet in the pulseaudio. Because stream
is NULL, the output_volume_slider->stream is NULL, users can't change
the output volume via the volume-slider.
To fix it, we add a output_volume_slider->stream check in the
device_update_cb(), if it is NULL, get the stream and set it to
volume-slider. In this function, the sink hdmi-stereo is created
already, so the stream is not NULL. And this change also applies to
input as well.
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2021-07-29 17:08:08 +08:00
|
|
|
|
|
|
|
if (cc_volume_slider_get_stream (self->input_volume_slider) == NULL)
|
|
|
|
stream = gvc_mixer_control_get_stream_from_device (self->mixer_control, device);
|
|
|
|
if (stream != NULL)
|
|
|
|
set_input_stream (self, stream);
|
sound: update the profile list after getting the signal from gvc
In the ubuntu 20.04, we found a regression on HDMI audio. We plug a
HDMI/DP monitor, the output device is the speaker in the output device
combo box, then we select the HDMI from the combo box, the output
device is switched to HDMI audio successfully, but the configuration
box is empty. This will not happen in the ubuntu 18.04, the profile
will show hdmi-stereo in this situation. So I think this is a
regression.
When problem happens, I could see the errors from log:
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Through debugging, I found the cc_profile_combo_box_set_device() is
called too early. In the ubuntu 18.04, this function is called after
pulseaudio changes the active_profile, but in the ubuntu 20.04, it is
called ahead of pulseaudio changes the active_profile.
To fix it, add a signal callback function, after pulseaudio changes
the active_profile, this callback function will be called, then call
cc_profile_combo_box_set_device().
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-09-04 17:06:27 +08:00
|
|
|
}
|
|
|
|
|
2018-10-10 16:08:37 +13:00
|
|
|
static void
|
2018-11-19 12:57:52 +13:00
|
|
|
test_output_configuration_button_clicked_cb (CcSoundPanel *self)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
|
|
|
GvcMixerUIDevice *device;
|
|
|
|
GvcMixerStream *stream = NULL;
|
2022-12-16 15:52:05 +01:00
|
|
|
CcOutputTestWindow *window;
|
2021-10-20 00:24:41 -03:00
|
|
|
GtkWidget *toplevel;
|
|
|
|
CcShell *shell;
|
2018-10-10 16:08:37 +13:00
|
|
|
|
|
|
|
device = cc_device_combo_box_get_device (self->output_device_combo_box);
|
|
|
|
if (device != NULL)
|
|
|
|
stream = gvc_mixer_control_get_stream_from_device (self->mixer_control, device);
|
|
|
|
|
2021-10-20 00:24:41 -03:00
|
|
|
shell = cc_panel_get_shell (CC_PANEL (self));
|
|
|
|
toplevel = cc_shell_get_toplevel (shell);
|
|
|
|
|
2022-12-16 15:52:05 +01:00
|
|
|
window = cc_output_test_window_new (stream);
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
|
|
|
|
gtk_window_present (GTK_WINDOW (window));
|
2018-10-10 16:08:37 +13:00
|
|
|
}
|
|
|
|
|
2023-01-10 21:37:55 +01:00
|
|
|
static void
|
|
|
|
volume_levels_activated_cb (CcSoundPanel *self)
|
|
|
|
{
|
|
|
|
CcVolumeLevelsWindow *volume_levels;
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
CcShell *shell;
|
|
|
|
|
|
|
|
shell = cc_panel_get_shell (CC_PANEL (self));
|
|
|
|
toplevel = GTK_WINDOW (cc_shell_get_toplevel (shell));
|
|
|
|
|
|
|
|
volume_levels = cc_volume_levels_window_new (self->mixer_control);
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (volume_levels), toplevel);
|
|
|
|
gtk_window_present (GTK_WINDOW (volume_levels));
|
|
|
|
}
|
|
|
|
|
2023-01-14 19:49:39 +01:00
|
|
|
static void
|
|
|
|
alert_sound_activated_cb (CcSoundPanel *self)
|
|
|
|
{
|
|
|
|
CcAlertChooserWindow *alert_chooser;
|
|
|
|
GtkWindow *toplevel;
|
|
|
|
CcShell *shell;
|
|
|
|
|
|
|
|
shell = cc_panel_get_shell (CC_PANEL (self));
|
|
|
|
toplevel = GTK_WINDOW (cc_shell_get_toplevel (shell));
|
|
|
|
|
|
|
|
alert_chooser = cc_alert_chooser_window_new ();
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (alert_chooser), toplevel);
|
|
|
|
|
|
|
|
g_signal_connect_object (alert_chooser, "destroy",
|
|
|
|
G_CALLBACK (update_alert_sound_label),
|
|
|
|
self, G_CONNECT_SWAPPED);
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (alert_chooser));
|
|
|
|
}
|
|
|
|
|
2018-10-10 16:08:37 +13:00
|
|
|
static const char *
|
2018-11-19 12:57:52 +13:00
|
|
|
cc_sound_panel_get_help_uri (CcPanel *panel)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
|
|
|
return "help:gnome-help/media#sound";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-11-19 12:57:52 +13:00
|
|
|
cc_sound_panel_finalize (GObject *object)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
2023-05-31 15:07:47 +12:00
|
|
|
CcSoundPanel *self = CC_SOUND_PANEL (object);
|
2018-10-10 16:08:37 +13:00
|
|
|
|
2023-05-31 15:07:47 +12:00
|
|
|
g_clear_object (&self->mixer_control);
|
|
|
|
g_clear_object (&self->sound_settings);
|
2018-10-10 16:08:37 +13:00
|
|
|
|
2018-11-19 12:57:52 +13:00
|
|
|
G_OBJECT_CLASS (cc_sound_panel_parent_class)->finalize (object);
|
2018-10-10 16:08:37 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-11-19 12:57:52 +13:00
|
|
|
cc_sound_panel_class_init (CcSoundPanelClass *klass)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
|
|
|
|
2018-11-19 12:57:52 +13:00
|
|
|
panel_class->get_help_uri = cc_sound_panel_get_help_uri;
|
|
|
|
|
|
|
|
object_class->finalize = cc_sound_panel_finalize;
|
|
|
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/sound/cc-sound-panel.ui");
|
|
|
|
|
2023-01-28 15:03:38 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, output_group);
|
2023-01-12 23:33:38 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, output_level_bar);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, output_device_combo_box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, output_profile_row);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, output_profile_combo_box);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, output_volume_slider);
|
2018-11-19 12:57:52 +13:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, balance_slider);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, fade_row);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, fade_slider);
|
2023-01-12 23:33:38 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, subwoofer_row);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, subwoofer_slider);
|
2023-01-28 15:03:38 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, output_no_devices_group);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, input_group);
|
2018-11-19 12:57:52 +13:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, input_level_bar);
|
2023-01-12 23:33:38 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, input_device_combo_box);
|
2018-11-19 12:57:52 +13:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, input_profile_row);
|
2023-01-12 23:33:38 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, input_profile_combo_box);
|
2018-11-19 12:57:52 +13:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, input_volume_slider);
|
2023-01-28 15:03:38 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, input_no_devices_group);
|
2023-01-14 19:49:39 +01:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcSoundPanel, alert_sound_label);
|
2018-10-10 16:08:37 +13:00
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, input_device_changed_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, output_device_changed_cb);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, test_output_configuration_button_clicked_cb);
|
2023-01-10 21:37:55 +01:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, volume_levels_activated_cb);
|
2023-01-14 19:49:39 +01:00
|
|
|
gtk_widget_class_bind_template_callback (widget_class, alert_sound_activated_cb);
|
2018-10-10 16:08:37 +13:00
|
|
|
|
|
|
|
g_type_ensure (CC_TYPE_BALANCE_SLIDER);
|
|
|
|
g_type_ensure (CC_TYPE_DEVICE_COMBO_BOX);
|
|
|
|
g_type_ensure (CC_TYPE_FADE_SLIDER);
|
|
|
|
g_type_ensure (CC_TYPE_LEVEL_BAR);
|
|
|
|
g_type_ensure (CC_TYPE_PROFILE_COMBO_BOX);
|
|
|
|
g_type_ensure (CC_TYPE_SUBWOOFER_SLIDER);
|
|
|
|
g_type_ensure (CC_TYPE_VOLUME_SLIDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-11-19 12:57:52 +13:00
|
|
|
cc_sound_panel_init (CcSoundPanel *self)
|
2018-10-10 16:08:37 +13:00
|
|
|
{
|
2018-11-19 12:57:52 +13:00
|
|
|
g_resources_register (cc_sound_get_resource ());
|
2018-10-10 16:08:37 +13:00
|
|
|
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
|
|
|
|
self->sound_settings = g_settings_new (KEY_SOUNDS_SCHEMA);
|
|
|
|
g_signal_connect_object (self->sound_settings,
|
|
|
|
"changed::allow-volume-above-100-percent",
|
|
|
|
G_CALLBACK (allow_amplified_changed_cb),
|
|
|
|
self,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
allow_amplified_changed_cb (self);
|
|
|
|
|
|
|
|
self->mixer_control = gvc_mixer_control_new ("GNOME Settings");
|
|
|
|
gvc_mixer_control_open (self->mixer_control);
|
|
|
|
|
2019-08-13 11:11:05 +12:00
|
|
|
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);
|
2018-10-10 16:08:37 +13:00
|
|
|
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);
|
sound: update the profile list after getting the signal from gvc
In the ubuntu 20.04, we found a regression on HDMI audio. We plug a
HDMI/DP monitor, the output device is the speaker in the output device
combo box, then we select the HDMI from the combo box, the output
device is switched to HDMI audio successfully, but the configuration
box is empty. This will not happen in the ubuntu 18.04, the profile
will show hdmi-stereo in this situation. So I think this is a
regression.
When problem happens, I could see the errors from log:
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Gvc: DEBUG: Matching profile for 'output:analog-stereo' is '(null)'
Through debugging, I found the cc_profile_combo_box_set_device() is
called too early. In the ubuntu 18.04, this function is called after
pulseaudio changes the active_profile, but in the ubuntu 20.04, it is
called ahead of pulseaudio changes the active_profile.
To fix it, add a signal callback function, after pulseaudio changes
the active_profile, this callback function will be called, then call
cc_profile_combo_box_set_device().
Signed-off-by: Hui Wang <hui.wang@canonical.com>
2020-09-04 17:06:27 +08:00
|
|
|
g_signal_connect_object (self->mixer_control,
|
|
|
|
"active-output-update",
|
|
|
|
G_CALLBACK (output_device_update_cb),
|
|
|
|
self,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (self->mixer_control,
|
|
|
|
"active-input-update",
|
|
|
|
G_CALLBACK (input_device_update_cb),
|
|
|
|
self,
|
|
|
|
G_CONNECT_SWAPPED);
|
2023-01-14 19:49:39 +01:00
|
|
|
|
|
|
|
update_alert_sound_label (self);
|
2018-10-10 16:08:37 +13:00
|
|
|
}
|