[gnome-settings-daemon] media-keys: Postpone initialisation of libcanberra
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] media-keys: Postpone initialisation of libcanberra
- Date: Mon, 1 Sep 2014 12:30:48 +0000 (UTC)
commit 2f6f42f1e1283b5bf61613368f54f1fd84806e94
Author: Bastien Nocera <hadess hadess net>
Date: Mon Sep 1 01:27:50 2014 +0200
media-keys: Postpone initialisation of libcanberra
It's possible for gnome-settings-daemon to block for the initialisation
of PulseAudio on startup, especially as some of PulseAudio's
enumerations could take a while.
Instead of initialising libcanberra on startup, initialise it when we're
actually going to use it the first time. Given that this happens in a
volume media key handling function, there's a good chance that
PulseAudio will already be initialised at that point.
See https://bugzilla.gnome.org/show_bug.cgi?id=645756#c3
https://bugzilla.gnome.org/show_bug.cgi?id=735777
plugins/media-keys/gsd-media-keys-manager.c | 39 ++++++++++++++++-----------
1 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index c0891da..d818bf8 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -977,6 +977,28 @@ do_lock_screensaver (GsdMediaKeysManager *manager)
}
static void
+ensure_canberra (GsdMediaKeysManager *manager)
+{
+ char *theme_name;
+
+ if (manager->priv->ca != NULL)
+ return;
+
+ ca_context_create (&manager->priv->ca);
+ ca_context_set_driver (manager->priv->ca, "pulse");
+ ca_context_change_props (manager->priv->ca, 0,
+ CA_PROP_APPLICATION_ID, "org.gnome.VolumeControl",
+ NULL);
+ manager->priv->gtksettings = gtk_settings_get_for_screen (gdk_screen_get_default ());
+ g_object_get (G_OBJECT (manager->priv->gtksettings), "gtk-sound-theme-name", &theme_name, NULL);
+ if (theme_name)
+ ca_context_change_props (manager->priv->ca, CA_PROP_CANBERRA_XDG_THEME_NAME, theme_name,
NULL);
+ g_free (theme_name);
+ g_signal_connect (manager->priv->gtksettings, "notify::gtk-sound-theme-name",
+ G_CALLBACK (sound_theme_changed), manager);
+}
+
+static void
update_dialog (GsdMediaKeysManager *manager,
GvcMixerStream *stream,
guint vol,
@@ -1009,6 +1031,7 @@ update_dialog (GsdMediaKeysManager *manager,
}
if (quiet == FALSE && sound_changed != FALSE && muted == FALSE) {
+ ensure_canberra (manager);
ca_context_change_device (manager->priv->ca,
gvc_mixer_stream_get_name (stream));
ca_context_play (manager->priv->ca, 1,
@@ -2299,8 +2322,6 @@ shell_presence_changed (GsdMediaKeysManager *manager)
static gboolean
start_media_keys_idle_cb (GsdMediaKeysManager *manager)
{
- char *theme_name;
-
g_debug ("Starting media_keys manager");
gnome_settings_profile_start (NULL);
@@ -2318,20 +2339,6 @@ start_media_keys_idle_cb (GsdMediaKeysManager *manager)
g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
- /* Sound events */
- ca_context_create (&manager->priv->ca);
- ca_context_set_driver (manager->priv->ca, "pulse");
- ca_context_change_props (manager->priv->ca, 0,
- CA_PROP_APPLICATION_ID, "org.gnome.VolumeControl",
- NULL);
- manager->priv->gtksettings = gtk_settings_get_for_screen (gdk_screen_get_default ());
- g_object_get (G_OBJECT (manager->priv->gtksettings), "gtk-sound-theme-name", &theme_name, NULL);
- if (theme_name)
- ca_context_change_props (manager->priv->ca, CA_PROP_CANBERRA_XDG_THEME_NAME, theme_name,
NULL);
- g_free (theme_name);
- g_signal_connect (manager->priv->gtksettings, "notify::gtk-sound-theme-name",
- G_CALLBACK (sound_theme_changed), manager);
-
/* for the power plugin interface code */
manager->priv->power_settings = g_settings_new (SETTINGS_POWER_DIR);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]