~ubuntu-desktop/gnome-settings-daemon/ubuntu

« back to all changes in this revision

Viewing changes to debian/patches/70_allow_sound_above_100.patch

  • Committer: Iain Lane
  • Date: 2018-07-24 16:02:15 UTC
  • Revision ID: iain@orangesquash.org.uk-20180724160215-2zwqcisylwweql16
Moved to git: lp:~ubuntu-desktop/ubuntu/+source/gnome-settings-daemon

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: Allow volume to bet set above 100%.
2
 
 Some systems have low maximum volume set (like x220), allow, from an option
3
 
 in gnome-control-center to set it above that 100% limit.
4
 
 Modified from original patch in ubuntu-settings-daemon from Lars Uebernickel.
5
 
Origin: ubuntu
6
 
Bug-Ubuntu: https://launchpad.net/bugs/1706524
7
 
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=710424
8
 
---
9
 
 plugins/media-keys/gsd-media-keys-manager.c |   27 ++++++++++++++++++++++++---
10
 
 1 file changed, 24 insertions(+), 3 deletions(-)
11
 
 
12
 
--- a/plugins/media-keys/gsd-media-keys-manager.c
13
 
+++ b/plugins/media-keys/gsd-media-keys-manager.c
14
 
@@ -167,6 +167,7 @@ struct GsdMediaKeysManagerPrivate
15
 
 
16
 
         GSettings       *settings;
17
 
         GHashTable      *custom_settings;
18
 
+        GSettings       *sound_settings;
19
 
 
20
 
         GPtrArray       *keys;
21
 
 
22
 
@@ -1146,6 +1147,18 @@ ensure_canberra (GsdMediaKeysManager *ma
23
 
        if (manager->priv->ca != NULL)
24
 
                return;
25
 
 
26
 
+        if (strstr (g_getenv("XDG_CURRENT_DESKTOP"), "ubuntu") != NULL) {
27
 
+                GSettingsSchema *schema;
28
 
+                schema = g_settings_schema_source_lookup(g_settings_schema_source_get_default(),
29
 
+                                                         "com.ubuntu.sound", TRUE);
30
 
+
31
 
+                if (schema != NULL)
32
 
+                {
33
 
+                        manager->priv->sound_settings = g_settings_new_full(schema, NULL, NULL);
34
 
+                        g_settings_schema_unref(schema);
35
 
+                }
36
 
+        }
37
 
+
38
 
         ca_context_create (&manager->priv->ca);
39
 
         ca_context_set_driver (manager->priv->ca, "pulse");
40
 
         ca_context_change_props (manager->priv->ca, 0,
41
 
@@ -1166,6 +1179,7 @@ update_dialog (GsdMediaKeysManager *mana
42
 
                guint                vol,
43
 
                gboolean             muted,
44
 
                gboolean             sound_changed,
45
 
+               pa_volume_t          max_volume,
46
 
                gboolean             quiet)
47
 
 {
48
 
         GvcMixerUIDevice *device;
49
 
@@ -1173,7 +1187,7 @@ update_dialog (GsdMediaKeysManager *mana
50
 
         const char *icon;
51
 
 
52
 
         if (!muted) {
53
 
-                vol = (int) (100 * (double) vol / PA_VOLUME_NORM);
54
 
+                vol = (int) (100 * (double) vol / max_volume);
55
 
                 vol = CLAMP (vol, 0, 100);
56
 
         } else {
57
 
                 vol = 0.0;
58
 
@@ -1329,6 +1343,7 @@ do_sound_action (GsdMediaKeysManager *ma
59
 
         gboolean old_muted, new_muted;
60
 
         guint old_vol, new_vol, norm_vol_step;
61
 
         gboolean sound_changed;
62
 
+        pa_volume_t max_volume;
63
 
 
64
 
         /* Find the stream that corresponds to the device, if any */
65
 
         stream = NULL;
66
 
@@ -1348,6 +1363,11 @@ do_sound_action (GsdMediaKeysManager *ma
67
 
         if (stream == NULL)
68
 
                 return;
69
 
 
70
 
+        if ((manager->priv->sound_settings != NULL) && g_settings_get_boolean (manager->priv->sound_settings, "allow-amplified-volume"))
71
 
+                max_volume = PA_VOLUME_UI_MAX;
72
 
+        else
73
 
+                max_volume = PA_VOLUME_NORM;
74
 
+
75
 
         if (flags & SOUND_ACTION_FLAG_IS_PRECISE)
76
 
                 norm_vol_step = PA_VOLUME_NORM * VOLUME_STEP_PRECISE / 100;
77
 
         else
78
 
@@ -1374,7 +1394,7 @@ do_sound_action (GsdMediaKeysManager *ma
79
 
                 new_muted = FALSE;
80
 
                 /* When coming out of mute only increase the volume if it was 0 */
81
 
                 if (!old_muted || old_vol == 0)
82
 
-                        new_vol = MIN (old_vol + norm_vol_step, MAX_VOLUME);
83
 
+                        new_vol = MIN (old_vol + norm_vol_step, max_volume);
84
 
                 break;
85
 
         }
86
 
 
87
 
@@ -1391,7 +1411,7 @@ do_sound_action (GsdMediaKeysManager *ma
88
 
         }
89
 
 
90
 
         update_dialog (manager, stream, new_vol, new_muted, sound_changed,
91
 
-                       flags & SOUND_ACTION_FLAG_IS_QUIET);
92
 
+                       max_volume, flags & SOUND_ACTION_FLAG_IS_QUIET);
93
 
 }
94
 
 
95
 
 static void
96
 
@@ -2963,6 +2983,7 @@ gsd_media_keys_manager_stop (GsdMediaKey
97
 
         g_clear_object (&priv->power_proxy);
98
 
         g_clear_object (&priv->power_screen_proxy);
99
 
         g_clear_object (&priv->power_keyboard_proxy);
100
 
+        g_clear_object (&priv->sound_settings);
101
 
         g_clear_object (&priv->composite_device);
102
 
         g_clear_object (&priv->mpris_controller);
103
 
         g_clear_object (&priv->screencast_proxy);