Merge lp:~xavi-garcia-mena/indicator-sound/bug-1512798-reenable-amplified-volume into lp:indicator-sound/15.10

Proposed by Xavi Garcia on 2015-11-10
Status: Merged
Approved by: Charles Kerr on 2015-11-11
Approved revision: 508
Merged at revision: 520
Proposed branch: lp:~xavi-garcia-mena/indicator-sound/bug-1512798-reenable-amplified-volume
Merge into: lp:indicator-sound/15.10
Diff against target: 73 lines (+28/-1)
2 files modified
src/service.vala (+26/-0)
src/volume-control.vala (+2/-1)
To merge this branch: bzr merge lp:~xavi-garcia-mena/indicator-sound/bug-1512798-reenable-amplified-volume
Reviewer Review Type Date Requested Status
Charles Kerr (community) 2015-11-10 Approve on 2015-11-11
PS Jenkins bot (community) continuous-integration Approve on 2015-11-10
Review via email: mp+277128@code.launchpad.net

Commit message

Reenables allow amplified volume.

Description of the change

Reenables allow amplified volume.

To post a comment you must log in.
Charles Kerr (charlesk) wrote :

LGTM. Thanks Xavi :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/service.vala'
2--- src/service.vala 2015-10-02 14:07:44 +0000
3+++ src/service.vala 2015-11-10 14:02:00 +0000
4@@ -47,6 +47,7 @@
5 () => { debug("Notifications name vanshed"); notify_server_caps_checked = false; });
6
7 this.settings = new Settings ("com.canonical.indicator.sound");
8+ this.sharedsettings = new Settings ("com.ubuntu.sound");
9
10 this.settings.bind ("visible", this, "visible", SettingsBindFlags.GET);
11 this.notify["visible"].connect ( () => this.update_root_icon () );
12@@ -95,6 +96,8 @@
13 this.sync_preferred_players ();
14 });
15
16+ sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET);
17+
18 /* Hide the notification when the menu is shown */
19 var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction;
20 shown_action.change_state.connect ((state) => {
21@@ -173,6 +176,28 @@
22
23 public bool visible { get; set; }
24
25+ public bool allow_amplified_volume {
26+ get {
27+ return this.volume_control.max_volume > 1.0;
28+ }
29+
30+ set {
31+ if (this.allow_amplified_volume == value)
32+ return;
33+
34+ if (value) {
35+ /* from pulse/volume.h: #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) */
36+ this.volume_control.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM;
37+ }
38+ else {
39+ this.volume_control.max_volume = 1.0;
40+ }
41+
42+ /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */
43+ this.actions.change_action_state ("volume", this.volume_control.volume.volume / this.volume_control.max_volume);
44+ }
45+ }
46+
47 const ActionEntry[] action_entries = {
48 { "root", null, null, "@a{sv} {}", null },
49 { "scroll", activate_scroll_action, "i", null, null },
50@@ -184,6 +209,7 @@
51 SimpleActionGroup actions;
52 HashTable<string, SoundMenu> menus;
53 Settings settings;
54+ Settings sharedsettings;
55 VolumeControl volume_control;
56 MediaPlayerList players;
57 uint player_action_update_id;
58
59=== modified file 'src/volume-control.vala'
60--- src/volume-control.vala 2015-08-12 14:00:56 +0000
61+++ src/volume-control.vala 2015-11-10 14:02:00 +0000
62@@ -40,9 +40,10 @@
63 public virtual bool mute { get { return false; } }
64 public virtual bool is_playing { get { return false; } }
65 private Volume _volume;
66+ private double _max_volume = 1.0;
67 public virtual Volume volume { get { return _volume; } set { } }
68 public virtual double mic_volume { get { return 0.0; } set { } }
69- public virtual double max_volume { get { return 1.0; } protected set { } }
70+ public virtual double max_volume { get { return _max_volume; } set { _max_volume = value;} }
71
72 public virtual bool high_volume_approved { get { return false; } protected set { } }
73 public virtual void approve_high_volume() { }

Subscribers

People subscribed via source and target branches