Merge lp:~diwic/gnome-control-center/expose-card-ports into lp:~cjcurran/gnome-control-center/expose-card-ports

Proposed by David Henningsson
Status: Merged
Merge reported by: Conor Curran
Merged at revision: not available
Proposed branch: lp:~diwic/gnome-control-center/expose-card-ports
Merge into: lp:~cjcurran/gnome-control-center/expose-card-ports
Diff against target: 333 lines (+74/-50)
4 files modified
panels/sound/gvc-mixer-control.c (+26/-9)
panels/sound/gvc-mixer-dialog.c (+19/-17)
panels/sound/gvc-speaker-test.c (+28/-23)
panels/sound/gvc-speaker-test.h (+1/-1)
To merge this branch: bzr merge lp:~diwic/gnome-control-center/expose-card-ports
Reviewer Review Type Date Requested Status
Conor Curran Approve
Review via email: mp+91444@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote :

Looking good !

review: Approve
275. By David Henningsson

Fix speaker testing for devices without cards

Revision history for this message
Conor Curran (cjcurran) wrote :

Merged manually - quilt is acting the ...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/sound/gvc-mixer-control.c'
2--- panels/sound/gvc-mixer-control.c 2012-02-02 22:12:25 +0000
3+++ panels/sound/gvc-mixer-control.c 2012-02-03 15:13:21 +0000
4@@ -582,9 +582,9 @@
5
6
7 /**
8- * gvc_mixer_control_change_output:
9+ * gvc_mixer_control_change_input:
10 * @control:
11- * @output:
12+ * @input:
13 */
14 void
15 gvc_mixer_control_change_input (GvcMixerControl *control,
16@@ -620,6 +620,23 @@
17 return;
18 }
19
20+ // Handle a network sink => a portless/cardless device
21+ if (gvc_mixer_ui_device_get_port (input) == NULL){
22+ g_print ("Did we try to move to a network source ? \n");
23+ if (gvc_mixer_control_set_default_source (control, stream)) {
24+ // source change successfull => update the UI.
25+ g_signal_emit (G_OBJECT (control),
26+ signals[ACTIVE_INPUT_UPDATE],
27+ 0,
28+ gvc_mixer_ui_device_get_id (input));
29+ }
30+ else{
31+ g_warning ("Failed to set default source with stream from input %s \n",
32+ gvc_mixer_ui_device_get_description (input));
33+ }
34+ return;
35+ }
36+
37 const GvcMixerStreamPort* active_port = gvc_mixer_stream_get_port (stream);
38 const gchar* input_port = gvc_mixer_ui_device_get_port (input);
39 // First ensure the correct port is active on the sink
40@@ -1197,7 +1214,7 @@
41
42 static void
43 sync_devices (GvcMixerControl *control,
44- GvcMixerStream* stream)
45+ GvcMixerStream* stream, int is_output)
46 {
47
48 // Go through ports to see what outputs can be created.
49@@ -1208,22 +1225,22 @@
50 gint stream_port_count = 0;
51
52 if (g_list_length (stream_ports) == 0){
53- g_print (" \n \n !!! Just found a sink without ports - creating an output \n");
54+ g_print (" \n \n !!! Just found a %s without ports - creating a UI device \n", is_output ? "sink" : "source");
55 GObject *object;
56 object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
57 "stream-id", (gint)gvc_mixer_stream_get_id (stream),
58 "description", gvc_mixer_stream_get_description (stream),
59- "origin", gvc_mixer_stream_get_name (stream),
60+ "origin", "", /* gvc_mixer_stream_get_name (stream), */
61 "port-name", NULL,
62 "port-available", TRUE,
63 NULL);
64 GvcMixerUIDevice* out = GVC_MIXER_UI_DEVICE (object);
65- g_hash_table_insert (control->priv->ui_outputs,
66+ g_hash_table_insert (is_output ? control->priv->ui_outputs : control->priv->ui_inputs,
67 GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (out)),
68 g_object_ref (out));
69
70 g_signal_emit (G_OBJECT (control),
71- signals[OUTPUT_ADDED],
72+ signals[is_output ? OUTPUT_ADDED : INPUT_ADDED],
73 0,
74 gvc_mixer_ui_device_get_id (out));
75 return;
76@@ -1397,7 +1414,7 @@
77 add_stream (control, stream);
78 // Always sink on a new stream to able to assign the right stream id
79 // to the appropriate outputs (=>multiple potential outputs per stream).
80- sync_devices (control, stream);
81+ sync_devices (control, stream, TRUE);
82 }
83
84
85@@ -1533,7 +1550,7 @@
86 g_object_ref (stream));
87 add_stream (control, stream);
88
89- sync_devices (control, stream);
90+ sync_devices (control, stream, FALSE);
91 }
92
93 if (control->priv->default_source_name != NULL
94
95=== modified file 'panels/sound/gvc-mixer-dialog.c'
96--- panels/sound/gvc-mixer-dialog.c 2012-02-01 19:58:09 +0000
97+++ panels/sound/gvc-mixer-dialog.c 2012-02-03 15:13:21 +0000
98@@ -1129,18 +1129,17 @@
99 GIcon *icon;
100
101 if (card_id == GVC_MIXER_UI_DEVICE_INVALID) {
102+ GvcMixerStream *stream;
103 g_print ("just detected a network source");
104- /*GvcMixerStream *stream;
105- stream = gvc_mixer_control_get_stream_from_device (dialog->priv->mixer_control, output);
106+ stream = gvc_mixer_control_get_stream_from_device (dialog->priv->mixer_control, input);
107 if (stream == NULL) {
108- g_warning ("tried to add the network sink but the stream was null - fail ?!");
109- g_free (sink_port_name);
110- g_free (origin);
111- g_free (description);
112+ g_warning ("tried to add the network source but the stream was null - fail ?!");
113+ g_free (port_name);
114+ g_free (origin);
115+ g_free (description);
116 return;
117 }
118- icon = gvc_mixer_stream_get_gicon (stream);*/
119- return;
120+ icon = gvc_mixer_stream_get_gicon (stream);
121 }
122 else{
123 GvcMixerCard *card;
124@@ -1617,28 +1616,31 @@
125
126 GvcMixerUIDevice *output;
127 output = gvc_mixer_control_lookup_output_id (dialog->priv->mixer_control, (guint)active_output);
128- gint card_id;
129-
130- g_object_get (G_OBJECT (output), "card-id", &card_id, NULL);
131+ gint stream_id = gvc_mixer_ui_device_get_stream_id(output);
132
133- if (card_id == GVC_MIXER_UI_DEVICE_INVALID)
134+ if (stream_id == GVC_MIXER_UI_DEVICE_INVALID)
135 return;
136
137 g_print ("Test the speakers on the %s", gvc_mixer_ui_device_get_description (output));
138
139- GvcMixerCard *card;
140+ GvcMixerStream *stream;
141 GvcMixerCardProfile *profile;
142 GtkWidget *d, *speaker_test, *container;
143 char *title;
144
145- card = gvc_mixer_control_lookup_card_id (dialog->priv->mixer_control, card_id);
146+ stream = gvc_mixer_control_lookup_stream_id (dialog->priv->mixer_control, stream_id);
147+ if (stream == NULL) {
148+ g_print ("Stream/sink not found");
149+ return;
150+ }
151+/* card = gvc_mixer_control_lookup_card_id (dialog->priv->mixer_control, card_id);
152
153 profile = gvc_mixer_card_get_profile (card);
154
155 g_debug ("XXX Start speaker testing for profile '%s', card %s XXX",
156 profile->profile, gvc_mixer_card_get_name (card));
157-
158- title = g_strdup_printf (_("Speaker Testing for %s"), gvc_mixer_card_get_name (card));
159+*/
160+ title = g_strdup_printf (_("Speaker Testing for %s"), gvc_mixer_ui_device_get_description (output));
161 d = gtk_dialog_new_with_buttons (title,
162 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget))),
163 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
164@@ -1648,7 +1650,7 @@
165
166 g_free (title);
167 speaker_test = gvc_speaker_test_new (dialog->priv->mixer_control,
168- card);
169+ stream);
170 gtk_widget_show (speaker_test);
171 container = gtk_dialog_get_content_area (GTK_DIALOG (d));
172 gtk_container_add (GTK_CONTAINER (container), speaker_test);
173
174=== modified file 'panels/sound/gvc-speaker-test.c'
175--- panels/sound/gvc-speaker-test.c 2011-08-18 12:14:03 +0000
176+++ panels/sound/gvc-speaker-test.c 2012-02-03 15:13:21 +0000
177@@ -33,7 +33,7 @@
178
179 #include "gvc-speaker-test.h"
180 #include "gvc-mixer-stream.h"
181-#include "gvc-mixer-card.h"
182+/* #include "gvc-mixer-card.h" */
183
184 #define GVC_SPEAKER_TEST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_SPEAKER_TEST, GvcSpeakerTestPrivate))
185
186@@ -41,7 +41,7 @@
187 {
188 GtkWidget *channel_controls[PA_CHANNEL_POSITION_MAX];
189 ca_context *canberra;
190- GvcMixerCard *card;
191+ GvcMixerStream *stream;
192 GvcMixerControl *control;
193 };
194
195@@ -53,7 +53,7 @@
196
197 enum {
198 PROP_0,
199- PROP_CARD,
200+ PROP_STREAM,
201 PROP_CONTROL
202 };
203
204@@ -89,14 +89,14 @@
205 GvcSpeakerTest *self = GVC_SPEAKER_TEST (object);
206
207 switch (prop_id) {
208- case PROP_CARD:
209- self->priv->card = g_value_dup_object (value);
210+ case PROP_STREAM:
211+ self->priv->stream = g_value_dup_object (value);
212 if (self->priv->control != NULL)
213 update_channel_map (self);
214 break;
215 case PROP_CONTROL:
216 self->priv->control = g_value_dup_object (value);
217- if (self->priv->card != NULL)
218+ if (self->priv->stream != NULL)
219 update_channel_map (self);
220 break;
221 default:
222@@ -114,8 +114,8 @@
223 GvcSpeakerTest *self = GVC_SPEAKER_TEST (object);
224
225 switch (prop_id) {
226- case PROP_CARD:
227- g_value_set_object (value, self->priv->card);
228+ case PROP_STREAM:
229+ g_value_set_object (value, self->priv->stream);
230 break;
231 case PROP_CONTROL:
232 g_value_set_object (value, self->priv->control);
233@@ -136,11 +136,11 @@
234 object_class->get_property = gvc_speaker_test_get_property;
235
236 g_object_class_install_property (object_class,
237- PROP_CARD,
238- g_param_spec_object ("card",
239- "card",
240- "The card",
241- GVC_TYPE_MIXER_CARD,
242+ PROP_STREAM,
243+ g_param_spec_object ("stream",
244+ "stream",
245+ "The stream",
246+ GVC_TYPE_MIXER_STREAM,
247 G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
248 g_object_class_install_property (object_class,
249 PROP_CONTROL,
250@@ -366,6 +366,7 @@
251 }
252 }
253
254+#if 0
255 static const GvcChannelMap *
256 get_channel_map_for_card (GvcMixerControl *control,
257 GvcMixerCard *card,
258@@ -408,6 +409,7 @@
259
260 return map;
261 }
262+#endif
263
264 static void
265 update_channel_map (GvcSpeakerTest *speaker_test)
266@@ -417,17 +419,20 @@
267 char *output_name;
268
269 g_return_if_fail (speaker_test->priv->control != NULL);
270- g_return_if_fail (speaker_test->priv->card != NULL);
271+ g_return_if_fail (speaker_test->priv->stream != NULL);
272
273 g_debug ("XXX update_channel_map called XXX");
274
275- map = get_channel_map_for_card (speaker_test->priv->control,
276- speaker_test->priv->card,
277+ map = gvc_mixer_stream_get_channel_map (speaker_test->priv->stream);
278+/*
279+ map = get_channel_map_for_stream (speaker_test->priv->control,
280+ speaker_test->priv->stream,
281 &output_name);
282-
283+*/
284 g_return_if_fail (map != NULL);
285
286- ca_context_change_device (speaker_test->priv->canberra, output_name);
287+ ca_context_change_device (speaker_test->priv->canberra,
288+ gvc_mixer_stream_get_name (speaker_test->priv->stream));
289 g_free (output_name);
290
291 for (i = 0; i < G_N_ELEMENTS (position_table); i += 3) {
292@@ -495,8 +500,8 @@
293
294 g_return_if_fail (speaker_test->priv != NULL);
295
296- g_object_unref (speaker_test->priv->card);
297- speaker_test->priv->card = NULL;
298+ g_object_unref (speaker_test->priv->stream);
299+ speaker_test->priv->stream = NULL;
300
301 g_object_unref (speaker_test->priv->control);
302 speaker_test->priv->control = NULL;
303@@ -509,15 +514,15 @@
304
305 GtkWidget *
306 gvc_speaker_test_new (GvcMixerControl *control,
307- GvcMixerCard *card)
308+ GvcMixerStream *stream)
309 {
310 GObject *speaker_test;
311
312- g_return_val_if_fail (card != NULL, NULL);
313+ g_return_val_if_fail (stream != NULL, NULL);
314 g_return_val_if_fail (control != NULL, NULL);
315
316 speaker_test = g_object_new (GVC_TYPE_SPEAKER_TEST,
317- "card", card,
318+ "stream", stream,
319 "control", control,
320 NULL);
321
322
323=== modified file 'panels/sound/gvc-speaker-test.h'
324--- panels/sound/gvc-speaker-test.h 2011-05-17 10:47:27 +0000
325+++ panels/sound/gvc-speaker-test.h 2012-02-03 15:13:21 +0000
326@@ -50,7 +50,7 @@
327 GType gvc_speaker_test_get_type (void);
328
329 GtkWidget * gvc_speaker_test_new (GvcMixerControl *control,
330- GvcMixerCard *card);
331+ GvcMixerStream *stream);
332
333 G_END_DECLS
334

Subscribers

People subscribed via source and target branches