aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-11-10 14:56:02 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-11-10 14:56:02 +0100
commit8d981b26459b98189ab3200a23d75ecd0294fb2b (patch)
tree0ebd8521a68823c2168a724d883c768d36db1f36
parent6ee23e401d3847e609f1ef50e1736f69e6253608 (diff)
downloadayatana-indicator-sound-8d981b26459b98189ab3200a23d75ecd0294fb2b.tar.gz
ayatana-indicator-sound-8d981b26459b98189ab3200a23d75ecd0294fb2b.tar.bz2
ayatana-indicator-sound-8d981b26459b98189ab3200a23d75ecd0294fb2b.zip
Restore code to allow amplified volume
-rw-r--r--src/service.vala26
-rw-r--r--src/volume-control.vala3
2 files changed, 28 insertions, 1 deletions
diff --git a/src/service.vala b/src/service.vala
index a08edf3..1173194 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -47,6 +47,7 @@ public class IndicatorSound.Service: Object {
() => { debug("Notifications name vanshed"); notify_server_caps_checked = false; });
this.settings = new Settings ("com.canonical.indicator.sound");
+ this.sharedsettings = new Settings ("com.ubuntu.sound");
this.settings.bind ("visible", this, "visible", SettingsBindFlags.GET);
this.notify["visible"].connect ( () => this.update_root_icon () );
@@ -95,6 +96,8 @@ public class IndicatorSound.Service: Object {
this.sync_preferred_players ();
});
+ sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET);
+
/* Hide the notification when the menu is shown */
var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction;
shown_action.change_state.connect ((state) => {
@@ -173,6 +176,28 @@ public class IndicatorSound.Service: Object {
public bool visible { get; set; }
+ public bool allow_amplified_volume {
+ get {
+ return this.volume_control.max_volume > 1.0;
+ }
+
+ set {
+ if (this.allow_amplified_volume == value)
+ return;
+
+ if (value) {
+ /* from pulse/volume.h: #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) */
+ this.volume_control.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM;
+ }
+ else {
+ this.volume_control.max_volume = 1.0;
+ }
+
+ /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */
+ this.actions.change_action_state ("volume", this.volume_control.volume.volume / this.volume_control.max_volume);
+ }
+ }
+
const ActionEntry[] action_entries = {
{ "root", null, null, "@a{sv} {}", null },
{ "scroll", activate_scroll_action, "i", null, null },
@@ -184,6 +209,7 @@ public class IndicatorSound.Service: Object {
SimpleActionGroup actions;
HashTable<string, SoundMenu> menus;
Settings settings;
+ Settings sharedsettings;
VolumeControl volume_control;
MediaPlayerList players;
uint player_action_update_id;
diff --git a/src/volume-control.vala b/src/volume-control.vala
index 6efac35..2f12b7f 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -40,9 +40,10 @@ public abstract class VolumeControl : Object
public virtual bool mute { get { return false; } }
public virtual bool is_playing { get { return false; } }
private Volume _volume;
+ private double _max_volume = 1.0;
public virtual Volume volume { get { return _volume; } set { } }
public virtual double mic_volume { get { return 0.0; } set { } }
- public virtual double max_volume { get { return 1.0; } protected set { } }
+ public virtual double max_volume { get { return _max_volume; } set { _max_volume = value;} }
public virtual bool high_volume_approved { get { return false; } protected set { } }
public virtual void approve_high_volume() { }