aboutsummaryrefslogtreecommitdiff
path: root/src/pulseaudio-mgr.c
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2011-03-04 13:38:16 -0500
committerKen VanDine <ken.vandine@canonical.com>2011-03-04 13:38:16 -0500
commitf2b815cf615ba4532a7e04254ddb4acd1bbb75ff (patch)
treeeda29e8b8c389b0c06148337f56d58b65da97591 /src/pulseaudio-mgr.c
parent4eea1b645a81b5fa99963b3d9c8353a545b68232 (diff)
parent73772e6ea7f0ca55bd3df65a031ddb48fba66104 (diff)
downloadayatana-indicator-sound-f2b815cf615ba4532a7e04254ddb4acd1bbb75ff.tar.gz
ayatana-indicator-sound-f2b815cf615ba4532a7e04254ddb4acd1bbb75ff.tar.bz2
ayatana-indicator-sound-f2b815cf615ba4532a7e04254ddb4acd1bbb75ff.zip
releasing version 0.6.2-0ubuntu1
Diffstat (limited to 'src/pulseaudio-mgr.c')
-rw-r--r--src/pulseaudio-mgr.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index 76102e4..6d11221 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -31,6 +31,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <pulse/error.h>
#include "pulseaudio-mgr.h"
+#include "config.h"
#define RECONNECT_DELAY 5
@@ -116,24 +117,44 @@ Method which connects to the pulse server and is used to track reconnects.
static gboolean
reconnect_to_pulse (gpointer user_data)
{
- g_debug("Attempt to reconnect to pulse");
+ g_debug("Attempt a pulse connection");
// reset
+ g_return_val_if_fail (IS_ACTIVE_SINK (user_data), FALSE);
+
connection_attempts += 1;
if (pulse_context != NULL) {
pa_context_unref(pulse_context);
pulse_context = NULL;
}
- pulse_context = pa_context_new( pa_glib_mainloop_get_api( pa_main_loop ),
- "com.canonical.indicators.sound" );
+ pa_proplist *proplist;
+
+ proplist = pa_proplist_new ();
+ pa_proplist_sets (proplist,
+ PA_PROP_APPLICATION_NAME,
+ "Indicator Sound");
+ pa_proplist_sets (proplist,
+ PA_PROP_APPLICATION_ID,
+ "com.canonical.indicators.sound");
+ pa_proplist_sets (proplist,
+ PA_PROP_APPLICATION_ICON_NAME,
+ "multimedia-volume-control");
+ pa_proplist_sets (proplist,
+ PA_PROP_APPLICATION_VERSION,
+ PACKAGE_VERSION);
+
+ pulse_context = pa_context_new_with_proplist (pa_glib_mainloop_get_api( pa_main_loop ),
+ NULL,
+ proplist);
+ pa_proplist_free (proplist);
g_assert(pulse_context);
pa_context_set_state_callback (pulse_context,
pm_context_state_callback,
user_data);
int result = pa_context_connect (pulse_context,
NULL,
- PA_CONTEXT_NOFAIL,
- user_data);
+ (pa_context_flags_t)PA_CONTEXT_NOFAIL,
+ NULL);
if (result < 0) {
g_warning ("Failed to connect context: %s",
@@ -220,11 +241,12 @@ pm_subscribed_events_callback (pa_context *c,
}
break;
case PA_SUBSCRIPTION_EVENT_SOURCE:
- g_debug ("Looks like source event of some description");
+ g_debug ("Looks like source event of some description - index = %i", index);
// We don't care about any other sink other than the active one.
if (index != active_sink_get_source_index (sink))
return;
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
+ g_debug ("Source removal event - index = %i", index);
active_sink_deactivate_voip_source (sink, FALSE);
}
else{
@@ -279,8 +301,10 @@ pm_context_state_callback (pa_context *c, void *userdata)
g_debug("connecting - waiting for the server to become available");
break;
case PA_CONTEXT_AUTHORIZING:
+ g_debug ("Authorizing");
break;
case PA_CONTEXT_SETTING_NAME:
+ g_debug ("Setting name");
break;
case PA_CONTEXT_FAILED:
g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?");
@@ -288,10 +312,11 @@ pm_context_state_callback (pa_context *c, void *userdata)
if (reconnect_idle_id == 0){
reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY,
reconnect_to_pulse,
- userdata);
+ (gpointer)userdata);
}
break;
case PA_CONTEXT_TERMINATED:
+ g_debug ("Terminated");
break;
case PA_CONTEXT_READY:
connection_attempts = 0;
@@ -396,8 +421,8 @@ pm_sink_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE){
- g_warning ("sink info callback - our user data is not what we think it should be");
+ if (IS_ACTIVE_SINK (userdata) == FALSE || sink == NULL){
+ g_warning ("sink info callback - our user data is not what we think it should be or the sink parameter is null");
return;
}
ActiveSink* a_sink = ACTIVE_SINK (userdata);
@@ -418,8 +443,8 @@ pm_default_sink_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE){
- g_warning ("Default sink info callback - our user data is not what we think it should be");
+ if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
+ g_warning ("Default sink info callback - our user data is not what we think it should be or the info parameter is null");
return;
}
// Only repopulate if there is a change with regards the index
@@ -441,9 +466,8 @@ pm_sink_input_info_callback (pa_context *c,
return;
}
else {
- if (info == NULL) {
- // TODO: watch this carefully - PA async api should not be doing this . . .
- g_warning("\n Sink input info callback : SINK INPUT INFO IS NULL BUT EOL was not POSITIVE!!!");
+ if (info == NULL || IS_ACTIVE_SINK (userdata) == FALSE) {
+ g_warning("Sink input info callback : SINK INPUT INFO IS NULL or our user_data is not what we think it should be");
return;
}
@@ -486,8 +510,8 @@ pm_update_active_sink (pa_context *c,
return;
}
else{
- if (IS_ACTIVE_SINK (userdata) == FALSE){
- g_warning ("update_active_sink - our user data is not what we think it should be");
+ if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
+ g_warning ("update_active_sink - our user data is not what we think it should be or the info parameter is null");
return;
}
active_sink_update (ACTIVE_SINK(userdata), info);
@@ -504,6 +528,10 @@ pm_toggle_mute_for_every_sink_callback (pa_context *c,
return;
}
else {
+ if (sink == NULL) {
+ g_warning ("toggle_mute cb - sink parameter is null - why ?");
+ return;
+ }
pa_operation_unref (pa_context_set_sink_mute_by_index (c,
sink->index,
GPOINTER_TO_INT(userdata),
@@ -523,8 +551,8 @@ pm_default_source_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE){
- g_warning ("Default sink info callback - our user data is not what we think it should be");
+ if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
+ g_warning ("Default source info callback - our user data is not what we think it should be or the source info parameter is null");
return;
}
// If there is an index change we need to change our cached source
@@ -546,8 +574,8 @@ pm_source_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE){
- g_warning ("Default sink info callback - our user data is not what we think it should be");
+ if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL){
+ g_warning ("source info callback - our user data is not what we think it should be or the source info parameter is null");
return;
}
// For now we will take the first available
@@ -567,11 +595,11 @@ pm_update_source_info_callback (pa_context *c,
return;
}
else {
- if (IS_ACTIVE_SINK (userdata) == FALSE){
- g_warning ("Default sink info callback - our user data is not what we think it should be");
+ if (IS_ACTIVE_SINK (userdata) == FALSE || info == NULL ){
+ g_warning ("source info update callback - our user data is not what we think it should be or the source info paramter is null");
return;
}
g_debug ("Got a source update for %s , index %i", info->name, info->index);
active_sink_update_voip_input_source (ACTIVE_SINK (userdata), info);
}
-} \ No newline at end of file
+}