Merge lp:~xavi-garcia-mena/indicator-sound/bluetooth-icons-bug-1415480 into lp:indicator-sound/15.10
- bluetooth-icons-bug-1415480
- Merge into trunk.15.10
Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Charles Kerr | ||||||||||||||||
Approved revision: | 510 | ||||||||||||||||
Merged at revision: | 508 | ||||||||||||||||
Proposed branch: | lp:~xavi-garcia-mena/indicator-sound/bluetooth-icons-bug-1415480 | ||||||||||||||||
Merge into: | lp:indicator-sound/15.10 | ||||||||||||||||
Diff against target: |
614 lines (+437/-40) 6 files modified
src/CMakeLists.txt (+1/-0) src/service.vala (+329/-27) src/sound-menu.vala (+23/-0) src/volume-control-pulse.vala (+69/-12) src/volume-control.vala (+14/-0) tests/notifications-test.cc (+1/-1) |
||||||||||||||||
To merge this branch: | bzr merge lp:~xavi-garcia-mena/indicator-sound/bluetooth-icons-bug-1415480 | ||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+272735@code.launchpad.net |
Commit message
Added the code to change the icons and label when a bluetooth headset is connected
Description of the change
Added the code to change the icons and label when a bluetooth headset is connected
PS Jenkins bot (ps-jenkins) wrote : | # |
Charles Kerr (charlesk) wrote : | # |
So many possible states!
Writing coverage test for this will be fun... :-)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:507
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 508. By Xavi Garcia
-
Updated to show a label stating the active output
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:508
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 509. By Xavi Garcia
-
Added USB and HDMI active outputs
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:509
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 510. By Xavi Garcia
-
fixed panel root panel icons
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:510
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Charles Kerr (charlesk) : | # |
Sebastien Bacher (seb128) wrote : | # |
that seems to have broken unity7 notifications (when scrolling over the indicator)
Xavi Garcia (xavi-garcia-mena) wrote : | # |
As discussed with Lars Uebernickel, a fix for unity7 is ready to go.
This branch adds a new string to the notification.
Preview Diff
1 | === modified file 'src/CMakeLists.txt' |
2 | --- src/CMakeLists.txt 2015-02-19 16:23:01 +0000 |
3 | +++ src/CMakeLists.txt 2015-10-05 12:20:39 +0000 |
4 | @@ -103,6 +103,7 @@ |
5 | sound-menu.vala |
6 | DEPENDS |
7 | media-player |
8 | + volume-control |
9 | ) |
10 | vala_add(indicator-sound-service |
11 | accounts-service-user.vala |
12 | |
13 | === modified file 'src/service.vala' |
14 | --- src/service.vala 2015-08-27 11:42:21 +0000 |
15 | +++ src/service.vala 2015-10-05 12:20:39 +0000 |
16 | @@ -52,6 +52,8 @@ |
17 | this.notify["visible"].connect ( () => this.update_root_icon () ); |
18 | |
19 | this.volume_control = volume; |
20 | + this.volume_control.active_output_changed.connect (this.update_root_icon); |
21 | + this.volume_control.active_output_changed.connect (this.update_notification); |
22 | |
23 | this.accounts_service = accounts; |
24 | /* If we're on the greeter, don't export */ |
25 | @@ -90,6 +92,10 @@ |
26 | this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE); |
27 | }); |
28 | |
29 | + this.menus.@foreach ( (profile, menu) => { |
30 | + this.volume_control.active_output_changed.connect (menu.update_volume_slider); |
31 | + }); |
32 | + |
33 | this.sync_preferred_players (); |
34 | this.settings.changed["interested-media-players"].connect ( () => { |
35 | this.sync_preferred_players (); |
36 | @@ -245,17 +251,7 @@ |
37 | |
38 | void update_root_icon () { |
39 | double volume = this.volume_control.volume.volume; |
40 | - string icon; |
41 | - if (this.volume_control.mute || volume <= 0.0) |
42 | - icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
43 | - else if (this.accounts_service != null && this.accounts_service.silentMode) |
44 | - icon = "audio-volume-muted-panel"; |
45 | - else if (volume <= 0.3) |
46 | - icon = "audio-volume-low-panel"; |
47 | - else if (volume <= 0.7) |
48 | - icon = "audio-volume-medium-panel"; |
49 | - else |
50 | - icon = "audio-volume-high-panel"; |
51 | + string icon = get_volume_root_icon (volume, this.volume_control.mute, volume_control.active_output); |
52 | |
53 | string accessible_name; |
54 | if (this.volume_control.mute) { |
55 | @@ -282,6 +278,292 @@ |
56 | private bool notify_server_supports_sync = false; |
57 | private bool block_info_notifications = false; |
58 | |
59 | + private string get_volume_icon (double volume, VolumeControl.ActiveOutput active_output) |
60 | + { |
61 | + string icon = ""; |
62 | + switch (active_output) |
63 | + { |
64 | + case VolumeControl.ActiveOutput.SPEAKERS: |
65 | + if (volume <= 0.0) |
66 | + icon = "audio-volume-muted"; |
67 | + else if (volume <= 0.3) |
68 | + icon = "audio-volume-low"; |
69 | + else if (volume <= 0.7) |
70 | + icon = "audio-volume-medium"; |
71 | + else |
72 | + icon = "audio-volume-high"; |
73 | + break; |
74 | + case VolumeControl.ActiveOutput.HEADPHONES: |
75 | + if (volume <= 0.0) |
76 | + icon = "audio-volume-muted"; |
77 | + else if (volume <= 0.3) |
78 | + icon = "audio-volume-low"; |
79 | + else if (volume <= 0.7) |
80 | + icon = "audio-volume-medium"; |
81 | + else |
82 | + icon = "audio-volume-high"; |
83 | + break; |
84 | + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: |
85 | + if (volume <= 0.0) |
86 | + icon = "audio-volume-muted"; |
87 | + else if (volume <= 0.3) |
88 | + icon = "audio-volume-low"; |
89 | + else if (volume <= 0.7) |
90 | + icon = "audio-volume-medium"; |
91 | + else |
92 | + icon = "audio-volume-high"; |
93 | + break; |
94 | + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: |
95 | + if (volume <= 0.0) |
96 | + icon = "audio-volume-muted"; |
97 | + else if (volume <= 0.3) |
98 | + icon = "audio-volume-low"; |
99 | + else if (volume <= 0.7) |
100 | + icon = "audio-volume-medium"; |
101 | + else |
102 | + icon = "audio-volume-high"; |
103 | + break; |
104 | + case VolumeControl.ActiveOutput.USB_SPEAKER: |
105 | + if (volume <= 0.0) |
106 | + icon = "audio-volume-muted"; |
107 | + else if (volume <= 0.3) |
108 | + icon = "audio-volume-low"; |
109 | + else if (volume <= 0.7) |
110 | + icon = "audio-volume-medium"; |
111 | + else |
112 | + icon = "audio-volume-high"; |
113 | + break; |
114 | + case VolumeControl.ActiveOutput.USB_HEADPHONES: |
115 | + if (volume <= 0.0) |
116 | + icon = "audio-volume-muted"; |
117 | + else if (volume <= 0.3) |
118 | + icon = "audio-volume-low"; |
119 | + else if (volume <= 0.7) |
120 | + icon = "audio-volume-medium"; |
121 | + else |
122 | + icon = "audio-volume-high"; |
123 | + break; |
124 | + case VolumeControl.ActiveOutput.HDMI_SPEAKER: |
125 | + if (volume <= 0.0) |
126 | + icon = "audio-volume-muted"; |
127 | + else if (volume <= 0.3) |
128 | + icon = "audio-volume-low"; |
129 | + else if (volume <= 0.7) |
130 | + icon = "audio-volume-medium"; |
131 | + else |
132 | + icon = "audio-volume-high"; |
133 | + break; |
134 | + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: |
135 | + if (volume <= 0.0) |
136 | + icon = "audio-volume-muted"; |
137 | + else if (volume <= 0.3) |
138 | + icon = "audio-volume-low"; |
139 | + else if (volume <= 0.7) |
140 | + icon = "audio-volume-medium"; |
141 | + else |
142 | + icon = "audio-volume-high"; |
143 | + break; |
144 | + } |
145 | + return icon; |
146 | + } |
147 | + |
148 | + private string get_volume_root_icon_by_volume (double volume, VolumeControl.ActiveOutput active_output) |
149 | + { |
150 | + string icon = ""; |
151 | + switch (active_output) |
152 | + { |
153 | + case VolumeControl.ActiveOutput.SPEAKERS: |
154 | + if (volume <= 0.0) |
155 | + icon = "audio-volume-muted-panel"; |
156 | + else if (volume <= 0.3) |
157 | + icon = "audio-volume-low-panel"; |
158 | + else if (volume <= 0.7) |
159 | + icon = "audio-volume-medium-panel"; |
160 | + else |
161 | + icon = "audio-volume-high-panel"; |
162 | + break; |
163 | + case VolumeControl.ActiveOutput.HEADPHONES: |
164 | + if (volume <= 0.0) |
165 | + icon = "audio-volume-muted-panel"; |
166 | + else if (volume <= 0.3) |
167 | + icon = "audio-volume-low-panel"; |
168 | + else if (volume <= 0.7) |
169 | + icon = "audio-volume-medium-panel"; |
170 | + else |
171 | + icon = "audio-volume-high-panel"; |
172 | + break; |
173 | + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: |
174 | + if (volume <= 0.0) |
175 | + icon = "audio-volume-muted-panel"; |
176 | + else if (volume <= 0.3) |
177 | + icon = "audio-volume-low-panel"; |
178 | + else if (volume <= 0.7) |
179 | + icon = "audio-volume-medium-panel"; |
180 | + else |
181 | + icon = "audio-volume-high-panel"; |
182 | + break; |
183 | + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: |
184 | + if (volume <= 0.0) |
185 | + icon = "audio-volume-muted-panel"; |
186 | + else if (volume <= 0.3) |
187 | + icon = "audio-volume-low-panel"; |
188 | + else if (volume <= 0.7) |
189 | + icon = "audio-volume-medium-panel"; |
190 | + else |
191 | + icon = "audio-volume-high-panel"; |
192 | + break; |
193 | + case VolumeControl.ActiveOutput.USB_SPEAKER: |
194 | + if (volume <= 0.0) |
195 | + icon = "audio-volume-muted-panel"; |
196 | + else if (volume <= 0.3) |
197 | + icon = "audio-volume-low-panel"; |
198 | + else if (volume <= 0.7) |
199 | + icon = "audio-volume-medium-panel"; |
200 | + else |
201 | + icon = "audio-volume-high-panel"; |
202 | + break; |
203 | + case VolumeControl.ActiveOutput.USB_HEADPHONES: |
204 | + if (volume <= 0.0) |
205 | + icon = "audio-volume-muted-panel"; |
206 | + else if (volume <= 0.3) |
207 | + icon = "audio-volume-low-panel"; |
208 | + else if (volume <= 0.7) |
209 | + icon = "audio-volume-medium-panel"; |
210 | + else |
211 | + icon = "audio-volume-high-panel"; |
212 | + break; |
213 | + case VolumeControl.ActiveOutput.HDMI_SPEAKER: |
214 | + if (volume <= 0.0) |
215 | + icon = "audio-volume-muted-panel"; |
216 | + else if (volume <= 0.3) |
217 | + icon = "audio-volume-low-panel"; |
218 | + else if (volume <= 0.7) |
219 | + icon = "audio-volume-medium-panel"; |
220 | + else |
221 | + icon = "audio-volume-high-panel"; |
222 | + break; |
223 | + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: |
224 | + if (volume <= 0.0) |
225 | + icon = "audio-volume-muted-panel"; |
226 | + else if (volume <= 0.3) |
227 | + icon = "audio-volume-low-panel"; |
228 | + else if (volume <= 0.7) |
229 | + icon = "audio-volume-medium-panel"; |
230 | + else |
231 | + icon = "audio-volume-high-panel"; |
232 | + break; |
233 | + } |
234 | + return icon; |
235 | + } |
236 | + |
237 | + private string get_volume_notification_icon (double volume, bool loud, VolumeControl.ActiveOutput active_output) { |
238 | + string icon = ""; |
239 | + if (loud) { |
240 | + switch (active_output) |
241 | + { |
242 | + case VolumeControl.ActiveOutput.SPEAKERS: |
243 | + icon = "audio-volume-high"; |
244 | + break; |
245 | + case VolumeControl.ActiveOutput.HEADPHONES: |
246 | + icon = "audio-volume-high"; |
247 | + break; |
248 | + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: |
249 | + icon = "audio-volume-high"; |
250 | + break; |
251 | + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: |
252 | + icon = "audio-volume-high"; |
253 | + break; |
254 | + case VolumeControl.ActiveOutput.USB_SPEAKER: |
255 | + icon = "audio-volume-high"; |
256 | + break; |
257 | + case VolumeControl.ActiveOutput.USB_HEADPHONES: |
258 | + icon = "audio-volume-high"; |
259 | + break; |
260 | + case VolumeControl.ActiveOutput.HDMI_SPEAKER: |
261 | + icon = "audio-volume-high"; |
262 | + break; |
263 | + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: |
264 | + icon = "audio-volume-high"; |
265 | + break; |
266 | + } |
267 | + } else { |
268 | + icon = get_volume_icon (volume, active_output); |
269 | + } |
270 | + return icon; |
271 | + } |
272 | + |
273 | + private string get_volume_root_icon (double volume, bool mute, VolumeControl.ActiveOutput active_output) { |
274 | + string icon = ""; |
275 | + switch (active_output) |
276 | + { |
277 | + case VolumeControl.ActiveOutput.SPEAKERS: |
278 | + if (mute || volume <= 0.0) |
279 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
280 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
281 | + icon = "audio-volume-muted-panel"; |
282 | + else |
283 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
284 | + break; |
285 | + case VolumeControl.ActiveOutput.HEADPHONES: |
286 | + if (mute || volume <= 0.0) |
287 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
288 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
289 | + icon = "audio-volume-muted-panel"; |
290 | + else |
291 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
292 | + break; |
293 | + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: |
294 | + if (mute || volume <= 0.0) |
295 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
296 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
297 | + icon = "audio-volume-muted-panel"; |
298 | + else |
299 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
300 | + break; |
301 | + case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER: |
302 | + if (mute || volume <= 0.0) |
303 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
304 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
305 | + icon = "audio-volume-muted-panel"; |
306 | + else |
307 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
308 | + break; |
309 | + case VolumeControl.ActiveOutput.USB_SPEAKER: |
310 | + if (mute || volume <= 0.0) |
311 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
312 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
313 | + icon = "audio-volume-muted-panel"; |
314 | + else |
315 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
316 | + break; |
317 | + case VolumeControl.ActiveOutput.USB_HEADPHONES: |
318 | + if (mute || volume <= 0.0) |
319 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
320 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
321 | + icon = "audio-volume-muted-panel"; |
322 | + else |
323 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
324 | + break; |
325 | + case VolumeControl.ActiveOutput.HDMI_SPEAKER: |
326 | + if (mute || volume <= 0.0) |
327 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
328 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
329 | + icon = "audio-volume-muted-panel"; |
330 | + else |
331 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
332 | + break; |
333 | + case VolumeControl.ActiveOutput.HDMI_HEADPHONES: |
334 | + if (mute || volume <= 0.0) |
335 | + icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; |
336 | + else if (this.accounts_service != null && this.accounts_service.silentMode) |
337 | + icon = "audio-volume-muted-panel"; |
338 | + else |
339 | + icon = get_volume_root_icon_by_volume (volume, active_output); |
340 | + break; |
341 | + } |
342 | + return icon; |
343 | + } |
344 | + |
345 | private void update_notification () { |
346 | |
347 | if (!notify_server_caps_checked) { |
348 | @@ -323,26 +605,46 @@ |
349 | if (notify_server_supports_sync && !block_info_notifications) { |
350 | |
351 | /* Determine Label */ |
352 | - unowned string volume_label = loud |
353 | + string volume_label = loud |
354 | ? _("High volume can damage your hearing.") |
355 | : ""; |
356 | + |
357 | + if (volume_label == "") { |
358 | + if (volume_control.active_output == VolumeControl.ActiveOutput.SPEAKERS) { |
359 | + volume_label = _("Speakers"); |
360 | + } |
361 | + |
362 | + if (volume_control.active_output == VolumeControl.ActiveOutput.HEADPHONES) { |
363 | + volume_label = _("Headphones"); |
364 | + } |
365 | + |
366 | + if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES) { |
367 | + volume_label = _("Bluetooth headphones"); |
368 | + } |
369 | + |
370 | + if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER) { |
371 | + volume_label = _("Bluetooth speaker"); |
372 | + } |
373 | + |
374 | + if (volume_control.active_output == VolumeControl.ActiveOutput.USB_SPEAKER) { |
375 | + volume_label = _("Usb speaker"); |
376 | + } |
377 | + |
378 | + if (volume_control.active_output == VolumeControl.ActiveOutput.USB_HEADPHONES) { |
379 | + volume_label = _("Usb headphones"); |
380 | + } |
381 | + |
382 | + if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_SPEAKER) { |
383 | + volume_label = _("HDMI speaker"); |
384 | + } |
385 | + |
386 | + if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_HEADPHONES) { |
387 | + volume_label = _("HDMI headphones"); |
388 | + } |
389 | + } |
390 | |
391 | /* Choose an icon */ |
392 | - unowned string icon; |
393 | - if (loud) { |
394 | - icon = "audio-volume-high"; |
395 | - } else { |
396 | - var volume = volume_control.volume.volume; |
397 | - |
398 | - if (volume <= 0.0) |
399 | - icon = "audio-volume-muted"; |
400 | - else if (volume <= 0.3) |
401 | - icon = "audio-volume-low"; |
402 | - else if (volume <= 0.7) |
403 | - icon = "audio-volume-medium"; |
404 | - else |
405 | - icon = "audio-volume-high"; |
406 | - } |
407 | + string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output); |
408 | |
409 | /* Reset the notification */ |
410 | var n = this.info_notification; |
411 | |
412 | === modified file 'src/sound-menu.vala' |
413 | --- src/sound-menu.vala 2015-02-12 00:44:34 +0000 |
414 | +++ src/sound-menu.vala 2015-10-05 12:20:39 +0000 |
415 | @@ -71,6 +71,7 @@ |
416 | this.notify_handlers = new HashTable<MediaPlayer, ulong> (direct_hash, direct_equal); |
417 | |
418 | this.greeter_players = (flags & DisplayFlags.GREETER_PLAYERS) != 0; |
419 | + |
420 | } |
421 | |
422 | ~SoundMenu () { |
423 | @@ -185,6 +186,28 @@ |
424 | this.notify_handlers.remove (player); |
425 | } |
426 | |
427 | + public void update_volume_slider (VolumeControl.ActiveOutput active_output) { |
428 | + int index = find_action (this.volume_section, "indicator.volume"); |
429 | + if (index != -1) { |
430 | + string label = "Volume"; |
431 | + switch (active_output) { |
432 | + case VolumeControl.ActiveOutput.SPEAKERS: |
433 | + label = "Volume"; |
434 | + break; |
435 | + case VolumeControl.ActiveOutput.HEADPHONES: |
436 | + label = "Volume (Headphones)"; |
437 | + break; |
438 | + case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES: |
439 | + label = "Volume (Bluetooth)"; |
440 | + break; |
441 | + } |
442 | + this.volume_section.remove (index); |
443 | + this.volume_section.insert_item (index, this.create_slider_menu_item (_(label), "indicator.volume(0)", 0.0, 1.0, 0.01, |
444 | + "audio-volume-low-zero-panel", |
445 | + "audio-volume-high-panel")); |
446 | + } |
447 | + } |
448 | + |
449 | public Menu root; |
450 | public Menu menu; |
451 | Menu volume_section; |
452 | |
453 | === modified file 'src/volume-control-pulse.vala' |
454 | --- src/volume-control-pulse.vala 2015-08-12 18:16:40 +0000 |
455 | +++ src/volume-control-pulse.vala 2015-10-05 12:20:39 +0000 |
456 | @@ -87,6 +87,7 @@ |
457 | private bool _send_next_local_volume = false; |
458 | private double _account_service_volume = 0.0; |
459 | private bool _active_port_headphone = false; |
460 | + private VolumeControl.ActiveOutput _active_output = VolumeControl.ActiveOutput.SPEAKERS; |
461 | |
462 | /** true when connected to the pulse server */ |
463 | public override bool ready { get; private set; } |
464 | @@ -135,6 +136,52 @@ |
465 | stop_high_volume_approved_timer(); |
466 | } |
467 | |
468 | + private VolumeControl.ActiveOutput calculate_active_output (SinkInfo? sink) { |
469 | + |
470 | + VolumeControl.ActiveOutput ret_output = VolumeControl.ActiveOutput.SPEAKERS; |
471 | + /* Check if the current active port is headset/headphone */ |
472 | + /* There is not easy way to check if the port is a headset/headphone besides |
473 | + * checking for the port name. On touch (with the pulseaudio droid element) |
474 | + * the headset/headphone port is called 'output-headset' and 'output-headphone'. |
475 | + * On the desktop this is usually called 'analog-output-headphones' */ |
476 | + if (sink.active_port != null) { |
477 | + // look if it's a headset/headphones |
478 | + if (sink.active_port.name.contains("headset") || |
479 | + sink.active_port.name.contains("headphone")) { |
480 | + _active_port_headphone = true; |
481 | + // check if it's a bluetooth device |
482 | + var device_bus = sink.proplist.gets ("device.bus"); |
483 | + if (device_bus != null && device_bus == "bluetooth") { |
484 | + ret_output = VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES; |
485 | + } else if (device_bus != null && device_bus == "usb") { |
486 | + ret_output = VolumeControl.ActiveOutput.USB_HEADPHONES; |
487 | + } else if (device_bus != null && device_bus == "hdmi") { |
488 | + ret_output = VolumeControl.ActiveOutput.HDMI_HEADPHONES; |
489 | + } else { |
490 | + ret_output = VolumeControl.ActiveOutput.HEADPHONES; |
491 | + } |
492 | + } else { |
493 | + // speaker |
494 | + _active_port_headphone = false; |
495 | + var device_bus = sink.proplist.gets ("device.bus"); |
496 | + if (device_bus != null && device_bus == "bluetooth") { |
497 | + ret_output = VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER; |
498 | + } else if (device_bus != null && device_bus == "usb") { |
499 | + ret_output = VolumeControl.ActiveOutput.USB_SPEAKER; |
500 | + } else if (device_bus != null && device_bus == "hdmi") { |
501 | + ret_output = VolumeControl.ActiveOutput.HDMI_SPEAKER; |
502 | + } else { |
503 | + ret_output = VolumeControl.ActiveOutput.SPEAKERS; |
504 | + } |
505 | + } |
506 | + } else { |
507 | + _active_port_headphone = false; |
508 | + ret_output = VolumeControl.ActiveOutput.SPEAKERS; |
509 | + } |
510 | + |
511 | + return ret_output; |
512 | + } |
513 | + |
514 | /* PulseAudio logic*/ |
515 | private void context_events_cb (Context c, Context.SubscriptionEventType t, uint32 index) |
516 | { |
517 | @@ -201,18 +248,20 @@ |
518 | this.notify_property ("is-playing"); |
519 | } |
520 | |
521 | - /* Check if the current active port is headset/headphone */ |
522 | - /* There is not easy way to check if the port is a headset/headphone besides |
523 | - * checking for the port name. On touch (with the pulseaudio droid element) |
524 | - * the headset/headphone port is called 'output-headset' and 'output-headphone'. |
525 | - * On the desktop this is usually called 'analog-output-headphones' */ |
526 | - if (i.active_port != null && |
527 | - (i.active_port.name == "output-wired_headset" || |
528 | - i.active_port.name == "output-wired_headphone" || |
529 | - i.active_port.name == "analog-output-headphones")) { |
530 | - _active_port_headphone = true; |
531 | - } else { |
532 | - _active_port_headphone = false; |
533 | + // store the current status of the active output |
534 | + VolumeControl.ActiveOutput active_output_before = active_output; |
535 | + |
536 | + // calculate the output |
537 | + _active_output = calculate_active_output (i); |
538 | + |
539 | + // check if the output has changed, if so... emit a signal |
540 | + VolumeControl.ActiveOutput active_output_now = active_output; |
541 | + if (active_output_now != active_output_before) { |
542 | + this.active_output_changed (active_output_now); |
543 | + if (active_output_now == VolumeControl.ActiveOutput.SPEAKERS) { |
544 | + _high_volume_approved = false; |
545 | + } |
546 | + update_high_volume(); |
547 | } |
548 | |
549 | if (_pulse_use_stream_restore == false && |
550 | @@ -535,6 +584,14 @@ |
551 | } |
552 | } |
553 | |
554 | + public override VolumeControl.ActiveOutput active_output |
555 | + { |
556 | + get |
557 | + { |
558 | + return _active_output; |
559 | + } |
560 | + } |
561 | + |
562 | /* Volume operations */ |
563 | private static PulseAudio.Volume double_to_volume (double vol) |
564 | { |
565 | |
566 | === modified file 'src/volume-control.vala' |
567 | --- src/volume-control.vala 2015-08-12 14:00:56 +0000 |
568 | +++ src/volume-control.vala 2015-10-05 12:20:39 +0000 |
569 | @@ -28,6 +28,17 @@ |
570 | VOLUME_STREAM_CHANGE |
571 | } |
572 | |
573 | + public enum ActiveOutput { |
574 | + SPEAKERS, |
575 | + HEADPHONES, |
576 | + BLUETOOTH_HEADPHONES, |
577 | + BLUETOOTH_SPEAKER, |
578 | + USB_SPEAKER, |
579 | + USB_HEADPHONES, |
580 | + HDMI_SPEAKER, |
581 | + HDMI_HEADPHONES |
582 | + } |
583 | + |
584 | public class Volume : Object { |
585 | public double volume; |
586 | public VolumeReasons reason; |
587 | @@ -39,6 +50,7 @@ |
588 | public virtual bool high_volume { get { return false; } protected set { } } |
589 | public virtual bool mute { get { return false; } } |
590 | public virtual bool is_playing { get { return false; } } |
591 | + public virtual VolumeControl.ActiveOutput active_output { get { return VolumeControl.ActiveOutput.SPEAKERS; } } |
592 | private Volume _volume; |
593 | public virtual Volume volume { get { return _volume; } set { } } |
594 | public virtual double mic_volume { get { return 0.0; } set { } } |
595 | @@ -56,4 +68,6 @@ |
596 | v.reason = reason; |
597 | this.volume = v; |
598 | } |
599 | + |
600 | + public signal void active_output_changed (VolumeControl.ActiveOutput active_output); |
601 | } |
602 | |
603 | === modified file 'tests/notifications-test.cc' |
604 | --- tests/notifications-test.cc 2015-08-11 22:19:36 +0000 |
605 | +++ tests/notifications-test.cc 2015-10-05 12:20:39 +0000 |
606 | @@ -345,7 +345,7 @@ |
607 | auto notev = notifications->getNotifications(); |
608 | ASSERT_EQ(1, notev.size()); |
609 | EXPECT_EQ("Volume", notev[0].summary); |
610 | - EXPECT_EQ("", notev[0].body); |
611 | + EXPECT_EQ("Speakers", notev[0].body); |
612 | EXPECT_GVARIANT_EQ("@s 'false'", notev[0].hints["x-canonical-value-bar-tint"]); |
613 | |
614 | /* Set high volume with volume change */ |
PASSED: Continuous integration, rev:506 jenkins. qa.ubuntu. com/job/ indicator- sound-ci/ 257/ jenkins. qa.ubuntu. com/job/ indicator- sound-wily- amd64-ci/ 33 jenkins. qa.ubuntu. com/job/ indicator- sound-wily- armhf-ci/ 33 jenkins. qa.ubuntu. com/job/ indicator- sound-wily- armhf-ci/ 33/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/indicator- sound-ci/ 257/rebuild
http://