Merge lp:~cjcurran/indicator-sound/hotplug-investigations into lp:~harryhaaren/indicator-sound/hotplug-client-index

Proposed by Conor Curran
Status: Merged
Merge reported by: Conor Curran
Merged at revision: not available
Proposed branch: lp:~cjcurran/indicator-sound/hotplug-investigations
Merge into: lp:~harryhaaren/indicator-sound/hotplug-client-index
Diff against target: 792 lines (+497/-42) (has conflicts)
5 files modified
src/Makefile.am (+1/-1)
src/device.c (+23/-0)
src/device.h (+2/-0)
src/pulseaudio-mgr.c (+471/-40)
src/pulseaudio-mgr.h (+0/-1)
Text conflict in src/pulseaudio-mgr.c
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/hotplug-investigations
Reviewer Review Type Date Requested Status
Harry van Haaren Pending
Review via email: mp+66141@code.launchpad.net
To post a comment you must log in.

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-06-22 19:19:49 +0000
3+++ src/Makefile.am 2011-06-28 13:12:52 +0000
4@@ -108,7 +108,7 @@
5 $(music_bridge_VALASOURCES:.vala=.c)
6
7 indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall
8-indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS)
9+indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) -lnotify
10
11 #########################
12 # Service xml compilation
13
14=== modified file 'src/device.c'
15--- src/device.c 2011-06-27 16:58:31 +0000
16+++ src/device.c 2011-06-28 13:12:52 +0000
17@@ -442,6 +442,29 @@
18 mute_menu_item_get_button (priv->mute_menuitem),
19 DBUSMENU_MENUITEM (priv->volume_slider_menuitem),
20 DBUSMENU_MENUITEM (priv->voip_input_menu_item));
21+
22+ printf("<ME> device.c:device_new()\n");
23+
24+ NotifyNotification *notify;
25+
26+ notify_init("soundNotify");
27+
28+ notify = notify_notification_new ("Audio Device Connected",
29+ "New device connected",
30+ NULL);
31+
32+ notify_notification_set_timeout (notify, 3000); //3 seconds
33+
34+ if (!notify_notification_show (notify, NULL)) {
35+ fprintf(stderr, "failed to send notification\n");
36+ }
37+
38+ g_object_unref(G_OBJECT(notify));
39+
40 pm_establish_pulse_connection (sink);
41 return sink;
42 }
43+
44+
45+
46+
47
48=== modified file 'src/device.h'
49--- src/device.h 2011-06-24 17:18:51 +0000
50+++ src/device.h 2011-06-28 13:12:52 +0000
51@@ -23,6 +23,8 @@
52 #include <glib.h>
53 #include <glib-object.h>
54
55+#include <libnotify/notify.h>
56+
57 #include "common-defs.h"
58 #include "sound-service-dbus.h"
59
60
61=== modified file 'src/pulseaudio-mgr.c'
62--- src/pulseaudio-mgr.c 2011-06-27 16:58:31 +0000
63+++ src/pulseaudio-mgr.c 2011-06-28 13:12:52 +0000
64@@ -29,13 +29,15 @@
65 #include <pulse/gccmacro.h>
66 #include <pulse/glib-mainloop.h>
67 #include <pulse/error.h>
68+#include <pulse/ext-stream-restore.h>
69
70 #include "pulseaudio-mgr.h"
71 #include "config.h"
72
73+#include <libnotify/notify.h>
74+
75 #define RECONNECT_DELAY 5
76
77-
78 static void pm_context_state_callback(pa_context *c, void *userdata);
79 static void pm_subscribed_events_callback (pa_context *c,
80 enum pa_subscription_event_type t,
81@@ -101,9 +103,39 @@
82 int eol,
83 void *userdata);
84
85+
86+
87+static const char* pm_default_sink_name = 0;
88+static const char* pm_default_source_name = 0;
89+
90+static gint stream_restore_array_iter = 0;
91+static gint stream_restore_array_size = 0;
92+static gint stream_restore_array_contents_size = 0;
93+
94+static pa_ext_stream_restore_info *stream_restore_array = NULL;
95+
96+static gint pm_ext_stream_restore_counter = 0;
97+
98+static void pm_ext_stream_restore_read_callback(pa_context *c,const pa_ext_stream_restore_info *info,int eol,void *userdata);
99+
100+
101+static void pm_ext_stream_restore_test_callback(pa_context *c, uint32_t version, void *userdata);
102+static void pm_ext_stream_restore_subscribe_callback(pa_context *c, int success, void *userdata);
103+static void pm_ext_stream_restore_action_callback(pa_context *c, void *userdata);
104+
105+static void pm_sink_input_info_hotplug_callback (pa_context *c,
106+ const pa_sink_input_info *info,
107+ int eol,
108+ void *userdata);
109+
110+
111+
112 static gboolean reconnect_to_pulse (gpointer user_data);
113-
114-
115+<<<<<<< TREE
116+
117+
118+=======
119+>>>>>>> MERGE-SOURCE
120 static gint connection_attempts = 0;
121 static gint reconnect_idle_id = 0;
122 static pa_context *pulse_context = NULL;
123@@ -161,8 +193,10 @@
124 }
125
126 pa_proplist *proplist;
127-
128+
129 proplist = pa_proplist_new ();
130+
131+
132 pa_proplist_sets (proplist,
133 PA_PROP_APPLICATION_NAME,
134 "Indicator Sound");
135@@ -215,6 +249,17 @@
136 }
137
138 void
139+stream_moved_callback(pa_stream *s, void *userdata)
140+{
141+ g_debug("Stream moved");
142+
143+ g_debug("Stream moved to device %s (%u, %ssuspended)",
144+ pa_stream_get_device_name(s),
145+ pa_stream_get_device_index(s),
146+ (pa_stream_is_suspended(s) ? "" : "not "));
147+}
148+
149+void
150 pm_update_mute (gboolean update)
151 {
152 pa_operation_unref (pa_context_get_sink_info_list (pulse_context,
153@@ -245,6 +290,99 @@
154 // Pulse-Audio asychronous call-backs
155 /**********************************************************************************************************************/
156
157+void pm_ext_stream_restore_test_callback(pa_context *c, uint32_t version, void *userdata)
158+{
159+ printf("pm_ext_stream_restore_test_callback: %i\n", version);
160+
161+ if ( version != 0 )
162+ {
163+ // we have the stream restore module, so register callbacks
164+
165+ // first "enable" our subscription to the stream database:
166+ pa_operation_unref( pa_ext_stream_restore_subscribe(c,
167+ 1, // int enable
168+ pm_ext_stream_restore_subscribe_callback,
169+ NULL // userdata
170+ ));
171+
172+ // then set our subscription callback, which will provide info:
173+ pa_ext_stream_restore_set_subscribe_cb (c,
174+ pm_ext_stream_restore_action_callback,
175+ NULL );
176+
177+ // initialize array to an arbitrary size for now, <FIXME>
178+ //pa_ext_stream_restore_info stream_database[100];
179+ //stream_restore_array = &stream_database;
180+
181+ // read the entire streams database,
182+ pa_operation_unref( pa_ext_stream_restore_read( c,
183+ pm_ext_stream_restore_read_callback,
184+ NULL // userdata
185+ ) );
186+
187+ }
188+ else
189+ g_warning("ext_stream_restore module not available");
190+
191+}
192+
193+static void pm_sink_input_info_hotplug_callback (pa_context *c,
194+ const pa_sink_input_info *info,
195+ int eol,
196+ void *userdata)
197+{
198+ if (info == NULL)
199+ {
200+ g_warning("hotplug_callback, info == NULL");
201+ return;
202+ }
203+
204+ printf("sink input info: %i Client: %i and sink index %i\n", info->index, info->client, info->sink);
205+}
206+
207+void pm_ext_stream_restore_read_callback(pa_context *c,const pa_ext_stream_restore_info *info,int eol,void *userdata)
208+{
209+ // this callback gets a "pa_ext_stream_restore_info" pointer, which
210+ // corresponds to a stream's info.
211+
212+ return;
213+
214+ if (eol)
215+ {
216+ // end of list, just return, we've had all entries in the database,
217+ // this is final calling of the CB is to signal end-of-database
218+ return;
219+ }
220+
221+ if ( info == NULL )
222+ {
223+ g_warning("pm_ext_stream_restore_read_callback: info == NULL");
224+ return;
225+ }
226+
227+ printf("Id: %i\tName: %s\tDevice: %s\n", eol, info->name, info->device);
228+
229+}
230+
231+static void pm_ext_stream_restore_action_callback(pa_context *c, void *userdata)
232+{
233+ // this callback gets called once per sink / source, when a stream_restore
234+ // action occurs.
235+ //
236+ // Example: user plugs in a *previously used* soundcard, and this
237+ // callback will be called one time per active port in the graph.
238+ //
239+ // Note: If an internal card is default, and a external card gets
240+ // plugged out, this callback will *not* be called.
241+
242+ printf("Stream Restore Action!\n");
243+
244+}
245+
246+static void pm_ext_stream_restore_subscribe_callback(pa_context *c, int success, void *userdata)
247+{
248+ printf("Subscribed to changes in stream database? %i\n",success);
249+}
250
251 static void
252 pm_subscribed_events_callback (pa_context *c,
253@@ -257,6 +395,7 @@
254 return;
255 }
256 Device* sink = DEVICE (userdata);
257+<<<<<<< TREE
258
259 switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
260 case PA_SUBSCRIPTION_EVENT_SINK:
261@@ -287,9 +426,101 @@
262 }
263 else{
264 pa_operation_unref (pa_context_get_source_info_by_index (c,
265+=======
266+
267+
268+ switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK)
269+ {
270+
271+ case PA_SUBSCRIPTION_EVENT_SINK:
272+ // g_debug("SUBSCRIPTION_EVENT_SINK");
273+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW){
274+ g_debug("NEW Event of sink %i", index);
275+ }
276+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE){
277+ g_debug("REMOVE Event of sink %i", index);
278+ }
279+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE){
280+ g_debug("CHANGE Event Change of sink %i", index);
281+ }
282+
283+ break;
284+
285+ case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
286+ printf("SINK INPUT");
287+
288+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW)
289+ {
290+ // get info:
291+ pa_operation_unref (pa_context_get_sink_input_info (c,
292+ index,
293+ pm_sink_input_info_hotplug_callback,
294+ userdata));
295+ }
296+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
297+ {
298+ printf(" REMOVE");
299+ pa_operation_unref (pa_context_get_sink_input_info (c,
300+ index,
301+ pm_sink_input_info_hotplug_callback,
302+ userdata));
303+ }
304+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE)
305+ {
306+ printf(" CHANGE");
307+ pa_operation_unref (pa_context_get_sink_input_info (c,
308+ index,
309+ pm_sink_input_info_hotplug_callback,
310+ userdata));
311+ }
312+ printf("\n");
313+ break;
314+
315+ }
316+
317+ /*
318+ *
319+ * ./// never triggers?
320+ * case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
321+ g_debug("SINK INPUT");
322+
323+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW)
324+ {
325+ g_debug("SINK INPUT: NEW");
326+ }
327+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
328+ {
329+ g_debug("SINK INPUT: REMOVE");
330+ }
331+ break;
332+ *
333+ *
334+ *
335+ *
336+ *
337+ *
338+ switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK)
339+ {
340+ case PA_SUBSCRIPTION_EVENT_SINK:
341+
342+ // We don't care about any other sink other than the active one.
343+ if (index != device_get_sink_index (sink))
344+ {
345+ g_debug("Sink event != current sink");
346+ //return;
347+ }
348+
349+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
350+ g_debug("Remove Event of sink %i", index);
351+ device_sink_deactivated (sink);
352+ }
353+ else{
354+ pa_operation_unref (pa_context_get_sink_info_by_index (c,
355+>>>>>>> MERGE-SOURCE
356 index,
357- pm_update_source_info_callback,
358+ pm_update_device,
359 userdata) );
360+<<<<<<< TREE
361 }
362 break;
363 case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
364@@ -341,24 +572,115 @@
365 //g_debug ("some new source output event ? - index = %i", index);
366 // Determine if its a VOIP app.
367 pa_operation_unref (pa_context_get_source_output_info (c,
368+=======
369+ }
370+ break;
371+
372+
373+ case PA_SUBSCRIPTION_EVENT_SOURCE:
374+ g_debug ("Looks like source event of some description - index = %i", index);
375+ // We don't care about any other sink other than the active one.
376+ if (index != device_get_source_index (sink))
377+ {
378+ g_debug("Source event != current Source");
379+ //return;
380+ }
381+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE)
382+ {
383+ g_debug ("Source removal event - index = %i", index);
384+ device_deactivate_voip_source (sink, FALSE);
385+ }
386+ else
387+ {
388+ pa_operation_unref (pa_context_get_source_info_by_index (c,
389+ index,
390+ pm_update_source_info_callback,
391+ userdata) );
392+ }
393+ break;
394+
395+
396+ case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
397+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
398+ g_debug("PA - Event New - Mask");
399+
400+ // determine input client // get sync info callback on own fX
401+ //
402+ //
403+
404+ }
405+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
406+ g_debug("PA - Event Remove - Mask");
407+ }
408+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_AUTOLOAD) {
409+ g_debug("PA - Event AutoLoad - Mask");
410+ }
411+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE) {
412+ g_debug("PA - Event Change - Mask");
413+
414+ }
415+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CLIENT) {
416+ g_debug("PA - Event Client - Mask");
417+ }
418+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_MODULE) {
419+ g_debug("PA - Event Module - Mask");
420+ }
421+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE) {
422+ g_debug("PA - Event Sample Cache - Mask");
423+ }
424+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_SINK) {
425+ g_debug("PA - Event Server - Mask");
426+ }
427+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_SERVER) {
428+ g_debug("PA - Event Server - Mask");
429+ }
430+ else {
431+ g_debug("PA - SUBSCRIPTION_EVENT_SOURCE unknown type! ");
432+ }
433+ // Maybe blocking state ?.
434+ pa_operation_unref (pa_context_get_sink_input_info (c,
435+>>>>>>> MERGE-SOURCE
436 index,
437- pm_source_output_info_callback, userdata));
438- }
439- break;
440- case PA_SUBSCRIPTION_EVENT_SERVER:
441- g_debug("PA_SUBSCRIPTION_EVENT_SERVER event triggered.");
442- pa_operation *o;
443- if (!(o = pa_context_get_server_info (c, pm_server_info_callback, userdata))) {
444- g_warning("subscribed_events_callback - pa_context_get_server_info() failed");
445- return;
446- }
447- pa_operation_unref(o);
448- break;
449+ pm_sink_input_info_callback, userdata));
450+ break;
451+
452+
453+ case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT:
454+ g_debug ("source output event");
455+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
456+ gint cached_source_output_index = device_get_voip_source_output_index (sink);
457+ if (index == cached_source_output_index){
458+ g_debug ("Just saw a source output removal event - index = %i and cached index = %i", index, cached_source_output_index);
459+ device_deactivate_voip_client (sink);
460+ }
461+ }
462+ else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
463+ g_debug ("some new source output event ? - index = %i", index);
464+ // Determine if its a VOIP app.
465+ pa_operation_unref (pa_context_get_source_output_info (c,
466+ index,
467+ pm_source_output_info_callback, userdata));
468+ }
469+ break;
470+
471+
472+ case PA_SUBSCRIPTION_EVENT_SERVER:
473+ g_debug("PA_SUBSCRIPTION_EVENT_SERVER event triggered.");
474+ pa_operation *o;
475+ if (!(o = pa_context_get_server_info (c, pm_server_info_callback, userdata))) {
476+ g_warning("subscribed_events_callback - pa_context_get_server_info() failed");
477+ return;
478+ }
479+ pa_operation_unref(o);
480+ break;
481+
482 }
483+ */
484 }
485
486
487
488+
489 static void
490 pm_context_state_callback (pa_context *c, void *userdata)
491 {
492@@ -397,26 +719,34 @@
493 pa_operation *o;
494
495 pa_context_set_subscribe_callback(c, pm_subscribed_events_callback, userdata);
496+
497+ pa_operation_unref( pa_ext_stream_restore_test (c,
498+ pm_ext_stream_restore_test_callback,
499+ NULL) );
500
501- if (!(o = pa_context_subscribe (c, (pa_subscription_mask_t)
502+ if (!(o = pa_context_subscribe (c,
503+ (pa_subscription_mask_t)
504 (PA_SUBSCRIPTION_MASK_SINK|
505 PA_SUBSCRIPTION_MASK_SOURCE|
506- PA_SUBSCRIPTION_MASK_SINK_INPUT|
507- PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT|
508- PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) {
509+ PA_SUBSCRIPTION_MASK_SINK_INPUT),
510+ NULL, NULL))) {
511 g_warning("pa_context_subscribe() failed");
512-
513 }
514
515 if (!(o = pa_context_get_server_info (c, pm_server_info_callback, userdata))) {
516 g_warning("Initial - pa_context_get_server_info() failed");
517 }
518 pa_operation_unref(o);
519+<<<<<<< TREE
520
521 // request a list of info on sink inputs, to store them in the client->sink hashtable
522 pa_context_get_sink_input_info_list(c,
523 pm_sink_input_info_store_callback,
524 NULL);
525+=======
526+
527+
528+>>>>>>> MERGE-SOURCE
529
530 break;
531 }
532@@ -433,26 +763,46 @@
533 void *userdata)
534 {
535 pa_operation *operation;
536+<<<<<<< TREE
537 //g_debug ("server info callback");
538+=======
539+ printf ("server info callback:\n\t");
540+>>>>>>> MERGE-SOURCE
541
542 if (info == NULL) {
543 g_warning("No PA server - get the hell out of here");
544 device_sink_deactivated (DEVICE (userdata));
545 return;
546 }
547+
548+
549 // Go for the default sink
550+<<<<<<< TREE
551 if (info->default_sink_name != NULL) {
552 //g_debug ("default sink name from the server ain't null'");
553 if (!(operation = pa_context_get_sink_info_by_name (c,
554+=======
555+ if (info->default_sink_name != NULL)
556+ {
557+ printf ("default sink name: %s\n", info->default_sink_name );
558+ pm_default_sink_name = info->default_sink_name;
559+
560+
561+ if ( !(operation = pa_context_get_sink_info_by_name (c,
562+>>>>>>> MERGE-SOURCE
563 info->default_sink_name,
564 pm_default_sink_info_callback,
565- userdata) )) {
566+ userdata) )
567+ )
568+ {
569 g_warning("pa_context_get_sink_info_by_namet() failed");
570 device_sink_deactivated (DEVICE (userdata));
571 pa_operation_unref(operation);
572 return;
573 }
574- } // If there is no default sink, try to determine a sink from the list of sinks
575+ }
576+
577+ // If there is no default sink, try to determine a sink from the list of sinks
578 else if (!(operation = pa_context_get_sink_info_list(c,
579 pm_sink_info_callback,
580 userdata))) {
581@@ -461,9 +811,16 @@
582 pa_operation_unref(operation);
583 return;
584 }
585+
586+
587+
588 // And the source
589 if (info->default_source_name != NULL) {
590+<<<<<<< TREE
591 //g_debug ("default source name from the server is not null'");
592+=======
593+ g_debug ("default source name from server: %s", info->default_source_name);
594+>>>>>>> MERGE-SOURCE
595 if (!(operation = pa_context_get_source_info_by_name (c,
596 info->default_source_name,
597 pm_default_source_info_callback,
598@@ -481,6 +838,8 @@
599 // TODO: call some input deactivate method for the source
600 }
601 pa_operation_unref(operation);
602+
603+ printf ("\n");
604 }
605
606 static void pm_get_client_name_callback(pa_context *c,
607@@ -554,6 +913,13 @@
608 int eol,
609 void* userdata)
610 {
611+ printf("sink_info_callback() ");
612+ if (sink != NULL)
613+ printf("name: %s",sink->name);
614+
615+ printf("\n");
616+
617+
618 if (eol > 0) {
619 return;
620 }
621@@ -578,14 +944,25 @@
622 int eol,
623 void *userdata)
624 {
625+ g_debug("Default sink info callback");
626+
627 if (eol > 0) {
628 return;
629 }
630- else {
631+ else
632+ {
633 if (IS_DEVICE (userdata) == FALSE || info == NULL){
634 g_warning ("Default sink info callback - our user data is not what we think it should be or the info parameter is null");
635 return;
636 }
637+
638+ g_debug("Current default sink name:");
639+ g_debug( pm_default_sink_name);
640+ g_debug("New default sink name:");
641+ g_debug( info->name );
642+
643+ pm_default_sink_name = info->name;
644+
645 // Only repopulate if there is a change with regards the index
646 if (device_get_sink_index (DEVICE (userdata)) == info->index)
647 return;
648@@ -775,6 +1152,8 @@
649 int eol,
650 void *userdata)
651 {
652+ g_debug("SourceOutputInfoCallback");
653+
654 if (eol > 0) {
655 return;
656 }
657@@ -814,10 +1193,19 @@
658 return;
659 }
660 else{
661- if (IS_DEVICE (userdata) == FALSE || info == NULL){
662- g_warning ("update_device - our user data is not what we think it should be or the info parameter is null");
663- return;
664- }
665+ if (IS_DEVICE (userdata) == FALSE )
666+ {
667+ g_warning ("Update device:source info update callback - our user data is not what we think it should be");
668+ return;
669+ }
670+ else if ( info == NULL )
671+ {
672+ g_warning ( "Update device: source info paramter is null" );
673+ return;
674+ }
675+
676+ // maths converts from uint32_t to 0->1 float, and range scales from that to 0 - 150 %
677+ //g_debug("Updating device with %f percent volume", (pa_cvolume_avg( &info->volume ) / 983.04f) * 6/4.f );
678 device_sink_update (DEVICE(userdata), info);
679 }
680 }
681@@ -828,6 +1216,7 @@
682 int eol,
683 void* userdata)
684 {
685+ g_debug("toggle_mute_for_every_sink_callback");
686 if (eol > 0) {
687 return;
688 }
689@@ -851,18 +1240,47 @@
690 int eol,
691 void *userdata)
692 {
693- if (eol > 0) {
694+ g_debug("default_source_info_callback");
695+ if (eol > 0)
696+ {
697 return;
698 }
699 else {
700- if (IS_DEVICE (userdata) == FALSE || info == NULL){
701- g_warning ("Default source info callback - our user data is not what we think it should be or the source info parameter is null");
702- return;
703- }
704+ if (IS_DEVICE (userdata) == FALSE)
705+ {
706+ g_warning ("Default source info callback - our user data is not what we think it should be");
707+ return;
708+ }
709+ else if ( info == NULL )
710+ {
711+ g_warning ("source info parameter is null");
712+ return;
713+ }
714+
715 // If there is an index change we need to change our cached source
716 if (device_get_source_index (DEVICE (userdata)) == info->index)
717 return;
718- g_debug ("Pulse Server has handed us a new default source");
719+
720+ pm_default_source_name = info->name;
721+
722+ printf ("Pulse Server has handed us a new default source: %s\n", pm_default_source_name);
723+
724+ // <ME> <MoveCode> out of the pulseaudio mgr into more suitable place
725+ // notify of new default source:
726+ NotifyNotification *not;
727+
728+ not = notify_notification_new ( "New Default Output",
729+ info->name,
730+ NULL);
731+
732+ notify_notification_set_timeout (not, 3000);
733+
734+ if (!notify_notification_show(not, NULL)) {
735+ g_debug("Notification sending failed");
736+ }
737+ g_object_unref(G_OBJECT(not));
738+ // </MoveCode>
739+
740 device_deactivate_voip_source (DEVICE (userdata), TRUE);
741 device_update_voip_input_source (DEVICE (userdata), info);
742 }
743@@ -874,6 +1292,8 @@
744 int eol,
745 void *userdata)
746 {
747+ g_debug("source_info_callback");
748+
749 if (eol > 0) {
750 return;
751 }
752@@ -895,15 +1315,26 @@
753 int eol,
754 void *userdata)
755 {
756+ g_debug("update_source_info_callback");
757 if (eol > 0) {
758 return;
759 }
760 else {
761- if (IS_DEVICE (userdata) == FALSE || info == NULL ){
762- g_warning ("source info update callback - our user data is not what we think it should be or the source info paramter is null");
763- return;
764- }
765- g_debug ("Got a source update for %s , index %i", info->name, info->index);
766+ if (IS_DEVICE (userdata) == FALSE )
767+ {
768+ g_warning ("Update source Callback:source info update callback - our user data is not what we think it should be");
769+ return;
770+ }
771+ else if ( info == NULL )
772+ {
773+ g_warning ( "update source Callback: source info paramter is null" );
774+ return;
775+ }
776+
777+ // this function gets called when things *sources* change, so when
778+ // a new player connects / disconnects this will trigger
779+
780+ g_debug ("Got a source update for index %i, name %s", info->index, info->name);
781 device_update_voip_input_source (DEVICE (userdata), info);
782 }
783 }
784
785=== modified file 'src/pulseaudio-mgr.h'
786--- src/pulseaudio-mgr.h 2011-03-14 19:47:59 +0000
787+++ src/pulseaudio-mgr.h 2011-06-28 13:12:52 +0000
788@@ -30,4 +30,3 @@
789
790
791
792-

Subscribers

People subscribed via source and target branches

to all changes: