After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 466458 - No sound in session
No sound in session
Status: RESOLVED FIXED
Product: gnome-session
Classification: Core
Component: gnome-session
2.19.x
Other All
: Normal minor
: ---
Assigned To: Session Maintainers
Session Maintainers
: 470348 (view as bug list)
Depends on: 515340 515341 518075
Blocks:
 
 
Reported: 2007-08-14 02:54 UTC by Frédéric Bellaiche
Modified: 2008-02-28 17:59 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
Patch for gsm-sound.c to get login and logout sounds working (2.42 KB, patch)
2007-09-07 15:06 UTC, Calvin Gaisford
none Details | Review
improved version, wrap esd into a shell (3.36 KB, patch)
2007-09-21 10:39 UTC, Frederic Crozat
none Details | Review
Fork the shell to the root directory (3.37 KB, patch)
2008-01-04 14:31 UTC, Josselin Mouette
none Details | Review
gnome-session-play-login-sound.patch (2.96 KB, patch)
2008-02-11 11:27 UTC, Bastien Nocera
none Details | Review
gnome-session-play-login-sound-2.patch (2.96 KB, patch)
2008-02-11 11:50 UTC, Bastien Nocera
committed Details | Review
gnome-session-remove-esd-launch.patch (7.82 KB, patch)
2008-02-28 16:51 UTC, Bastien Nocera
none Details | Review

Description Frédéric Bellaiche 2007-08-14 02:54:16 UTC
Please describe the problem:
since version 2.19.5 (up to 2.19.90), there is no more sound at startup (although sound is working, and a correct system sound for "Log in" is chosen in the sound preferences capplet)

Steps to reproduce:



Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Sebastien Bacher 2007-08-28 22:13:55 UTC
*** Bug 470348 has been marked as a duplicate of this bug. ***
Comment 2 Calvin Gaisford 2007-09-07 15:06:15 UTC
Created attachment 95136 [details] [review]
Patch for gsm-sound.c to get login and logout sounds working

This is a patch I created in opensuse 10.3 which address these two sound issues:

With the changes recently made in gsm-sound.c the two functions load_login_sample_from and load_login_sample_from were removed.  I went through the code multiple times and there doesn't appear to be a need for these methods but they do make a call to esd_sample_getid which binds the gnome sound system to esd.  Without making a call to load_login_sample during the sound_init, the sound system doesn't get setup in time for the login sound to play.  This patch adds the functions back in with a call to load_login_sample which gets the sound system up and running in time for the login sound to be played.

The other problem is the logout sound isn't being played.  The way sound was being shutdown, it would actually kill esd before the trigger would get processed to play the logout sound.  This patch re-introduces the -terminate option to ESD and never shuts down the sound system (it will terminate by itself when the clients are gone).  I believe the shutdown code was introduced to fix a problem with NFS mounts because ESD wasn't changing the daemon's working directory at startup so NFS couldn't unmount.  That's been fixed in ESD so we should be able to let it shutdown by itself now.
Comment 3 TJ 2007-09-07 17:27:57 UTC
I've just applied the patch to 2.19.92 (Ubuntu Gutsy 64-bit).

inotifywait -m shows that both /etc/sound/events/gnome-2.soundlist and /usr/share/sounds/startup3.wav are now being accessed but there's still no actual login sound.

'startup3.wav' plays fine from aplay and the Gnome Sound Settings dialog.

Also, this change seems to have affected the Ubuntu Log-off dialog.

