Merge lp:~cjcurran/indicator-sound/unify-device-handling-patterns into lp:~indicator-applet-developers/indicator-sound/trunk_3
- unify-device-handling-patterns
- Merge into trunk_3
Proposed by
Conor Curran
Status: | Merged |
---|---|
Approved by: | Ted Gould |
Approved revision: | 224 |
Merged at revision: | 222 |
Proposed branch: | lp:~cjcurran/indicator-sound/unify-device-handling-patterns |
Merge into: | lp:~indicator-applet-developers/indicator-sound/trunk_3 |
Diff against target: |
1108 lines (+288/-255) 10 files modified
src/Makefile.am (+2/-2) src/device.c (+80/-139) src/device.h (+32/-33) src/pulseaudio-mgr.c (+43/-43) src/pulseaudio-mgr.h (+2/-2) src/slider-menu-item.c (+110/-21) src/slider-menu-item.h (+10/-4) src/sound-service-dbus.c (+5/-5) src/voip-input-menu-item.c (+2/-4) src/voip-input-menu-item.h (+2/-2) |
To merge this branch: | bzr merge lp:~cjcurran/indicator-sound/unify-device-handling-patterns |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email: mp+53315@code.launchpad.net |
Commit message
Description of the change
This is essentially a renaming refactor that was needed on the service side. Every since the voip item was introduced the existing pattern within the pulsemanager of assuming its userdata object was some sort of sink representative became untrue. The userdata mgr is simply just now a wrapper for which the pulsemanager uses to communicate with to menu. It is now called simply 'Device'
Furthermore all state should be stored in the respective widgets. Therefore there is no need for Device to calculate volumes etc.
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Makefile.am' |
2 | --- src/Makefile.am 2011-02-17 16:07:28 +0000 |
3 | +++ src/Makefile.am 2011-03-14 20:12:00 +0000 |
4 | @@ -92,8 +92,8 @@ |
5 | sound-service.c \ |
6 | pulseaudio-mgr.h \ |
7 | pulseaudio-mgr.c \ |
8 | - active-sink.c \ |
9 | - active-sink.h \ |
10 | + device.c \ |
11 | + device.h \ |
12 | sound-service-dbus.h \ |
13 | sound-service-dbus.c \ |
14 | slider-menu-item.h \ |
15 | |
16 | === renamed file 'src/active-sink.c' => 'src/device.c' |
17 | --- src/active-sink.c 2011-02-18 17:11:08 +0000 |
18 | +++ src/device.c 2011-03-14 20:12:00 +0000 |
19 | @@ -18,64 +18,55 @@ |
20 | */ |
21 | #include <libdbusmenu-glib/menuitem.h> |
22 | |
23 | -#include "active-sink.h" |
24 | +#include "device.h" |
25 | #include "slider-menu-item.h" |
26 | #include "mute-menu-item.h" |
27 | #include "voip-input-menu-item.h" |
28 | #include "pulseaudio-mgr.h" |
29 | |
30 | -typedef struct _ActiveSinkPrivate ActiveSinkPrivate; |
31 | +typedef struct _DevicePrivate DevicePrivate; |
32 | |
33 | -struct _ActiveSinkPrivate |
34 | +struct _DevicePrivate |
35 | { |
36 | SliderMenuItem* volume_slider_menuitem; |
37 | MuteMenuItem* mute_menuitem; |
38 | VoipInputMenuItem* voip_input_menu_item; |
39 | SoundState current_sound_state; |
40 | SoundServiceDbus* service; |
41 | - gint index; |
42 | - gchar* name; |
43 | - pa_cvolume volume; |
44 | - pa_channel_map channel_map; |
45 | - pa_volume_t base_volume; |
46 | }; |
47 | |
48 | -#define ACTIVE_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ACTIVE_SINK_TYPE, ActiveSinkPrivate)) |
49 | +#define DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEVICE_TYPE, DevicePrivate)) |
50 | |
51 | /* Prototypes */ |
52 | -static void active_sink_class_init (ActiveSinkClass *klass); |
53 | -static void active_sink_init (ActiveSink *self); |
54 | -static void active_sink_dispose (GObject *object); |
55 | -static void active_sink_finalize (GObject *object); |
56 | - |
57 | -static SoundState active_sink_get_state_from_volume (ActiveSink* self); |
58 | -static pa_cvolume active_sink_construct_mono_volume (const pa_cvolume* vol); |
59 | -static void active_sink_volume_update (ActiveSink* self, gdouble percent); |
60 | -static void active_sink_mute_update (ActiveSink* self, gboolean muted); |
61 | - |
62 | -G_DEFINE_TYPE (ActiveSink, active_sink, G_TYPE_OBJECT); |
63 | +static void device_class_init (DeviceClass *klass); |
64 | +static void device_init (Device *self); |
65 | +static void device_dispose (GObject *object); |
66 | +static void device_finalize (GObject *object); |
67 | + |
68 | +static SoundState device_get_state_from_volume (Device* self); |
69 | +static void device_mute_update (Device* self, gboolean muted); |
70 | + |
71 | +G_DEFINE_TYPE (Device, device, G_TYPE_OBJECT); |
72 | |
73 | static void |
74 | -active_sink_class_init (ActiveSinkClass *klass) |
75 | +device_class_init (DeviceClass *klass) |
76 | { |
77 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
78 | |
79 | - g_type_class_add_private (klass, sizeof (ActiveSinkPrivate)); |
80 | + g_type_class_add_private (klass, sizeof (DevicePrivate)); |
81 | |
82 | - gobject_class->dispose = active_sink_dispose; |
83 | - gobject_class->finalize = active_sink_finalize; |
84 | + gobject_class->dispose = device_dispose; |
85 | + gobject_class->finalize = device_finalize; |
86 | } |
87 | |
88 | static void |
89 | -active_sink_init (ActiveSink *self) |
90 | +device_init (Device *self) |
91 | { |
92 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
93 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
94 | priv->mute_menuitem = NULL; |
95 | priv->volume_slider_menuitem = NULL; |
96 | priv->voip_input_menu_item = NULL; |
97 | priv->current_sound_state = UNAVAILABLE; |
98 | - priv->index = -1; |
99 | - priv->name = NULL; |
100 | priv->service = NULL; |
101 | |
102 | // Init our menu items. |
103 | @@ -87,45 +78,38 @@ |
104 | } |
105 | |
106 | static void |
107 | -active_sink_dispose (GObject *object) |
108 | +device_dispose (GObject *object) |
109 | { |
110 | - G_OBJECT_CLASS (active_sink_parent_class)->dispose (object); |
111 | + G_OBJECT_CLASS (device_parent_class)->dispose (object); |
112 | } |
113 | |
114 | static void |
115 | -active_sink_finalize (GObject *object) |
116 | +device_finalize (GObject *object) |
117 | { |
118 | - G_OBJECT_CLASS (active_sink_parent_class)->finalize (object); |
119 | + G_OBJECT_CLASS (device_parent_class)->finalize (object); |
120 | } |
121 | |
122 | void |
123 | -active_sink_populate (ActiveSink* sink, |
124 | +device_populate (Device* self, |
125 | const pa_sink_info* update) |
126 | { |
127 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE(sink); |
128 | - |
129 | - priv->name = g_strdup (update->name); |
130 | - priv->index = update->index; |
131 | - active_sink_mute_update (sink, update->mute); |
132 | - priv->volume = active_sink_construct_mono_volume (&update->volume); |
133 | - priv->base_volume = update->base_volume; |
134 | - priv->channel_map = update->channel_map; |
135 | - |
136 | - pa_volume_t vol = pa_cvolume_max (&update->volume); |
137 | - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; |
138 | - |
139 | - active_sink_volume_update (sink, volume_percent); |
140 | - active_sink_mute_update (sink, update->mute); |
141 | + DevicePrivate* priv = DEVICE_GET_PRIVATE(self); |
142 | + device_mute_update (self, update->mute); |
143 | mute_menu_item_enable (priv->mute_menuitem, TRUE); |
144 | - slider_menu_item_enable (priv->volume_slider_menuitem, TRUE); |
145 | + slider_menu_item_populate (priv->volume_slider_menuitem, update); |
146 | + SoundState state = device_get_state_from_volume (self); |
147 | + if (priv->current_sound_state != state){ |
148 | + priv->current_sound_state = state; |
149 | + sound_service_dbus_update_sound_state (priv->service, |
150 | + priv->current_sound_state); |
151 | + } |
152 | |
153 | - g_debug ("Active sink has been populated - volume %f", volume_percent); |
154 | } |
155 | |
156 | void |
157 | -active_sink_activate_voip_item (ActiveSink* self, gint sink_input_index, gint client_index) |
158 | +device_activate_voip_item (Device* self, gint sink_input_index, gint client_index) |
159 | { |
160 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
161 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
162 | if (voip_input_menu_item_is_interested (priv->voip_input_menu_item, |
163 | sink_input_index, |
164 | client_index)){ |
165 | @@ -134,85 +118,55 @@ |
166 | } |
167 | |
168 | void |
169 | -active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible) |
170 | +device_deactivate_voip_source (Device* self, gboolean visible) |
171 | { |
172 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
173 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
174 | visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item); |
175 | voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible); |
176 | } |
177 | |
178 | void |
179 | -active_sink_deactivate_voip_client (ActiveSink* self) |
180 | +device_deactivate_voip_client (Device* self) |
181 | { |
182 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
183 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
184 | voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item); |
185 | } |
186 | |
187 | void |
188 | -active_sink_update (ActiveSink* sink, |
189 | +device_update (Device* self, |
190 | const pa_sink_info* update) |
191 | { |
192 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); |
193 | - active_sink_mute_update (sink, update->mute); |
194 | - priv->volume = active_sink_construct_mono_volume (&update->volume); |
195 | - priv->base_volume = update->base_volume; |
196 | - priv->channel_map = update->channel_map; |
197 | - |
198 | - pa_volume_t vol = pa_cvolume_max (&update->volume); |
199 | - gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; |
200 | - |
201 | - active_sink_volume_update (sink, volume_percent); |
202 | - active_sink_mute_update (sink, update->mute); |
203 | -} |
204 | - |
205 | -// To the UI |
206 | -static void |
207 | -active_sink_volume_update (ActiveSink* self, gdouble percent) |
208 | -{ |
209 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
210 | - slider_menu_item_update (priv->volume_slider_menuitem, percent); |
211 | - SoundState state = active_sink_get_state_from_volume (self); |
212 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
213 | + slider_menu_item_update (priv->volume_slider_menuitem, update); |
214 | + |
215 | + SoundState state = device_get_state_from_volume (self); |
216 | if (priv->current_sound_state != state){ |
217 | priv->current_sound_state = state; |
218 | sound_service_dbus_update_sound_state (priv->service, |
219 | priv->current_sound_state); |
220 | } |
221 | -} |
222 | - |
223 | -// From the UI |
224 | -void |
225 | -active_sink_update_volume (ActiveSink* self, gdouble percent) |
226 | -{ |
227 | - pa_cvolume new_volume; |
228 | - pa_cvolume_init(&new_volume); |
229 | - new_volume.channels = 1; |
230 | - pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); |
231 | - pa_cvolume_set(&new_volume, 1, new_volume_value); |
232 | - |
233 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
234 | - |
235 | - pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value); |
236 | - pm_update_volume (priv->index, new_volume); |
237 | -} |
238 | - |
239 | + |
240 | + device_mute_update (self, update->mute); |
241 | +} |
242 | |
243 | gint |
244 | -active_sink_get_current_sink_input_index (ActiveSink* sink) |
245 | +device_get_current_sink_input_index (Device* self) |
246 | { |
247 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); |
248 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
249 | return voip_input_menu_item_get_sink_input_index (priv->voip_input_menu_item); |
250 | } |
251 | |
252 | static void |
253 | -active_sink_mute_update (ActiveSink* self, gboolean muted) |
254 | +device_mute_update (Device* self, gboolean muted) |
255 | { |
256 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
257 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
258 | mute_menu_item_update (priv->mute_menuitem, muted); |
259 | - SoundState state = active_sink_get_state_from_volume (self); |
260 | + SoundState state = device_get_state_from_volume (self); |
261 | |
262 | if (muted == TRUE){ |
263 | state = MUTED; |
264 | } |
265 | + // Only send signals if something has changed |
266 | if (priv->current_sound_state != state){ |
267 | priv->current_sound_state = state; |
268 | sound_service_dbus_update_sound_state (priv->service, state); |
269 | @@ -220,9 +174,9 @@ |
270 | } |
271 | |
272 | void |
273 | -active_sink_ensure_sink_is_unmuted (ActiveSink* self) |
274 | +device_ensure_sink_is_unmuted (Device* self) |
275 | { |
276 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
277 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
278 | if (mute_menu_item_is_muted (priv->mute_menuitem)){ |
279 | pm_update_mute (FALSE); |
280 | } |
281 | @@ -230,9 +184,9 @@ |
282 | |
283 | |
284 | static SoundState |
285 | -active_sink_get_state_from_volume (ActiveSink* self) |
286 | +device_get_state_from_volume (Device* self) |
287 | { |
288 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
289 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
290 | GVariant* v = dbusmenu_menuitem_property_get_variant (DBUSMENU_MENUITEM(priv->volume_slider_menuitem), |
291 | DBUSMENU_VOLUME_MENUITEM_LEVEL); |
292 | gdouble volume_percent = g_variant_get_double (v); |
293 | @@ -254,21 +208,10 @@ |
294 | return state; |
295 | } |
296 | |
297 | -pa_cvolume |
298 | -active_sink_construct_mono_volume (const pa_cvolume* vol) |
299 | -{ |
300 | - pa_cvolume new_volume; |
301 | - pa_cvolume_init(&new_volume); |
302 | - new_volume.channels = 1; |
303 | - pa_volume_t max_vol = pa_cvolume_max(vol); |
304 | - pa_cvolume_set(&new_volume, 1, max_vol); |
305 | - return new_volume; |
306 | -} |
307 | - |
308 | void |
309 | -active_sink_determine_blocking_state (ActiveSink* self) |
310 | +device_determine_blocking_state (Device* self) |
311 | { |
312 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
313 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
314 | if (mute_menu_item_is_muted (priv->mute_menuitem)){ |
315 | /** |
316 | We don't want to set the current state to blocking |
317 | @@ -280,65 +223,63 @@ |
318 | } |
319 | |
320 | gint |
321 | -active_sink_get_index (ActiveSink* self) |
322 | +device_get_index (Device* self) |
323 | { |
324 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
325 | - return priv->index; |
326 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
327 | + return slider_menu_item_get_sink_index (priv->volume_slider_menuitem); |
328 | } |
329 | |
330 | gboolean |
331 | -active_sink_is_populated (ActiveSink* sink) |
332 | +device_is_populated (Device* self) |
333 | { |
334 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); |
335 | - return (priv->index != -1); |
336 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
337 | + return dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM (priv->volume_slider_menuitem), |
338 | + DBUSMENU_MENUITEM_PROP_ENABLED); |
339 | } |
340 | |
341 | void |
342 | -active_sink_deactivate (ActiveSink* self) |
343 | +device_deactivate (Device* self) |
344 | { |
345 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
346 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
347 | priv->current_sound_state = UNAVAILABLE; |
348 | sound_service_dbus_update_sound_state (priv->service, |
349 | priv->current_sound_state); |
350 | mute_menu_item_enable (priv->mute_menuitem, FALSE); |
351 | slider_menu_item_enable (priv->volume_slider_menuitem, FALSE); |
352 | - priv->index = -1; |
353 | - g_free(priv->name); |
354 | - priv->name = NULL; |
355 | } |
356 | |
357 | SoundState |
358 | -active_sink_get_state (ActiveSink* self) |
359 | +device_get_state (Device* self) |
360 | { |
361 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
362 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
363 | return priv->current_sound_state; |
364 | } |
365 | |
366 | void |
367 | -active_sink_update_voip_input_source (ActiveSink* self, const pa_source_info* update) |
368 | +device_update_voip_input_source (Device* self, const pa_source_info* update) |
369 | { |
370 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
371 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
372 | voip_input_menu_item_update (priv->voip_input_menu_item, update); |
373 | } |
374 | |
375 | gboolean |
376 | -active_sink_is_voip_source_populated (ActiveSink* self) |
377 | +device_is_voip_source_populated (Device* self) |
378 | { |
379 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
380 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
381 | return voip_input_menu_item_is_populated (priv->voip_input_menu_item); |
382 | } |
383 | |
384 | -gint active_sink_get_source_index (ActiveSink* self) |
385 | +gint device_get_source_index (Device* self) |
386 | { |
387 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (self); |
388 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (self); |
389 | return voip_input_menu_item_get_index (priv->voip_input_menu_item); |
390 | } |
391 | |
392 | -ActiveSink* |
393 | -active_sink_new (SoundServiceDbus* service) |
394 | +Device* |
395 | +device_new (SoundServiceDbus* service) |
396 | { |
397 | - ActiveSink* sink = g_object_new (ACTIVE_SINK_TYPE, NULL); |
398 | - ActiveSinkPrivate* priv = ACTIVE_SINK_GET_PRIVATE (sink); |
399 | + Device* sink = g_object_new (DEVICE_TYPE, NULL); |
400 | + DevicePrivate* priv = DEVICE_GET_PRIVATE (sink); |
401 | priv->service = service; |
402 | sound_service_dbus_build_sound_menu (service, |
403 | mute_menu_item_get_button (priv->mute_menuitem), |
404 | |
405 | === renamed file 'src/active-sink.h' => 'src/device.h' |
406 | --- src/active-sink.h 2011-02-18 16:56:17 +0000 |
407 | +++ src/device.h 2011-03-14 20:12:00 +0000 |
408 | @@ -17,8 +17,8 @@ |
409 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
410 | */ |
411 | |
412 | -#ifndef __ACTIVE_SINK_H__ |
413 | -#define __ACTIVE_SINK_H__ |
414 | +#ifndef __DEVICE_H__ |
415 | +#define __DEVICE_H__ |
416 | |
417 | #include <glib.h> |
418 | #include <glib-object.h> |
419 | @@ -30,25 +30,25 @@ |
420 | |
421 | G_BEGIN_DECLS |
422 | |
423 | -#define ACTIVE_SINK_TYPE (active_sink_get_type ()) |
424 | -#define ACTIVE_SINK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ACTIVE_SINK_TYPE, ActiveSink)) |
425 | -#define ACTIVE_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), ACTIVE_SINK_TYPE, ActiveSinkClass)) |
426 | -#define IS_ACTIVE_SINK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ACTIVE_SINK_TYPE)) |
427 | -#define IS_ACTIVE_SINK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ACTIVE_SINK_TYPE)) |
428 | -#define ACTIVE_SINK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ACTIVE_SINK_TYPE, ActiveSinkClass)) |
429 | - |
430 | -typedef struct _ActiveSink ActiveSink; |
431 | -typedef struct _ActiveSinkClass ActiveSinkClass; |
432 | - |
433 | -struct _ActiveSink { |
434 | +#define DEVICE_TYPE (device_get_type ()) |
435 | +#define DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DEVICE_TYPE, Device)) |
436 | +#define DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DEVICE_TYPE, DeviceClass)) |
437 | +#define IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DEVICE_TYPE)) |
438 | +#define IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DEVICE_TYPE)) |
439 | +#define DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DEVICE_TYPE, DeviceClass)) |
440 | + |
441 | +typedef struct _Device Device; |
442 | +typedef struct _DeviceClass DeviceClass; |
443 | + |
444 | +struct _Device { |
445 | GObject parent; |
446 | }; |
447 | |
448 | -struct _ActiveSinkClass { |
449 | +struct _DeviceClass { |
450 | GObjectClass parent_class; |
451 | }; |
452 | |
453 | -GType active_sink_get_type (void) G_GNUC_CONST; |
454 | +GType device_get_type (void) G_GNUC_CONST; |
455 | |
456 | /** |
457 | * TODO |
458 | @@ -58,27 +58,26 @@ |
459 | */ |
460 | |
461 | // Sink related |
462 | -void active_sink_populate (ActiveSink* sink, const pa_sink_info* update); |
463 | -void active_sink_update (ActiveSink* sink, const pa_sink_info* update); |
464 | -gboolean active_sink_is_populated (ActiveSink* sink); |
465 | -gint active_sink_get_index (ActiveSink* self); |
466 | -void active_sink_deactivate (ActiveSink* self); |
467 | -void active_sink_update_mute (ActiveSink* self, gboolean mute_update); |
468 | -void active_sink_update_volume (ActiveSink* self, gdouble percent); |
469 | -void active_sink_ensure_sink_is_unmuted (ActiveSink* self); |
470 | +void device_populate (Device* sink, const pa_sink_info* update); |
471 | +void device_update (Device* sink, const pa_sink_info* update); |
472 | +gboolean device_is_populated (Device* sink); |
473 | +gint device_get_index (Device* self); |
474 | +void device_deactivate (Device* self); |
475 | +void device_update_mute (Device* self, gboolean mute_update); |
476 | +void device_ensure_sink_is_unmuted (Device* self); |
477 | |
478 | // source and sinkinput/client related for VOIP functionality |
479 | -void active_sink_update_voip_input_source (ActiveSink* sink, const pa_source_info* update); |
480 | -void active_sink_activate_voip_item (ActiveSink* sink, gint sink_input_index, gint client_index); |
481 | -gint active_sink_get_current_sink_input_index (ActiveSink* sink); |
482 | -gboolean active_sink_is_voip_source_populated (ActiveSink* sink); |
483 | -gint active_sink_get_source_index (ActiveSink* self); |
484 | -void active_sink_determine_blocking_state (ActiveSink* self); |
485 | -void active_sink_deactivate_voip_source (ActiveSink* self, gboolean visible); |
486 | -void active_sink_deactivate_voip_client (ActiveSink* self); |
487 | -SoundState active_sink_get_state (ActiveSink* self); |
488 | +void device_update_voip_input_source (Device* sink, const pa_source_info* update); |
489 | +void device_activate_voip_item (Device* sink, gint sink_input_index, gint client_index); |
490 | +gint device_get_current_sink_input_index (Device* sink); |
491 | +gboolean device_is_voip_source_populated (Device* sink); |
492 | +gint device_get_source_index (Device* self); |
493 | +void device_determine_blocking_state (Device* self); |
494 | +void device_deactivate_voip_source (Device* self, gboolean visible); |
495 | +void device_deactivate_voip_client (Device* self); |
496 | +SoundState device_get_state (Device* self); |
497 | |
498 | -ActiveSink* active_sink_new (SoundServiceDbus* service); |
499 | +Device* device_new (SoundServiceDbus* service); |
500 | |
501 | G_END_DECLS |
502 | |
503 | |
504 | === modified file 'src/pulseaudio-mgr.c' |
505 | --- src/pulseaudio-mgr.c 2011-03-01 20:36:26 +0000 |
506 | +++ src/pulseaudio-mgr.c 2011-03-14 20:12:00 +0000 |
507 | @@ -68,7 +68,7 @@ |
508 | const pa_sink_input_info *info, |
509 | int eol, |
510 | void *userdata); |
511 | -static void pm_update_active_sink (pa_context *c, |
512 | +static void pm_update_device (pa_context *c, |
513 | const pa_sink_info *info, |
514 | int eol, |
515 | void *userdata); |
516 | @@ -89,11 +89,11 @@ |
517 | Entry Point |
518 | **/ |
519 | void |
520 | -pm_establish_pulse_connection (ActiveSink* active_sink) |
521 | +pm_establish_pulse_connection (Device* device) |
522 | { |
523 | pa_main_loop = pa_glib_mainloop_new (g_main_context_default ()); |
524 | g_assert (pa_main_loop); |
525 | - reconnect_to_pulse ((gpointer)active_sink); |
526 | + reconnect_to_pulse ((gpointer)device); |
527 | } |
528 | |
529 | /** |
530 | @@ -119,7 +119,7 @@ |
531 | { |
532 | g_debug("Attempt a pulse connection"); |
533 | // reset |
534 | - g_return_val_if_fail (IS_ACTIVE_SINK (user_data), FALSE); |
535 | + g_return_val_if_fail (IS_DEVICE (user_data), FALSE); |
536 | |
537 | connection_attempts += 1; |
538 | if (pulse_context != NULL) { |
539 | @@ -216,38 +216,38 @@ |
540 | uint32_t index, |
541 | void* userdata) |
542 | { |
543 | - if (IS_ACTIVE_SINK (userdata) == FALSE){ |
544 | + if (IS_DEVICE (userdata) == FALSE){ |
545 | g_critical ("subscribed events callback - our userdata is not what we think it should be"); |
546 | return; |
547 | } |
548 | - ActiveSink* sink = ACTIVE_SINK (userdata); |
549 | + Device* sink = DEVICE (userdata); |
550 | |
551 | switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) { |
552 | case PA_SUBSCRIPTION_EVENT_SINK: |
553 | |
554 | // We don't care about any other sink other than the active one. |
555 | - if (index != active_sink_get_index (sink)) |
556 | + if (index != device_get_index (sink)) |
557 | return; |
558 | |
559 | if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { |
560 | - active_sink_deactivate (sink); |
561 | + device_deactivate (sink); |
562 | |
563 | } |
564 | else{ |
565 | pa_operation_unref (pa_context_get_sink_info_by_index (c, |
566 | index, |
567 | - pm_update_active_sink, |
568 | + pm_update_device, |
569 | userdata) ); |
570 | } |
571 | break; |
572 | case PA_SUBSCRIPTION_EVENT_SOURCE: |
573 | g_debug ("Looks like source event of some description - index = %i", index); |
574 | // We don't care about any other sink other than the active one. |
575 | - if (index != active_sink_get_source_index (sink)) |
576 | + if (index != device_get_source_index (sink)) |
577 | return; |
578 | if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { |
579 | g_debug ("Source removal event - index = %i", index); |
580 | - active_sink_deactivate_voip_source (sink, FALSE); |
581 | + device_deactivate_voip_source (sink, FALSE); |
582 | } |
583 | else{ |
584 | pa_operation_unref (pa_context_get_source_info_by_index (c, |
585 | @@ -260,12 +260,12 @@ |
586 | // We don't care about sink input removals. |
587 | g_debug ("sink input event"); |
588 | if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { |
589 | - gint cached_index = active_sink_get_current_sink_input_index (sink); |
590 | + gint cached_index = device_get_current_sink_input_index (sink); |
591 | |
592 | g_debug ("Just saw a sink input removal event - index = %i and cached index = %i", index, cached_index); |
593 | |
594 | if (index == cached_index){ |
595 | - active_sink_deactivate_voip_client (sink); |
596 | + device_deactivate_voip_client (sink); |
597 | } |
598 | } |
599 | else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { |
600 | @@ -308,7 +308,7 @@ |
601 | break; |
602 | case PA_CONTEXT_FAILED: |
603 | g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?"); |
604 | - active_sink_deactivate (ACTIVE_SINK (userdata)); |
605 | + device_deactivate (DEVICE (userdata)); |
606 | if (reconnect_idle_id == 0){ |
607 | reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY, |
608 | reconnect_to_pulse, |
609 | @@ -362,7 +362,7 @@ |
610 | |
611 | if (info == NULL) { |
612 | g_warning("No PA server - get the hell out of here"); |
613 | - active_sink_deactivate (ACTIVE_SINK (userdata)); |
614 | + device_deactivate (DEVICE (userdata)); |
615 | return; |
616 | } |
617 | // Go for the default sink |
618 | @@ -373,7 +373,7 @@ |
619 | pm_default_sink_info_callback, |
620 | userdata) )) { |
621 | g_warning("pa_context_get_sink_info_by_namet() failed"); |
622 | - active_sink_deactivate (ACTIVE_SINK (userdata)); |
623 | + device_deactivate (DEVICE (userdata)); |
624 | pa_operation_unref(operation); |
625 | return; |
626 | } |
627 | @@ -382,7 +382,7 @@ |
628 | pm_sink_info_callback, |
629 | userdata))) { |
630 | g_warning("pa_context_get_sink_info_list() failed"); |
631 | - active_sink_deactivate (ACTIVE_SINK (userdata)); |
632 | + device_deactivate (DEVICE (userdata)); |
633 | pa_operation_unref(operation); |
634 | return; |
635 | } |
636 | @@ -421,14 +421,14 @@ |
637 | return; |
638 | } |
639 | else { |
640 | - if (IS_ACTIVE_SINK (userdata) == FALSE || sink == NULL){ |
641 | + if (IS_DEVICE (userdata) == FALSE || sink == NULL){ |
642 | g_warning ("sink info callback - our user data is not what we think it should be or the sink parameter is null"); |
643 | return; |
644 | } |
645 | - ActiveSink* a_sink = ACTIVE_SINK (userdata); |
646 | - if (active_sink_is_populated (a_sink) == FALSE && |
647 | + Device* a_sink = DEVICE (userdata); |
648 | + if (device_is_populated (a_sink) == FALSE && |
649 | g_ascii_strncasecmp("auto_null", sink->name, 9) != 0){ |
650 | - active_sink_populate (a_sink, sink); |
651 | + device_populate (a_sink, sink); |
652 | } |
653 | } |
654 | } |
655 | @@ -443,16 +443,16 @@ |
656 | return; |
657 | } |
658 | else { |
659 | - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ |
660 | + if (IS_DEVICE (userdata) == FALSE || info == NULL){ |
661 | g_warning ("Default sink info callback - our user data is not what we think it should be or the info parameter is null"); |
662 | return; |
663 | } |
664 | // Only repopulate if there is a change with regards the index |
665 | - if (active_sink_get_index (ACTIVE_SINK (userdata)) == info->index) |
666 | + if (device_get_index (DEVICE (userdata)) == info->index) |
667 | return; |
668 | |
669 | g_debug ("Pulse Server has handed us a new default sink"); |
670 | - active_sink_populate (ACTIVE_SINK (userdata), info); |
671 | + device_populate (DEVICE (userdata), info); |
672 | } |
673 | } |
674 | |
675 | @@ -466,18 +466,18 @@ |
676 | return; |
677 | } |
678 | else { |
679 | - if (info == NULL || IS_ACTIVE_SINK (userdata) == FALSE) { |
680 | + if (info == NULL || IS_DEVICE (userdata) == FALSE) { |
681 | g_warning("Sink input info callback : SINK INPUT INFO IS NULL or our user_data is not what we think it should be"); |
682 | return; |
683 | } |
684 | |
685 | - if (IS_ACTIVE_SINK (userdata) == FALSE){ |
686 | + if (IS_DEVICE (userdata) == FALSE){ |
687 | g_warning ("sink input info callback - our user data is not what we think it should be"); |
688 | return; |
689 | } |
690 | // Check if this is Voip sink input |
691 | gint result = pa_proplist_contains (info->proplist, PA_PROP_MEDIA_ROLE); |
692 | - ActiveSink* a_sink = ACTIVE_SINK (userdata); |
693 | + Device* a_sink = DEVICE (userdata); |
694 | |
695 | if (result == 1){ |
696 | g_debug ("Sink input info has media role property"); |
697 | @@ -485,7 +485,7 @@ |
698 | g_debug ("prop role = %s", value); |
699 | if (g_strcmp0 (value, "phone") == 0) { |
700 | g_debug ("And yes its a VOIP app ... sink input index = %i", info->index); |
701 | - active_sink_activate_voip_item (a_sink, (gint)info->index, (gint)info->client); |
702 | + device_activate_voip_item (a_sink, (gint)info->index, (gint)info->client); |
703 | // TODO to start with we will assume our source is the same as what this 'client' |
704 | // is pointing at. This should probably be more intelligent : |
705 | // query for the list of source output info's and going on the name of the client |
706 | @@ -494,14 +494,14 @@ |
707 | } |
708 | |
709 | // And finally check for the mute blocking state |
710 | - if (active_sink_get_index (a_sink) == info->sink){ |
711 | - active_sink_determine_blocking_state (a_sink); |
712 | + if (device_get_index (a_sink) == info->sink){ |
713 | + device_determine_blocking_state (a_sink); |
714 | } |
715 | } |
716 | } |
717 | |
718 | static void |
719 | -pm_update_active_sink (pa_context *c, |
720 | +pm_update_device (pa_context *c, |
721 | const pa_sink_info *info, |
722 | int eol, |
723 | void *userdata) |
724 | @@ -510,11 +510,11 @@ |
725 | return; |
726 | } |
727 | else{ |
728 | - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ |
729 | - g_warning ("update_active_sink - our user data is not what we think it should be or the info parameter is null"); |
730 | + if (IS_DEVICE (userdata) == FALSE || info == NULL){ |
731 | + g_warning ("update_device - our user data is not what we think it should be or the info parameter is null"); |
732 | return; |
733 | } |
734 | - active_sink_update (ACTIVE_SINK(userdata), info); |
735 | + device_update (DEVICE(userdata), info); |
736 | } |
737 | } |
738 | |
739 | @@ -551,16 +551,16 @@ |
740 | return; |
741 | } |
742 | else { |
743 | - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ |
744 | + if (IS_DEVICE (userdata) == FALSE || info == NULL){ |
745 | g_warning ("Default source info callback - our user data is not what we think it should be or the source info parameter is null"); |
746 | return; |
747 | } |
748 | // If there is an index change we need to change our cached source |
749 | - if (active_sink_get_source_index (ACTIVE_SINK (userdata)) == info->index) |
750 | + if (device_get_source_index (DEVICE (userdata)) == info->index) |
751 | return; |
752 | g_debug ("Pulse Server has handed us a new default source"); |
753 | - active_sink_deactivate_voip_source (ACTIVE_SINK (userdata), TRUE); |
754 | - active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); |
755 | + device_deactivate_voip_source (DEVICE (userdata), TRUE); |
756 | + device_update_voip_input_source (DEVICE (userdata), info); |
757 | } |
758 | } |
759 | |
760 | @@ -574,13 +574,13 @@ |
761 | return; |
762 | } |
763 | else { |
764 | - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){ |
765 | + if (IS_DEVICE (userdata) == FALSE || info == NULL){ |
766 | g_warning ("source info callback - our user data is not what we think it should be or the source info parameter is null"); |
767 | return; |
768 | } |
769 | // For now we will take the first available |
770 | - if (active_sink_is_voip_source_populated (ACTIVE_SINK (userdata)) == FALSE){ |
771 | - active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); |
772 | + if (device_is_voip_source_populated (DEVICE (userdata)) == FALSE){ |
773 | + device_update_voip_input_source (DEVICE (userdata), info); |
774 | } |
775 | } |
776 | } |
777 | @@ -595,11 +595,11 @@ |
778 | return; |
779 | } |
780 | else { |
781 | - if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL ){ |
782 | + if (IS_DEVICE (userdata) == FALSE || info == NULL ){ |
783 | g_warning ("source info update callback - our user data is not what we think it should be or the source info paramter is null"); |
784 | return; |
785 | } |
786 | g_debug ("Got a source update for %s , index %i", info->name, info->index); |
787 | - active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info); |
788 | + device_update_voip_input_source (DEVICE (userdata), info); |
789 | } |
790 | } |
791 | |
792 | === modified file 'src/pulseaudio-mgr.h' |
793 | --- src/pulseaudio-mgr.h 2011-02-18 16:22:58 +0000 |
794 | +++ src/pulseaudio-mgr.h 2011-03-14 20:12:00 +0000 |
795 | @@ -17,9 +17,9 @@ |
796 | with this program. If not, see <http://www.gnu.org/licenses/>. |
797 | */ |
798 | |
799 | -#include "active-sink.h" |
800 | +#include "device.h" |
801 | |
802 | -void pm_establish_pulse_connection (ActiveSink* active_sink); |
803 | +void pm_establish_pulse_connection (Device* device); |
804 | void close_pulse_activites(); |
805 | void pm_update_volume (gint sink_index, pa_cvolume new_volume); |
806 | void pm_update_mic_gain (gint source_index, pa_cvolume new_gain); |
807 | |
808 | === modified file 'src/slider-menu-item.c' |
809 | --- src/slider-menu-item.c 2011-03-10 19:48:26 +0000 |
810 | +++ src/slider-menu-item.c 2011-03-14 20:12:00 +0000 |
811 | @@ -23,11 +23,17 @@ |
812 | #include <glib/gi18n.h> |
813 | #include "slider-menu-item.h" |
814 | #include "common-defs.h" |
815 | +#include "pulseaudio-mgr.h" |
816 | |
817 | typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate; |
818 | |
819 | struct _SliderMenuItemPrivate { |
820 | - ActiveSink* a_sink; |
821 | + Device* a_sink; |
822 | + gint index; |
823 | + gchar* name; |
824 | + pa_cvolume volume; |
825 | + pa_channel_map channel_map; |
826 | + pa_volume_t base_volume; |
827 | }; |
828 | |
829 | #define SLIDER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SLIDER_MENU_ITEM_TYPE, SliderMenuItemPrivate)) |
830 | @@ -39,6 +45,8 @@ |
831 | static void slider_menu_item_finalize (GObject *object); |
832 | static void handle_event (DbusmenuMenuitem * mi, const gchar * name, |
833 | GVariant * value, guint timestamp); |
834 | +static pa_cvolume slider_menu_item_construct_mono_volume (const pa_cvolume* vol); |
835 | +static void slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent); |
836 | |
837 | G_DEFINE_TYPE (SliderMenuItem, slider_menu_item, DBUSMENU_TYPE_MENUITEM); |
838 | |
839 | @@ -63,7 +71,13 @@ |
840 | g_debug("Building new Slider Menu Item"); |
841 | dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self), |
842 | DBUSMENU_MENUITEM_PROP_TYPE, |
843 | - DBUSMENU_VOLUME_MENUITEM_TYPE ); |
844 | + DBUSMENU_VOLUME_MENUITEM_TYPE ); |
845 | + |
846 | + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); |
847 | + |
848 | + priv->index = -1; |
849 | + priv->name = NULL; |
850 | + |
851 | return; |
852 | } |
853 | |
854 | @@ -97,33 +111,108 @@ |
855 | SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi)); |
856 | gdouble volume_input = g_variant_get_double(input); |
857 | //g_debug ("slider menu item about to update volume %f", volume_input); |
858 | - active_sink_update_volume (priv->a_sink, volume_input); |
859 | - active_sink_ensure_sink_is_unmuted (priv->a_sink); |
860 | + slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input); |
861 | + device_ensure_sink_is_unmuted (priv->a_sink); |
862 | } |
863 | } |
864 | } |
865 | |
866 | -void |
867 | -slider_menu_item_update (SliderMenuItem* item, |
868 | - gdouble update) |
869 | -{ |
870 | - GVariant* new_volume = g_variant_new_double(update); |
871 | - dbusmenu_menuitem_property_set_variant(DBUSMENU_MENUITEM(item), |
872 | - DBUSMENU_VOLUME_MENUITEM_LEVEL, |
873 | - new_volume); |
874 | -} |
875 | - |
876 | -void |
877 | -slider_menu_item_enable (SliderMenuItem* item, |
878 | - gboolean active) |
879 | -{ |
880 | - dbusmenu_menuitem_property_set_bool( DBUSMENU_MENUITEM(item), |
881 | + |
882 | +void |
883 | +slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update) |
884 | +{ |
885 | + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); |
886 | + priv->name = g_strdup (update->name); |
887 | + priv->index = update->index; |
888 | + priv->volume = slider_menu_item_construct_mono_volume (&update->volume); |
889 | + priv->base_volume = update->base_volume; |
890 | + priv->channel_map = update->channel_map; |
891 | + |
892 | + pa_volume_t vol = pa_cvolume_max (&update->volume); |
893 | + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; |
894 | + GVariant* new_volume = g_variant_new_double (volume_percent); |
895 | + dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), |
896 | + DBUSMENU_VOLUME_MENUITEM_LEVEL, |
897 | + new_volume); |
898 | + slider_menu_item_enable (self, TRUE); |
899 | +} |
900 | + |
901 | +// From the UI |
902 | +static void |
903 | +slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent) |
904 | +{ |
905 | + pa_cvolume new_volume; |
906 | + pa_cvolume_init(&new_volume); |
907 | + new_volume.channels = 1; |
908 | + pa_volume_t new_volume_value = (pa_volume_t) ((percent * PA_VOLUME_NORM) / 100); |
909 | + pa_cvolume_set(&new_volume, 1, new_volume_value); |
910 | + |
911 | + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); |
912 | + |
913 | + pa_cvolume_set(&priv->volume, priv->channel_map.channels, new_volume_value); |
914 | + pm_update_volume (priv->index, new_volume); |
915 | +} |
916 | + |
917 | +// To the UI |
918 | +void |
919 | +slider_menu_item_update (SliderMenuItem* self, const pa_sink_info* update) |
920 | +{ |
921 | + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); |
922 | + |
923 | + priv->volume = slider_menu_item_construct_mono_volume (&update->volume); |
924 | + priv->base_volume = update->base_volume; |
925 | + priv->channel_map = update->channel_map; |
926 | + |
927 | + pa_volume_t vol = pa_cvolume_max (&update->volume); |
928 | + gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; |
929 | + |
930 | + GVariant* new_volume = g_variant_new_double (volume_percent); |
931 | + dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), |
932 | + DBUSMENU_VOLUME_MENUITEM_LEVEL, |
933 | + new_volume); |
934 | +} |
935 | + |
936 | +/* |
937 | + * Enable/Disabled can be considered the equivalent of whether we have an active |
938 | + * sink or not, let the widget have inherent state. |
939 | + */ |
940 | +void |
941 | +slider_menu_item_enable (SliderMenuItem* self, gboolean active) |
942 | +{ |
943 | + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); |
944 | + |
945 | + dbusmenu_menuitem_property_set_bool (DBUSMENU_MENUITEM(self), |
946 | DBUSMENU_MENUITEM_PROP_ENABLED, |
947 | - active ); |
948 | + active); |
949 | + if(active == FALSE){ |
950 | + priv->index = -1; |
951 | + if(priv->name != NULL){ |
952 | + g_free(priv->name); |
953 | + priv->name = NULL; |
954 | + } |
955 | + } |
956 | +} |
957 | + |
958 | +gint |
959 | +slider_menu_item_get_sink_index (SliderMenuItem* self) |
960 | +{ |
961 | + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); |
962 | + return priv->index; |
963 | +} |
964 | + |
965 | +static pa_cvolume |
966 | +slider_menu_item_construct_mono_volume (const pa_cvolume* vol) |
967 | +{ |
968 | + pa_cvolume new_volume; |
969 | + pa_cvolume_init(&new_volume); |
970 | + new_volume.channels = 1; |
971 | + pa_volume_t max_vol = pa_cvolume_max(vol); |
972 | + pa_cvolume_set(&new_volume, 1, max_vol); |
973 | + return new_volume; |
974 | } |
975 | |
976 | SliderMenuItem* |
977 | -slider_menu_item_new (ActiveSink* sink) |
978 | +slider_menu_item_new (Device* sink) |
979 | { |
980 | SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL); |
981 | SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); |
982 | |
983 | === modified file 'src/slider-menu-item.h' |
984 | --- src/slider-menu-item.h 2011-02-04 19:55:20 +0000 |
985 | +++ src/slider-menu-item.h 2011-03-14 20:12:00 +0000 |
986 | @@ -23,7 +23,7 @@ |
987 | #include <glib-object.h> |
988 | |
989 | #include <libdbusmenu-glib/menuitem.h> |
990 | -#include "active-sink.h" |
991 | +#include "device.h" |
992 | |
993 | G_BEGIN_DECLS |
994 | |
995 | @@ -47,10 +47,16 @@ |
996 | |
997 | GType slider_menu_item_get_type (void); |
998 | |
999 | -void slider_menu_item_update(SliderMenuItem* item, gdouble update); |
1000 | +void slider_menu_item_update(SliderMenuItem* item, const pa_sink_info* update); |
1001 | void slider_menu_item_enable(SliderMenuItem* item, gboolean active); |
1002 | - |
1003 | -SliderMenuItem* slider_menu_item_new (ActiveSink* sink); |
1004 | +void slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update); |
1005 | +//void |
1006 | +//active_sink_update (ActiveSink* sink, |
1007 | +// const pa_sink_info* update) |
1008 | + |
1009 | +gint slider_menu_item_get_sink_index (SliderMenuItem* self); |
1010 | + |
1011 | +SliderMenuItem* slider_menu_item_new (Device* sink); |
1012 | |
1013 | G_END_DECLS |
1014 | |
1015 | |
1016 | === modified file 'src/sound-service-dbus.c' |
1017 | --- src/sound-service-dbus.c 2011-03-11 15:24:11 +0000 |
1018 | +++ src/sound-service-dbus.c 2011-03-14 20:12:00 +0000 |
1019 | @@ -29,7 +29,7 @@ |
1020 | #include <libdbusmenu-glib/client.h> |
1021 | |
1022 | #include "sound-service-dbus.h" |
1023 | -#include "active-sink.h" |
1024 | +#include "device.h" |
1025 | #include "gen-sound-service.xml.h" |
1026 | #include "dbus-shared-names.h" |
1027 | |
1028 | @@ -55,7 +55,7 @@ |
1029 | struct _SoundServiceDbusPrivate { |
1030 | GDBusConnection* connection; |
1031 | DbusmenuMenuitem* root_menuitem; |
1032 | - ActiveSink* active_sink; |
1033 | + Device* device; |
1034 | }; |
1035 | |
1036 | static GDBusNodeInfo * node_info = NULL; |
1037 | @@ -155,7 +155,7 @@ |
1038 | paths); |
1039 | dbusmenu_server_set_root (server, priv->root_menuitem); |
1040 | g_object_unref (priv->root_menuitem); |
1041 | - priv->active_sink = active_sink_new (self); |
1042 | + priv->device = device_new (self); |
1043 | return priv->root_menuitem; |
1044 | } |
1045 | |
1046 | @@ -272,8 +272,8 @@ |
1047 | SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (service); |
1048 | |
1049 | if (g_strcmp0(method, "GetSoundState") == 0) { |
1050 | - g_debug("Get state - %i", active_sink_get_state (priv->active_sink)); |
1051 | - retval = g_variant_new ( "(i)", active_sink_get_state (priv->active_sink)); |
1052 | + g_debug("Get state - %i", device_get_state (priv->device)); |
1053 | + retval = g_variant_new ( "(i)", device_get_state (priv->device)); |
1054 | } |
1055 | else if (g_strcmp0(method, "BlacklistMediaPlayer") == 0) { |
1056 | gboolean blacklist; |
1057 | |
1058 | === modified file 'src/voip-input-menu-item.c' |
1059 | --- src/voip-input-menu-item.c 2011-02-18 17:11:08 +0000 |
1060 | +++ src/voip-input-menu-item.c 2011-03-14 20:12:00 +0000 |
1061 | @@ -28,7 +28,7 @@ |
1062 | typedef struct _VoipInputMenuItemPrivate VoipInputMenuItemPrivate; |
1063 | |
1064 | struct _VoipInputMenuItemPrivate { |
1065 | - ActiveSink* a_sink; |
1066 | + Device* a_sink; |
1067 | pa_cvolume volume; |
1068 | gint mute; |
1069 | guint32 volume_steps; |
1070 | @@ -129,8 +129,6 @@ |
1071 | if (priv->mute == 1) { |
1072 | pm_update_mic_mute (priv->source_index, 0); |
1073 | } |
1074 | - //active_sink_update_volume (priv->a_sink, volume_input); |
1075 | - //active_sink_ensure_sink_is_unmuted (priv->a_sink); |
1076 | } |
1077 | } |
1078 | } |
1079 | @@ -268,7 +266,7 @@ |
1080 | } |
1081 | |
1082 | VoipInputMenuItem* |
1083 | -voip_input_menu_item_new (ActiveSink* sink) |
1084 | +voip_input_menu_item_new (Device* sink) |
1085 | { |
1086 | VoipInputMenuItem *self = g_object_new(VOIP_INPUT_MENU_ITEM_TYPE, NULL); |
1087 | VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (self); |
1088 | |
1089 | === modified file 'src/voip-input-menu-item.h' |
1090 | --- src/voip-input-menu-item.h 2011-02-18 17:11:08 +0000 |
1091 | +++ src/voip-input-menu-item.h 2011-03-14 20:12:00 +0000 |
1092 | @@ -22,7 +22,7 @@ |
1093 | #include <glib.h> |
1094 | #include <pulse/pulseaudio.h> |
1095 | #include <libdbusmenu-glib/menuitem.h> |
1096 | -#include "active-sink.h" |
1097 | +#include "device.h" |
1098 | |
1099 | G_BEGIN_DECLS |
1100 | |
1101 | @@ -62,7 +62,7 @@ |
1102 | void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible); |
1103 | void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item); |
1104 | |
1105 | -VoipInputMenuItem* voip_input_menu_item_new (ActiveSink* sink); |
1106 | +VoipInputMenuItem* voip_input_menu_item_new (Device* sink); |
1107 | |
1108 | G_END_DECLS |
1109 |