aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2012-03-01 17:03:50 +0000
committerConor Curran <conor.curran@canonical.com>2012-03-01 17:03:50 +0000
commitff0714ee715436df3be294873b04b8ed298fe2cf (patch)
treea78f1df73dfa5fbb15bcc4ca29c08de9aab02da0 /src
parentffc2f69f9405ecdb19713bbeda8ff6ae0ee99e6f (diff)
parent40837488c4fa94e96cdfefae65020e2b443e46f5 (diff)
downloadayatana-indicator-sound-ff0714ee715436df3be294873b04b8ed298fe2cf.tar.gz
ayatana-indicator-sound-ff0714ee715436df3be294873b04b8ed298fe2cf.tar.bz2
ayatana-indicator-sound-ff0714ee715436df3be294873b04b8ed298fe2cf.zip
play it safe branch
Diffstat (limited to 'src')
-rw-r--r--src/mpris2-controller.vala3
-rw-r--r--src/mpris2-interfaces.vala12
-rw-r--r--src/pulseaudio-mgr.c112
3 files changed, 93 insertions, 34 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index cc80a86..0fa7b6c 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -248,8 +248,7 @@ public class Mpris2Controller : GLib.Object
private bool fetch_active_playlist()
{
if (this.playlists.ActivePlaylist.valid == false){
- // TODO
- // What happens here ?
+ return false;
}
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details );
diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala
index 5dab1d2..ee86c2b 100644
--- a/src/mpris2-interfaces.vala
+++ b/src/mpris2-interfaces.vala
@@ -49,15 +49,15 @@ public interface MprisPlayer : Object {
// Playlist container
public struct PlaylistDetails{
- public ObjectPath path;
- public string name;
- public string icon_path;
+ public ObjectPath? path;
+ public string? name;
+ public string? icon_path;
}
// Active playlist property container
public struct ActivePlaylistContainer{
public bool valid;
- public PlaylistDetails details;
+ public PlaylistDetails? details;
}
[DBus (name = "org.mpris.MediaPlayer2.Playlists")]
@@ -69,11 +69,11 @@ public interface MprisPlaylists : Object {
//methods
public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError;
- public abstract async PlaylistDetails[] GetPlaylists ( uint32 index,
+ public abstract async PlaylistDetails[]? GetPlaylists ( int32 index,
uint32 max_count,
string order,
bool reverse_order ) throws IOError;
//signals
public signal void PlaylistChanged (PlaylistDetails details);
-} \ No newline at end of file
+}
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index 3a80cbd..fee504e 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -121,7 +121,6 @@ static gboolean
reconnect_to_pulse (gpointer user_data)
{
g_debug("Attempt a pulse connection");
- // reset
g_return_val_if_fail (IS_DEVICE (user_data), FALSE);
connection_attempts += 1;
@@ -175,50 +174,107 @@ void
pm_update_volume (gint sink_index, pa_cvolume new_volume)
{
if (sink_index < 0 || pulse_context == NULL){
+ g_warning ("pm_update_volume sink index is negative or the context is null");
return;
}
- pa_operation_unref (pa_context_set_sink_volume_by_index (pulse_context,
- sink_index,
- &new_volume,
- NULL,
- NULL) );
+
+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
+ g_warning ("pm_update_volume context is not in a ready state");
+ return;
+ }
+
+ pa_operation *operation = NULL;
+
+ operation = pa_context_set_sink_volume_by_index (pulse_context,
+ sink_index,
+ &new_volume,
+ NULL,
+ NULL);
+ if (!operation){
+ g_warning ("pm_update_volume operation failed for some reason");
+ return;
+ }
+ pa_operation_unref (operation);
}
void
pm_update_mute (gboolean update)
{
- pa_operation_unref (pa_context_get_sink_info_list (pulse_context,
- pm_toggle_mute_for_every_sink_callback,
- GINT_TO_POINTER (update)));
+ if (pulse_context == NULL){
+ g_warning ("pm_update_mute - the context is null");
+ return;
+ }
+
+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
+ g_warning ("pm_update_mute context is not in a ready state");
+ return;
+ }
+
+ pa_operation *operation = NULL;
+
+ operation = pa_context_get_sink_info_list (pulse_context,
+ pm_toggle_mute_for_every_sink_callback,
+ GINT_TO_POINTER (update));
+ if (!operation){
+ g_warning ("pm_update_mute operation failed for some reason");
+ return;
+ }
+ pa_operation_unref (operation);
}
void
pm_update_mic_gain (gint source_index, pa_cvolume new_gain)
{
- // LP: #850662
if (source_index < 0 || pulse_context == NULL){
+ g_warning ("pm_update_mic_gain source index is negative or the context is null");
+ return;
+ }
+
+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
+ g_warning ("pm_update_mic_gain context is not in a ready state");
+ return;
+ }
+
+ pa_operation *operation = NULL;
+
+ operation = pa_context_set_source_volume_by_index (pulse_context,
+ source_index,
+ &new_gain,
+ NULL,
+ NULL);
+ if (!operation){
+ g_warning ("pm_update_mic_gain operation failed for some reason");
return;
}
- pa_operation_unref (pa_context_set_source_volume_by_index (pulse_context,
- source_index,
- &new_gain,
- NULL,
- NULL) );
+ pa_operation_unref (operation);
}
void
pm_update_mic_mute (gint source_index, gint mute_update)
{
- // LP: #850662
- if (source_index < 0){
- return;
- }
- pa_operation_unref (pa_context_set_source_mute_by_index (pulse_context,
- source_index,
- mute_update,
- NULL,
- NULL));
+ if (source_index < 0){
+ return;
+ }
+
+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
+ g_warning ("pm_update_mic_mute context is not in a ready state");
+ return;
+ }
+
+ pa_operation *operation = NULL;
+
+ operation = pa_context_set_source_mute_by_index (pulse_context,
+ source_index,
+ mute_update,
+ NULL,
+ NULL);
+ if (!operation){
+ g_warning ("pm_update_mic_mute operation failed for some reason");
+ return;
+ }
+ pa_operation_unref (operation);
}
+
/**********************************************************************************************************************/
// Pulse-Audio asychronous call-backs
/**********************************************************************************************************************/
@@ -308,8 +364,6 @@ pm_subscribed_events_callback (pa_context *c,
}
}
-
-
static void
pm_context_state_callback (pa_context *c, void *userdata)
{
@@ -337,6 +391,12 @@ pm_context_state_callback (pa_context *c, void *userdata)
break;
case PA_CONTEXT_TERMINATED:
g_debug ("Terminated");
+ device_sink_deactivated (DEVICE (userdata));
+
+ if (reconnect_idle_id != 0){
+ g_source_remove (reconnect_idle_id);
+ reconnect_idle_id = 0;
+ }
break;
case PA_CONTEXT_READY:
connection_attempts = 0;