gnome-settings-daemon r182 - in trunk: . plugins/sound
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r182 - in trunk: . plugins/sound
- Date: Thu, 28 Feb 2008 18:15:29 +0000 (GMT)
Author: hadess
Date: Thu Feb 28 18:15:28 2008
New Revision: 182
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=182&view=rev
Log:
2008-02-28 Bastien Nocera <hadess hadess net>
* plugins/sound/gsd-sound-manager.c (reset_esd_pid),
(start_gnome_sound), (stop_gnome_sound), (apply_settings),
(gsd_sound_manager_stop): Start the sound server ourselves,
as we need it to cache samples. If esd (or the PulseAudio
esd compat bits) isn't available, just print an error, and
don't try to cache the samples
If you use PulseAudio instead of esound in your distribution,
build with --disable-esd passed to configure
(Closes: #518075)
Modified:
trunk/ChangeLog
trunk/plugins/sound/gsd-sound-manager.c
Modified: trunk/plugins/sound/gsd-sound-manager.c
==============================================================================
--- trunk/plugins/sound/gsd-sound-manager.c (original)
+++ trunk/plugins/sound/gsd-sound-manager.c Thu Feb 28 18:15:28 2008
@@ -54,6 +54,8 @@
struct GsdSoundManagerPrivate
{
gboolean padding;
+ /* esd/PulseAudio pid */
+ GPid pid;
};
enum {
@@ -68,18 +70,46 @@
static gpointer manager_object = NULL;
+static void
+reset_esd_pid (GPid pid, gint status, gpointer user_data)
+{
+ GsdSoundManager *manager = (GsdSoundManager *) user_data;
+
+ if (pid == manager->priv->pid)
+ manager->priv->pid = 0;
+}
/* start_gnome_sound
*
* Start GNOME sound.
*/
-static void
-start_gnome_sound (void)
+static gboolean
+start_gnome_sound (GsdSoundManager *manager)
{
- gnome_sound_init (NULL);
- if (gnome_sound_connection_get () < 0) {
- g_warning ("Could not start GNOME sound.\n");
- }
+ char *argv[] = { "esd", "-nobeeps", NULL};
+ GError *err = NULL;
+ time_t starttime;
+
+ if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
+ &manager->priv->pid, &err)) {
+ g_printerr ("Could not start esd: %s\n", err->message);
+ g_error_free (err);
+ return FALSE;
+ }
+
+ g_child_watch_add (manager->priv->pid, reset_esd_pid, NULL);
+
+ starttime = time (NULL);
+ gnome_sound_init (NULL);
+
+ while (gnome_sound_connection_get () < 0
+ && ((time (NULL) - starttime) < 4))
+ {
+ g_usleep (200);
+ gnome_sound_init (NULL);
+ }
+
+ return gnome_sound_connection_get () >= 0;
}
#ifdef HAVE_ESD
@@ -91,7 +121,7 @@
* Stop GNOME sound.
*/
static void
-stop_gnome_sound (void)
+stop_gnome_sound (GsdSoundManager *manager)
{
#ifdef HAVE_ESD
/* Can't think of a way to do this reliably, so we fake it for now */
@@ -99,6 +129,13 @@
set_esd_standby = TRUE;
#else
gnome_sound_shutdown ();
+
+ if (manager->priv->pid) {
+ if (kill (manager->priv->pid, SIGTERM) == -1)
+ g_printerr ("Failed to kill esd (pid %d)\n", manager->priv->pid);
+ else
+ manager->priv->pid = 0;
+ }
#endif
}
@@ -189,13 +226,15 @@
enable_sound = TRUE;
#endif
event_sounds = gconf_client_get_bool (client, "/desktop/gnome/sound/event_sounds", NULL);
+ /* FIXME this is completely bogus, the entry doesn't exist */
event_changed_new = gconf_client_get_int (client, "/desktop/gnome/sound/event_changed", NULL);
closure.enable_system_sounds = event_sounds;
if (enable_sound) {
if (gnome_sound_connection_get () < 0)
- start_gnome_sound ();
+ if (!start_gnome_sound (manager))
+ return;
#ifdef HAVE_ESD
else if (set_esd_standby) {
esd_resume (gnome_sound_connection_get ());
@@ -206,7 +245,7 @@
#ifdef HAVE_ESD
if (!set_esd_standby)
#endif
- stop_gnome_sound ();
+ stop_gnome_sound (manager);
}
if (enable_sound &&
@@ -216,7 +255,6 @@
inited = TRUE;
event_changed_old = event_changed_new;
-
props = sound_properties_new ();
sound_properties_add_defaults (props, NULL);
sound_properties_foreach (props, reload_foreach_cb, &closure);
@@ -267,7 +305,7 @@
{
g_debug ("Stopping sound manager");
- stop_gnome_sound ();
+ stop_gnome_sound (manager);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]