diff options
-rw-r--r-- | MERGE-REVIEW | 19 | ||||
-rw-r--r-- | data/com.canonical.indicator.sound | 3 | ||||
-rw-r--r-- | debian/changelog | 94 | ||||
-rw-r--r-- | debian/control | 3 | ||||
-rw-r--r-- | src/service.vala | 125 | ||||
-rw-r--r-- | src/sound-menu.vala | 11 | ||||
-rw-r--r-- | src/volume-control.vala | 16 | ||||
-rw-r--r-- | tests/manual | 24 |
8 files changed, 275 insertions, 20 deletions
diff --git a/MERGE-REVIEW b/MERGE-REVIEW new file mode 100644 index 0000000..1b7ff95 --- /dev/null +++ b/MERGE-REVIEW @@ -0,0 +1,19 @@ + +This documents the expections that the project has on what both submitters +and reviewers should ensure that they've done for a merge into the project. + +== Submitter Responsibilities == + + * Ensure the project compiles and the test suite executes without error + * Ensure that non-obvious code has comments explaining it + * If the change works on specific profiles, please include those in the merge description. + +== Reviewer Responsibilities == + + * Did the Jenkins build compile? Pass? Run unit tests successfully? + * Are there appropriate tests to cover any new functionality? + * If the description says this effects the phone profile: + * Run tests indicator-sound/unity8* + * If the description says this effects the desktop profile: + * Run tests indicator-sound/unity7* + diff --git a/data/com.canonical.indicator.sound b/data/com.canonical.indicator.sound index ae5fd5d..fca15be 100644 --- a/data/com.canonical.indicator.sound +++ b/data/com.canonical.indicator.sound @@ -12,6 +12,9 @@ ObjectPath=/com/canonical/indicator/sound/phone [desktop_greeter] ObjectPath=/com/canonical/indicator/sound/desktop_greeter +[desktop_lockscreen] +ObjectPath=/com/canonical/indicator/sound/desktop_greeter + [ubiquity] ObjectPath=/com/canonical/indicator/sound/desktop_greeter diff --git a/debian/changelog b/debian/changelog index 2599770..d878559 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,97 @@ +indicator-sound (12.10.2+14.04.20140320-0ubuntu1) trusty; urgency=low + + [ Lars Uebernickel ] + * Scale volume in notifications when allow-amplified-volume is set + (LP: #1293163) + * Use audio-volume-mute-blocking-panel instead of *-blocked-panel + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 20 Mar 2014 08:58:30 +0000 + +indicator-sound (12.10.2+14.04.20140318-0ubuntu1) trusty; urgency=low + + [ Lars Uebernickel ] + * Show a red icon in the panel when a sound is playing while mute is + on (LP: #1291530) + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 18 Mar 2014 10:01:01 +0000 + +indicator-sound (12.10.2+14.04.20140313-0ubuntu1) trusty; urgency=low + + [ Lars Uebernickel ] + * Don't show player sections on the greeter and lock screen (LP: + #1280378) + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 13 Mar 2014 15:33:11 +0000 + +indicator-sound (12.10.2+14.04.20140311.1-0ubuntu1) trusty; urgency=low + + [ Lars Uebernickel ] + * Add desktop_lockscreen profile + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 11 Mar 2014 18:26:29 +0000 + +indicator-sound (12.10.2+14.04.20140305-0ubuntu1) trusty; urgency=low + + [ Lars Uebernickel ] + * Honor com.canonical.indicator.sound visible (LP: #829648) + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 05 Mar 2014 08:44:14 +0000 + +indicator-sound (12.10.2+14.04.20140224-0ubuntu1) trusty; urgency=low + + [ Sebastien Bacher ] + * Remove the new added allow-applified key, it's moved to shared + schemas, that way the other desktop components don't need to depends + on indicator-sound only to read that settings + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 24 Feb 2014 14:33:07 +0000 + +indicator-sound (12.10.2+14.04.20140220-0ubuntu1) trusty; urgency=low + + [ Lars Uebernickel ] + * Add support for amplified volumes Add a settings key "allow- + amplified-volume" which controls whether the volume slider stops at + 100% or PA_VOLUME_UI_MAX. unity-control-center will provide a ui for + this key. + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 20 Feb 2014 18:13:42 +0000 + +indicator-sound (12.10.2+14.04.20140207-0ubuntu1) trusty; urgency=low + + [ Unit193 ] + * Drop the recommends to suggests for the control centers and system + settings so that flavors that don't seed those packages aren't stuck + with them. + + [ Ted Gould ] + * Adding acceptance tests and merge review policies. + + [ CI bot ] + * Adding acceptance tests and merge review policies + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Fri, 07 Feb 2014 16:26:07 +0000 + +indicator-sound (12.10.2+14.04.20140124-0ubuntu1) trusty; urgency=low + + [ Robert Ancell ] + * Use unity-control-center if it is available. (LP: #1257505) + + [ Ted Gould ] + * Own the server capabilities so we clean it up. + + [ Lars Uebernickel ] + * Don't write 'interested-media-players' on startup + IndicatorSound.Service read that gsettings key and inserted the + players desktop ids into a MediaPlayerList, which emits "player- + added" every time a player is added. This patch makes the service + keep track of whether players are added because it is syncing the + key or when a player appeared on the bus. . + + [ Ubuntu daily release ] + * Automatic snapshot from revision 408 + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Fri, 24 Jan 2014 11:00:18 +0000 + indicator-sound (12.10.2+14.04.20131125-0ubuntu1) trusty; urgency=low [ Ted Gould ] diff --git a/debian/control b/debian/control index ab0c0f1..c7b3ed8 100644 --- a/debian/control +++ b/debian/control @@ -31,7 +31,8 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, pulseaudio, -Recommends: gnome-control-center | ubuntu-system-settings, + gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140224), +Recommends: unity-control-center | gnome-control-center | ubuntu-system-settings | pavucontrol, Description: System sound indicator. System sound indicator which provides easy control of the PulseAudio sound daemon. diff --git a/src/service.vala b/src/service.vala index 25a7b18..d4a5bc6 100644 --- a/src/service.vala +++ b/src/service.vala @@ -17,9 +17,13 @@ * Lars Uebernickel <lars.uebernickel@canonical.com> */ -public class IndicatorSound.Service { +public class IndicatorSound.Service: Object { public Service () { 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 () ); this.volume_control = new VolumeControl (); @@ -34,7 +38,7 @@ public class IndicatorSound.Service { this.actions.add_action (this.create_mic_volume_action ()); this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal); - this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE)); + this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); @@ -42,9 +46,9 @@ public class IndicatorSound.Service { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); - this.players.sync (settings.get_strv ("interested-media-players")); + this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { - this.players.sync (settings.get_strv ("interested-media-players")); + this.sync_preferred_players (); }); if (settings.get_boolean ("show-notify-osd-on-scroll")) { @@ -54,6 +58,8 @@ public class IndicatorSound.Service { this.notification.set_hint_string ("x-canonical-private-synchronous", "indicator-sound"); } } + + sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET); } public int run () { @@ -71,6 +77,27 @@ public class IndicatorSound.Service { return 0; } + public bool visible { get; set; } + + public bool allow_amplified_volume { + get { + return this.max_volume > 1.0; + } + + set { + if (value) { + /* from pulse/volume.h: #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) */ + this.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM; + } + else { + this.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.get_volume () / this.max_volume); + } + } + const ActionEntry[] action_entries = { { "root", null, null, "@a{sv} {}", null }, { "scroll", activate_scroll_action, "i", null, null }, @@ -82,10 +109,19 @@ public class IndicatorSound.Service { SimpleActionGroup actions; HashTable<string, SoundMenu> menus; Settings settings; + Settings sharedsettings; VolumeControl volume_control; MediaPlayerList players; uint player_action_update_id; + bool mute_blocks_sound; + uint sound_was_blocked_timeout_id; Notify.Notification notification; + bool syncing_preferred_players = false; + + /* Maximum volume as a scaling factor between the volume action's state and the value in + * this.volume_control. See create_volume_action(). + */ + double max_volume = 1.0; const double volume_step_percentage = 0.06; @@ -93,7 +129,7 @@ public class IndicatorSound.Service { int delta = param.get_int32(); /* positive for up, negative for down */ double v = this.volume_control.get_volume () + volume_step_percentage * delta; - this.volume_control.set_volume (v.clamp (0.0, 1.0)); + this.volume_control.set_volume (v.clamp (0.0, this.max_volume)); if (this.notification != null) { string icon; @@ -107,7 +143,7 @@ public class IndicatorSound.Service { icon = "notification-audio-volume-high"; this.notification.update ("indicator-sound", "", icon); - this.notification.set_hint_int32 ("value", ((int32) (100 * v)).clamp (-1, 101)); + this.notification.set_hint_int32 ("value", ((int32) (100 * v / this.max_volume)).clamp (-1, 101)); try { this.notification.show (); } @@ -123,7 +159,12 @@ public class IndicatorSound.Service { if (env == "xubuntu" || env == "ubuntustudio") cmd = "pavucontrol"; else - cmd = "gnome-control-center sound"; + { + if (Environment.get_variable ("XDG_CURRENT_DESKTOP") == "Unity" && Environment.find_program_in_path ("unity-control-center") != null) + cmd = "unity-control-center sound"; + else + cmd = "gnome-control-center sound"; + } try { Process.spawn_command_line_async (cmd); @@ -147,7 +188,7 @@ public class IndicatorSound.Service { double volume = this.volume_control.get_volume (); string icon; if (this.volume_control.mute) - icon = "audio-volume-muted-panel"; + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; else if (volume <= 0.0) icon = "audio-volume-low-zero-panel"; else if (volume <= 0.3) @@ -170,7 +211,7 @@ public class IndicatorSound.Service { builder.add ("{sv}", "title", new Variant.string (_("Sound"))); builder.add ("{sv}", "accessible-desc", new Variant.string (accessible_name)); builder.add ("{sv}", "icon", serialize_themed_icon (icon)); - builder.add ("{sv}", "visible", new Variant.boolean (true)); + builder.add ("{sv}", "visible", new Variant.boolean (this.visible)); root_action.set_state (builder.end()); } @@ -190,27 +231,65 @@ public class IndicatorSound.Service { this.update_root_icon (); }); + this.volume_control.notify["is-playing"].connect( () => { + if (!this.volume_control.mute) { + this.mute_blocks_sound = false; + return; + } + + if (this.volume_control.is_playing) { + this.mute_blocks_sound = true; + } + else if (this.mute_blocks_sound) { + /* Continue to show the blocking icon five seconds after a player has tried to play something */ + if (this.sound_was_blocked_timeout_id > 0) + Source.remove (this.sound_was_blocked_timeout_id); + + this.sound_was_blocked_timeout_id = Timeout.add_seconds (5, () => { + this.mute_blocks_sound = false; + this.sound_was_blocked_timeout_id = 0; + this.update_root_icon (); + return false; + }); + } + + this.update_root_icon (); + }); + return mute_action; } void volume_changed (double volume) { var volume_action = this.actions.lookup_action ("volume") as SimpleAction; - volume_action.set_state (new Variant.double (volume)); + + /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */ + volume_action.set_state (new Variant.double (volume / this.max_volume)); this.update_root_icon (); } Action create_volume_action () { - var volume_action = new SimpleAction.stateful ("volume", VariantType.INT32, new Variant.double (this.volume_control.get_volume ())); + /* The action's state is between be in [0.0, 1.0] instead of [0.0, + * max_volume], so that we don't need to update the slider menu item + * every time allow-amplified-volume is changed. Convert between the + * two here, so that we always pass the full range into + * volume_control.set_volume(). + */ + + double volume = this.volume_control.get_volume () / this.max_volume; + + var volume_action = new SimpleAction.stateful ("volume", VariantType.INT32, new Variant.double (volume)); volume_action.change_state.connect ( (action, val) => { - volume_control.set_volume (val.get_double ()); + double v = val.get_double () * this.max_volume; + volume_control.set_volume (v.clamp (0.0, this.max_volume)); }); /* activating this action changes the volume by the amount given in the parameter */ volume_action.activate.connect ( (action, param) => { - double v = volume_control.get_volume () + volume_step_percentage * param.get_int32 (); - volume_control.set_volume (v.clamp (0.0, 1.0)); + int delta = param.get_int32 (); + double v = volume_control.get_volume () + volume_step_percentage * delta; + volume_control.set_volume (v.clamp (0.0, this.max_volume)); }); this.volume_control.volume_changed.connect (volume_changed); @@ -281,11 +360,21 @@ public class IndicatorSound.Service { this.player_action_update_id = Idle.add (this.update_player_actions); } + + void sync_preferred_players () { + this.syncing_preferred_players = true; + this.players.sync (settings.get_strv ("interested-media-players")); + this.syncing_preferred_players = false; + } + void update_preferred_players () { - var builder = new VariantBuilder (VariantType.STRING_ARRAY); - foreach (var player in this.players) - builder.add ("s", player.id); - this.settings.set_value ("interested-media-players", builder.end ()); + /* only write the key if we're not getting this call because we're syncing from the key right now */ + if (!this.syncing_preferred_players) { + var builder = new VariantBuilder (VariantType.STRING_ARRAY); + foreach (var player in this.players) + builder.add ("s", player.id); + this.settings.set_value ("interested-media-players", builder.end ()); + } } void player_added (MediaPlayer player) { diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 480e1cf..3fdfc36 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -22,7 +22,8 @@ class SoundMenu: Object public enum DisplayFlags { NONE = 0, SHOW_MUTE = 1, - HIDE_INACTIVE_PLAYERS = 2 + HIDE_INACTIVE_PLAYERS = 2, + HIDE_PLAYERS = 4 } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -55,6 +56,7 @@ class SoundMenu: Object this.root = new Menu (); root.append_item (root_item); + this.hide_players = (flags & DisplayFlags.HIDE_PLAYERS) != 0; this.hide_inactive = (flags & DisplayFlags.HIDE_INACTIVE_PLAYERS) != 0; this.notify_handlers = new HashTable<MediaPlayer, ulong> (direct_hash, direct_equal); } @@ -119,6 +121,7 @@ class SoundMenu: Object bool mic_volume_shown; bool settings_shown = false; bool hide_inactive; + bool hide_players = false; HashTable<MediaPlayer, ulong> notify_handlers; /* returns the position in this.menu of the section that's associated with @player */ @@ -137,6 +140,9 @@ class SoundMenu: Object } void insert_player_section (MediaPlayer player) { + if (this.hide_players) + return; + var section = new Menu (); Icon icon; @@ -166,6 +172,9 @@ class SoundMenu: Object } void remove_player_section (MediaPlayer player) { + if (this.hide_players) + return; + int index = this.find_player_section (player); if (index >= 0) this.menu.remove (index); diff --git a/src/volume-control.vala b/src/volume-control.vala index e994922..8f21b60 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -31,6 +31,7 @@ public class VolumeControl : Object private PulseAudio.Context context; private bool _mute = true; + private bool _is_playing = false; private double _volume = 0.0; private double _mic_volume = 0.0; @@ -97,6 +98,13 @@ public class VolumeControl : Object this.notify_property ("mute"); } + var playing = (i.state == PulseAudio.SinkState.RUNNING); + if (_is_playing != playing) + { + _is_playing = playing; + this.notify_property ("is-playing"); + } + if (_volume != volume_to_double (i.volume.values[0])) { _volume = volume_to_double (i.volume.values[0]); @@ -235,6 +243,14 @@ public class VolumeControl : Object } } + public bool is_playing + { + get + { + return this._is_playing; + } + } + /* Volume operations */ private static PulseAudio.Volume double_to_volume (double vol) { diff --git a/tests/manual b/tests/manual new file mode 100644 index 0000000..201465c --- /dev/null +++ b/tests/manual @@ -0,0 +1,24 @@ + +Test-case indicator-sound/unity7-items-check +<dl> + <dt>Log in to a Unity 7 user session</dt> + <dt>Go to the panel and click on the Sound indicator</dt> + <dd>Ensure there are items in the menu</dd> +</dl> + +Test-case indicator-sound/unity7-greeter-items-check +<dl> + <dt>Start a system and wait for the greeter or logout of the current user session</dt> + <dt>Go to the panel and click on the Sound indicator</dt> + <dd>Ensure there are items in the menu</dd> +</dl> + +Test-case indicator-sound/unity8-items-check +<dl> + <dt>Login to a user session running Unity 8</dt> + <dt>Pull down the top panel until it sticks open</dt> + <dt>Navigate through the tabs until "Sound" is shown</dt> + <dd>Sound is at the top of the menu</dd> + <dd>The menu is populated with items</dd> +</dl> + |