diff options
author | Ted Gould <ted@gould.cx> | 2014-11-05 17:56:17 +0000 |
---|---|---|
committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-11-05 17:56:17 +0000 |
commit | b9caf5671da45dad55e69f59fc3ce016057567fa (patch) | |
tree | 05f4c79c23bff1fd757a06592f1d71e16c6a4994 | |
parent | dec2d5350f47e52539941b45d394516066a19678 (diff) | |
parent | 08bcdc3b069c4c5ce7cb2a769daa8573fce5cd5d (diff) | |
download | ayatana-indicator-sound-b9caf5671da45dad55e69f59fc3ce016057567fa.tar.gz ayatana-indicator-sound-b9caf5671da45dad55e69f59fc3ce016057567fa.tar.bz2 ayatana-indicator-sound-b9caf5671da45dad55e69f59fc3ce016057567fa.zip |
Manually merging branches to resolve conflicts Fixes: 1358340, 1373404, 1378564, 1378961, 1381871
Approved by: PS Jenkins bot
-rw-r--r-- | debian/changelog | 13 | ||||
-rw-r--r-- | src/service.vala | 23 | ||||
-rw-r--r-- | src/sound-menu.vala | 40 | ||||
-rw-r--r-- | src/volume-control.vala | 102 | ||||
-rw-r--r-- | tests/manual | 99 |
5 files changed, 268 insertions, 9 deletions
diff --git a/debian/changelog b/debian/changelog index 483c78b..899fa03 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +indicator-sound (12.10.2+14.10.20141010-0ubuntu8) UNRELEASED; urgency=medium + + * Remove various Vala warnings + * Show notifications on volume change (LP: #1378564, #1378961) + * Warn on high audio levels when using headphones (LP: #1232633, #1373404) + * service.vala: don't call set_volume unnecessarily (LP: #1381871) + * Integration test for audio roles + * Integration test for silent mode + * Ensure the greeter menu matches whether song metadata should be shown, + and update the metadata based on the new setting. (LP: #1358340) + + -- Ted Gould <ted@ubuntu.com> Wed, 05 Nov 2014 10:42:12 -0600 + indicator-sound (12.10.2+14.10.20141010-0ubuntu1) utopic; urgency=low [ Ricardo Salveti de Araujo ] diff --git a/src/service.vala b/src/service.vala index 2a65492..fd0c08d 100644 --- a/src/service.vala +++ b/src/service.vala @@ -49,6 +49,7 @@ public class IndicatorSound.Service: Object { this.actions.add_action (this.create_mute_action ()); this.actions.add_action (this.create_volume_action ()); this.actions.add_action (this.create_mic_volume_action ()); + this.actions.add_action (this.create_high_volume_actions ()); this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); @@ -60,6 +61,10 @@ public class IndicatorSound.Service: Object { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); + this.menus.@foreach ( (profile, menu) => { + this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE); + }); + this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { this.sync_preferred_players (); @@ -69,7 +74,7 @@ public class IndicatorSound.Service: Object { List<string> caps = Notify.get_server_caps (); if (caps.find_custom ("x-canonical-private-synchronous", strcmp) != null) { this.notification = new Notify.Notification ("indicator-sound", "", ""); - this.notification.set_hint_string ("x-canonical-private-synchronous", "indicator-sound"); + this.notification.set_hint ("x-canonical-private-synchronous", "indicator-sound"); } } @@ -126,6 +131,9 @@ public class IndicatorSound.Service: Object { } 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.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM; @@ -174,6 +182,8 @@ public class IndicatorSound.Service: Object { double v = this.volume_control.get_volume () + volume_step_percentage * delta; this.volume_control.set_volume (v.clamp (0.0, this.max_volume)); + /* TODO: Don't want to mess up the desktop today, but we should remove this + scrolling change and merge that into volume control's notification */ if (this.notification != null) { string icon; if (v <= 0.0) @@ -186,7 +196,7 @@ public class IndicatorSound.Service: Object { icon = "notification-audio-volume-high"; this.notification.update ("indicator-sound", "", icon); - this.notification.set_hint_int32 ("value", ((int32) (100 * v / this.max_volume)).clamp (-1, 101)); + this.notification.set_hint ("value", ((int32) (100 * v / this.max_volume)).clamp (-1, 101)); try { this.notification.show (); } @@ -388,6 +398,15 @@ public class IndicatorSound.Service: Object { return volume_action; } + Action create_high_volume_actions () { + var high_volume_action = new SimpleAction.stateful("high-volume", null, new Variant.boolean (this.volume_control.high_volume)); + + this.volume_control.notify["high-volume"].connect( () => + high_volume_action.set_state(new Variant.boolean (this.volume_control.high_volume))); + + return high_volume_action; + } + void bus_acquired (DBusConnection connection, string name) { try { connection.export_action_group ("/com/canonical/indicator/sound", this.actions); diff --git a/src/sound-menu.vala b/src/sound-menu.vala index f245a1f..3881faf 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -93,12 +93,49 @@ public class SoundMenu: Object this.mic_volume_shown = true; } else if (!value && this.mic_volume_shown) { - this.volume_section.remove (this.volume_section.get_n_items () -1); + int location = -1; + while ((location = find_action(this.volume_section, "indicator.mic-volume")) != -1) { + this.volume_section.remove (location); + } this.mic_volume_shown = false; } } } + public bool show_high_volume_warning { + get { + return this.high_volume_warning_shown; + } + set { + if (value && !this.high_volume_warning_shown) { + /* NOTE: Action doesn't really exist, just used to find below when removing */ + var item = new MenuItem(_("High volume can damage your hearing."), "indicator.high-volume-warning-item"); + volume_section.append_item (item); + this.high_volume_warning_shown = true; + } + else if (!value && this.high_volume_warning_shown) { + int location = -1; + while ((location = find_action(this.volume_section, "indicator.high-volume-warning-item")) != -1) { + this.volume_section.remove (location); + } + this.high_volume_warning_shown = false; + } + } + } + + int find_action (Menu menu, string in_action) { + int n = menu.get_n_items (); + for (int i = 0; i < n; i++) { + string action; + menu.get_item_attribute (i, "action", "s", out action); + if (in_action == action) + return i; + } + + return -1; + } + + public void add_player (MediaPlayer player) { if (this.notify_handlers.contains (player)) return; @@ -141,6 +178,7 @@ public class SoundMenu: Object Menu volume_section; bool mic_volume_shown; bool settings_shown = false; + bool high_volume_warning_shown = false; bool hide_inactive; bool hide_players = false; HashTable<MediaPlayer, ulong> notify_handlers; diff --git a/src/volume-control.vala b/src/volume-control.vala index ad186a7..6f22dc5 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -19,6 +19,7 @@ */ using PulseAudio; +using Notify; using Gee; [CCode(cname="pa_cvolume_set", cheader_filename = "pulse/volume.h")] @@ -67,6 +68,8 @@ public class VolumeControl : Object private uint _accountservice_volume_timer = 0; private bool _send_next_local_volume = false; private double _account_service_volume = 0.0; + private Notify.Notification _notification; + private bool _active_port_headphone = false; public signal void volume_changed (double v); public signal void mic_volume_changed (double v); @@ -77,6 +80,9 @@ public class VolumeControl : Object /** true when a microphone is active **/ public bool active_mic { get; private set; default = false; } + /** true when high volume warnings should be shown */ + public bool high_volume { get; set; } + public VolumeControl () { if (loop == null) @@ -84,6 +90,13 @@ public class VolumeControl : Object _mute_cancellable = new Cancellable (); _volume_cancellable = new Cancellable (); + + Notify.init ("Volume"); + _notification = new Notify.Notification(_("Volume"), "", "audio-volume-muted"); + _notification.set_hint ("value", 0); + _notification.set_hint ("x-canonical-private-synchronous", "true"); + _notification.set_hint ("x-canonical-non-shaped-icon", "true"); + setup_accountsservice.begin (); this.reconnect_to_pulse (); @@ -149,6 +162,8 @@ public class VolumeControl : Object private void sink_info_cb_for_props (Context c, SinkInfo? i, int eol) { + bool old_active_port_headphone = this._active_port_headphone; + if (i == null) return; @@ -165,12 +180,27 @@ public class VolumeControl : Object this.notify_property ("is-playing"); } + /* Check if the current active port is headset/headphone */ + /* There is not easy way to check if the port is a headset/headphone besides + * checking for the port name. On touch (with the pulseaudio droid element) + * the headset/headphone port is called 'output-headset' and 'output-headphone'. + * On the desktop this is usually called 'analog-output-headphones' */ + if (i.active_port.name == "output-wired_headset" || + i.active_port.name == "output-wired_headphone" || + i.active_port.name == "analog-output-headphones") { + _active_port_headphone = true; + } else { + _active_port_headphone = false; + } + if (_pulse_use_stream_restore == false && _volume != volume_to_double (i.volume.max ())) { _volume = volume_to_double (i.volume.max ()); volume_changed (_volume); start_local_volume_timer(); + } else if (this._active_port_headphone != old_active_port_headphone) { + volume_changed (_volume); } } @@ -572,8 +602,64 @@ public class VolumeControl : Object public void set_volume (double volume) { - if (set_volume_internal (volume)) + /* Using this to detect whether we're on the phone or not */ + if (_pulse_use_stream_restore) { + /* Watch for extreme */ + if (volume > 0.75 && _active_port_headphone) + high_volume = true; + else + high_volume = false; + + /* Determine Label */ + string volume_label = ""; + if (high_volume) + volume_label = _("High volume"); + + /* Choose an icon */ + string icon = "audio-volume-muted"; + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + + /* Choose a sound */ + string? sound = null; + if (!((_active_sink_input >= 0) && (_active_sink_input < _valid_roles.length) + && (_valid_roles[_active_sink_input] == "multimedia"))) + sound = "/usr/share/sounds/ubuntu/stereo/message.ogg"; + + /* Check tint */ + string tint = "false"; + if (high_volume) + tint = "true"; + + /* Put it all into the notification */ + _notification.clear_hints (); + _notification.update (_("Volume"), volume_label, icon); + _notification.set_hint ("value", (int32)(volume * 100.0)); + /* TODO: Removing sound until we can get all the roles cleaned up for + when to play it. We expect this to come back, but in another landing. + _notification.set_hint ("sound-file", sound); + */ + _notification.set_hint ("x-canonical-value-bar-tint", tint); + _notification.set_hint ("x-canonical-private-synchronous", "true"); + _notification.set_hint ("x-canonical-non-shaped-icon", "true"); + + /* Show it */ + try { + _notification.show (); + } catch (GLib.Error e) { + warning("Unable to send volume change notification: %s", e.message); + } + } + + if (set_volume_internal (volume)) { start_local_volume_timer(); + } } void set_mic_volume_success_cb (Context c, int success) @@ -689,7 +775,7 @@ public class VolumeControl : Object } /* AccountsService operations */ - private void accountsservice_props_changed_cb (DBusProxy proxy, Variant changed_properties, string[] invalidated_properties) + private void accountsservice_props_changed_cb (DBusProxy proxy, Variant changed_properties, string[]? invalidated_properties) { Variant volume_variant = changed_properties.lookup_value ("Volume", new VariantType ("d")); if (volume_variant != null) { @@ -747,10 +833,14 @@ public class VolumeControl : Object // Get current values and listen for changes _user_proxy.g_properties_changed.connect (accountsservice_props_changed_cb); - var props_variant = yield _user_proxy.get_connection ().call (_user_proxy.get_name (), _user_proxy.get_object_path (), "org.freedesktop.DBus.Properties", "GetAll", new Variant ("(s)", _user_proxy.get_interface_name ()), null, DBusCallFlags.NONE, -1); - Variant props; - props_variant.get ("(@a{sv})", out props); - accountsservice_props_changed_cb(_user_proxy, props, null); + try { + var props_variant = yield _user_proxy.get_connection ().call (_user_proxy.get_name (), _user_proxy.get_object_path (), "org.freedesktop.DBus.Properties", "GetAll", new Variant ("(s)", _user_proxy.get_interface_name ()), null, DBusCallFlags.NONE, -1); + Variant props; + props_variant.get ("(@a{sv})", out props); + accountsservice_props_changed_cb(_user_proxy, props, null); + } catch (GLib.Error e) { + debug("Unable to get properties for user %s at first try: %s", username, e.message); + } } private void greeter_user_changed (string username) diff --git a/tests/manual b/tests/manual index 201465c..c1cc214 100644 --- a/tests/manual +++ b/tests/manual @@ -22,3 +22,102 @@ Test-case indicator-sound/unity8-items-check <dd>The menu is populated with items</dd> </dl> +Test-case indicator-sound/unity8-sound-notifications +<dl> + <dt>Adjust volume using HW keys if available</dt> + <dd>A notification bubble should appear with the sound volume</dd> + <dd>An audibule sound should play at the level of the audio</dd> + <dt>Adjust volume with slider in sound indicator</dt> + <dd>A notification bubble should appear with the sound volume</dd> + <dd>An audibule sound should play at the level of the audio</dd> + <dt>Open a video with sound and play in media player</dt> + <dd>The video should play and the sound should be audible</dd> + <dt>Adjust volume using HW keys if available</dt> + <dd>A notification bubble should appear with the sound volume</dd> + <dd>No notification sound should be heard</dd> + <dt>Adjust volume with slider in sound indicator</dt> + <dd>A notification bubble should appear with the sound volume</dd> + <dd>No notification sound should be heard</dd> +</dl> + +Test-case indicator-sound/unity8-high-volume +<dl> + <dt>Plug headphones into the headphone jack</dt> + <dt>Adjust volume so that it is at the midpoint of volume range</dt> + <dd>The slider should be in the middle of the scale</dd> + <dt>Increase the volume once using HW keys if available</dt> + <dd>A notification bubble should appear with the sound volume</dd> + <dd>There should be no text on the notification</dd> + <dt>Increase the volume using HW keys until it is roughly 90% of the range</dt> + <dd>A notification bubble should appear with the sound volume</dd> + <dd>The text on the notification should read "High volume"</dd> + <dd>The range on the notification bubble should have a different color signifying the higher volume</dd> + <dt>Decrease the volume using HW keys until it is roughly 50% of the range</dt> + <dd>A notification bubble should appear with the sound volume</dd> + <dd>There should be no text on the notification</dd> + <dd>The range on the notification bubble should have a standard color</dd> +</dl> + +Test-case indicator-sound/unity8-silent-mode +<dl> + <dt>NOTE: This test currently doesn't work because of a bug: http://pad.lv/1336715</dt> + <dt>Open the Sound menu</dt> + <dd>The sound menu includes an item "Silent Mode" which is a check box</dd> + <dd>The checkbox is not checked</dd> + <dt>Enable silent mode</dt> + <dd>Selecting the "Silent Mode" item should cause the box to be checked</dd> + <dt>Open the sound panel in system settings</dt> + <dd>The sound panel includes an item "Silent Mode" which is a check box</dd> + <dd>The checkbox is checked</dd> + <dt>Disable silent mode in system settings</dt> + <dd>The checkbox is not checked</dd> + <dt>Open the Sound menu</dt> + <dd>The sound menu includes an item "Silent Mode" which is a check box</dd> + <dd>The checkbox is not checked</dd> +</dl> + +Test-case indicator-sound/unity8-audio-roles +<dl> + <dt>Without playing anything (no active audio stream), change the volume on the indicator or with the volume buttons and then try playing one of the following audio streams: camera shutter, ringtone, message notification, dtmf</dt> + <dd>The audio stream should reflect the volume set on the indicator</dd> + <dt>Without playing anything (no active audio stream), change the volume on the indicator or with volume buttons and then try playing one of the following audio streams: music-app, webrowser (youtube)</dt> + <dd>The audio stream should not be affected by the volume set on the indicator when there was no other active stream</dt> + <dt>Play a multimedia stream (music-app, webrowser) and change the volume on the indicator when the stream is active</dt> + <dd>The multimedia audio stream should reflect the volume set on the indicator</dd> + <dd>When stopping/closing the multimedia stream, it should automatically show up the volume for the alert role (ringtone, notification, etc)</dd> + <dd>No other role should be affected by the volume level used by the multimedia role</dd> + <dt>Play a alarm stream (clock-app) and change the volume on the indicator when the stream is active</dt> + <dd>The alarm audio stream should reflect the volume set on the indicator</dd> + <dd>When stopping/closing the alarm stream, it should automatically show up the volume for the alert role (ringtone, notification, etc)</dd> + <dd>No other role should be affected by the volume level used by the alarm role</dd> + <dt>Start a voice call using the dialer-app and change the volume on the indicator when the call is active</dt> + <dd>The phone audio stream should reflect the volume set on the indicator</dd> + <dd>When hanging up the voice call it should automatically show up the volume for the alert role (ringtone, notification, etc)</dd> + <dd>No other role should be affected by the volume level used by the phone role</dd> +</dl> + +Test-case indicator-sound/unity8-embedded-greeter +<dl> + <dt>NOTE: Only works with embedded greeter, split greeter will require modifications to this test</dt> + <dt>Ensure System Settings is set to "Show Messages on Greeter"</dt> + <dt>Play a song in the media player</dt> + <dd>The song should be heard</dd> + <dd>There should be an entry in the sound menu with the meta data for the song being played</dd> + <dt>Go to the greeter. This can be done by hitting the lock button twice.</dt> + <dt>Ensure the sound menu has song meta data</dt> + <dd>There should be an entry in the sound menu with the meta data for the song being played</dd> + <dt>Pause the song in the greeter</dt> + <dd>The song should stop playing</dd> + <dt>Resume the song in the greeter</dt> + <dd>The song should continue to play</dd> + <dt>Disable System Settings value "Show Messages on Greeter"</dt> + <dt>Ensure the sound menu has song meta data</dt> + <dd>There should be an entry in the sound menu with the meta data for the song being played</dd> + <dt>Go to the greeter. This can be done by hitting the lock button twice.</dt> + <dt>Ensure the sound menu does not have song meta data</dt> + <dd>There should be an entry for the player but it should have no information on the song being played</dd> + <dt>Pause the song in the greeter</dt> + <dd>The song should stop playing</dd> + <dt>Resume the song in the greeter</dt> + <dd>The song should continue to play</dd> +</dl> |