It was themed and decorated with Suspend & Hibernate in addition to the Log-off Restart and Shutdown graphical option buttons, but now it is a square undecorated (no borders) dialog with a radio-button list of Log-out, Shut down, and Restart and "Remember running applications£ checkbox.
Comment 4 Calvin Gaisford 2007-09-10 17:11:01 UTC
My only guess is that the patch isn't being applied cleanly with other Ubuntu patches.  The patch only touches the gsm-sound.c file which won't cause a change to the logout dialog (done in logout.c).
Comment 5 Vincent Untz 2007-09-10 17:26:53 UTC
(In reply to comment #2)
> Created an attachment (id=95136) [edit]
> Patch for gsm-sound.c to get login and logout sounds working
> 
> This is a patch I created in opensuse 10.3 which address these two sound
> issues:
> 
> With the changes recently made in gsm-sound.c the two functions
> load_login_sample_from and load_login_sample_from were removed.  I went through
> the code multiple times and there doesn't appear to be a need for these methods
> but they do make a call to esd_sample_getid which binds the gnome sound system
> to esd.  Without making a call to load_login_sample during the sound_init, the
> sound system doesn't get setup in time for the login sound to play.  This patch
> adds the functions back in with a call to load_login_sample which gets the
> sound system up and running in time for the login sound to be played.

I'm sorry, but this sounds like a workaround to me. There should be no need for us to do this. So I'd either blame esound or libgnome.

> The other problem is the logout sound isn't being played.  The way sound was
> being shutdown, it would actually kill esd before the trigger would get
> processed to play the logout sound.  This patch re-introduces the -terminate
> option to ESD and never shuts down the sound system (it will terminate by
> itself when the clients are gone).  I believe the shutdown code was introduced
> to fix a problem with NFS mounts because ESD wasn't changing the daemon's
> working directory at startup so NFS couldn't unmount.  That's been fixed in ESD
> so we should be able to let it shutdown by itself now.
> 

Hrm. Is there a way to have the trigger be processed before we kill esound? I think that it's reasonable to kill esd if we launch it, but well, maybe it's okay to change it again.
Comment 6 Pedro Villavicencio 2007-09-12 17:10:28 UTC
Should be this reassigned then? Vincent what you think?
Comment 7 Vincent Untz 2007-09-13 18:07:09 UTC
Well, I'd prefer that someone first investigates the real issue. I don't have time for this now, but if we keep the bug I'll do this later.
Comment 8 Frederic Crozat 2007-09-21 10:39:04 UTC
Created attachment 95950 [details] [review]
improved version, wrap esd into a shell

improved versino of patch : esd should be wrapped into a shell, because it receives otherwise a SIGHUP from xinit when logout is done, which resets esd and causes it to crash. I've also ensure gnome_sound_shutdown is called for shutdown too.
Comment 9 Josselin Mouette 2008-01-04 14:31:09 UTC
Created attachment 102121 [details] [review]
Fork the shell to the root directory

Now that esound chdir()s to the root directory, you can forget to kill it, but if you put it in a shell, you need to chdir the shell as well.
Comment 10 Bastien Nocera 2008-02-09 02:59:05 UTC
The problem is that gnome-settings-daemon's sound plugin is the one loading the samples into the esd/PulseAudio's cache. If gnome-settings-daemon isn't lightning fast, then the samples won't be cached by the time we get to play the sound, and the triggers will just fail (see the "if(sid<0) return" in gnome_triggers_play_sound() in libgnome).

You can see the problem by:
- running gnome-settings-daemon before running gnome-session
- adding the line (not tested):
load-sample-lazy login /usr/share/sounds/startup3.wav
to your /etc/pulse/default.pa

A potential fix would be to read ~/.gnome2/sound/events/gnome-2.soundlist to see if the login sound has been themed, if not, read /etc/sound/events/gnome-2.soundlist to see where [login] points to, run gnome_sound_play() on the file.
That should be pretty easy given GKeyFile.

Another way to solve the problem would be to have gnome-settings-daemon init the sound module asap and tell us it has init'ed particular modules using a signal. We wouldn't even need to start esd/PulseAudio ourselves anymore.

The whole sound effects theming in GNOME is a right mess. It should be using GConf instead, but seems to date back from pre-GNOME 1.0 days, but this is the easiest way to fix the problem without bringing back all the crappy libgnome code into it.
Comment 11 Bastien Nocera 2008-02-11 11:27:29 UTC
Created attachment 104915 [details] [review]
gnome-session-play-login-sound.patch

- Search for the sound in the user and system-wide keyfiles
- Resolve if it's a relative path (ie. a file in a known sound directory)
- Play the file using gnome_sound_play()

Please test.
Comment 12 Bastien Nocera 2008-02-11 11:50:53 UTC
Created attachment 104917 [details] [review]
gnome-session-play-login-sound-2.patch

Fix a typo.
Comment 13 Vincent Untz 2008-02-11 12:13:53 UTC
Looks okay, please commit. Thanks Bastien!
Comment 14 Bastien Nocera 2008-02-11 12:19:23 UTC
2008-02-11  Bastien Nocera  <hadess@hadess.net>

        reviewed by: Vincent Untz <vuntz@gnome.org>

        * Makefile.am:
        * gsm-sound.c: (get_filename_from_string),
        (get_filename_for_sound_from_keyfile), (get_filename_for_sound),
        (play_sound_event): Don't use libgnome's triggers to play the
        login sound, as gnome-settings-daemon hasn't loaded the
        samples in esound when we want to play that file, so referencing
        it by sample name won't work (Helps: #466458)

Leaving opened so we can revert the changes and wait on the gnome-settings-daemon sound plugin being initialised instead in future versions.
Comment 15 Bastien Nocera 2008-02-22 14:38:11 UTC
Retitling the bug, the problem is a bit deeper.

1. gnome-session starts
2. gnome-session starts gnome-settings-daemon
3a. gsd gets to loading the sound plugin
3b. gsd realises that pulseaudio/esd isn't started, so tries to use gnome_sound_init(), which won't work as esd (or PA) doesn't autospawn
3c. gsd fails to load any samples in the cache
4a. gnome-session starts pulseaudio properly
4b. login sound fails (with the old code) as the sample isn't loaded

Note that 3. and 4. items happen concurrently, so there's no saying which one will be loaded first. Sometimes, with a bit of luck, pulseaudio will be started for gsd to load the samples, but not early enough for gnome-session to use the cached sample to play the login sound.

The correct fix (as discussed with Jon) would be:
1. gnome-session starts
2. gnome-session starts gsd and listens for plugins being loaded
3. gsd loads the sound plugin, which starts pulseaudio, and caches the samples
4. gsd tells gnome-session that the sound plugin has finished loading
5. gnome-session gets told sound services are ready, plays the login sound

This means we can remove the sound startup code from gnome-session, and trim the login/logout sound playback code to a single call to gnome_triggers_do.
Comment 16 Bastien Nocera 2008-02-28 16:51:29 UTC
Created attachment 106171 [details] [review]
gnome-session-remove-esd-launch.patch

Remove esound launch for gnome-session, and wait until gnome-settings-daemon launches the sound daemon to play back sound.

Because we don't need to launch or poke esd directly, the libgnome APIs are enough for us, and we can remove the direct esound dependency.
Comment 17 Bastien Nocera 2008-02-28 17:59:21 UTC
Patch from above, and also disconnect from the "PluginActivated" signal, as we wouldn't want to play the login sound again when gnome-settings-daemon is restarted (thanks Vincent!)

2008-02-28  Bastien Nocera  <hadess@hadess.net>

	* configure.in: Remove hard requirement on esound,
	as we use the gnome-sound APIs, and let the
	gnome-settings-daemon launch the sound server

2008-02-28  Bastien Nocera  <hadess@hadess.net>

	* Makefile.am: Remove unneeded definition

	* gsm-gsd.c (plugin_activated), (gsm_gsd_start): when the sound server
	starts, play back the login sound if it's used

	* gsm-sound.c (sound_init), (play_sound_event), (gsm_sound_logout):
	* main.c (main): Let gnome-settings-daemon launch the sound server,
	and as the sample are not loaded when we play back the login sound,
	remove our own loading code and use libgnome sound APIs

	(Closes: #466458)