diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/metadata-widget.c | 2 | ||||
-rw-r--r-- | src/mpris2-controller.vala | 3 | ||||
-rw-r--r-- | src/mpris2-interfaces.vala | 12 | ||||
-rw-r--r-- | src/pulseaudio-mgr.c | 112 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 34 |
5 files changed, 116 insertions, 47 deletions
diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 36b48f8..597c12c 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -229,7 +229,7 @@ metadata_widget_init (MetadataWidget *self) GtkWidget* player_label; player_label = gtk_label_new (""); gtk_misc_set_alignment(GTK_MISC(player_label), (gfloat)0, (gfloat)0); - gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)0); + gtk_misc_set_padding (GTK_MISC(player_label), (gfloat)1, (gfloat)4); gtk_widget_set_size_request (player_label, 150, 24); priv->player_label = player_label; 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; diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 5650002..07d3d6f 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -58,6 +58,7 @@ struct _SoundServiceDbusPrivate { DbusmenuMenuitem* root_menuitem; Device* device; gboolean greeter_mode; + guint registration_id; }; enum { @@ -155,18 +156,18 @@ sound_service_dbus_init (SoundServiceDbus *self) return; } /* register the service on it */ - g_dbus_connection_register_object (priv->connection, - INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, - interface_info, - &interface_table, - self, - NULL, - &error); - if (error != NULL) { - g_error("Unable to register the object to DBus: %s", error->message); - g_error_free(error); - return; - } + priv->registration_id = g_dbus_connection_register_object (priv->connection, + INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH, + interface_info, + &interface_table, + self, + NULL, + &error); + if (error != NULL) { + g_error("Unable to register the object to DBus: %s", error->message); + g_error_free(error); + return; + } } DbusmenuMenuitem* @@ -239,6 +240,15 @@ show_sound_settings_dialog (DbusmenuMenuitem *mi, static void sound_service_dbus_dispose (GObject *object) { + SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (object); + + if (priv->connection && priv->registration_id) { + g_dbus_connection_unregister_object (priv->connection, priv->registration_id); + priv->registration_id = 0; + } + + g_clear_object(&priv->connection); + G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object); //TODO dispose of the active sink instance ! return; |