GNOME Bugzilla – Bug 466458
No sound in session
Last modified: 2008-02-28 17:59:21 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:
Does this happen every time?
*** Bug 470348 has been marked as a duplicate of this bug. ***
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.
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.
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).
(In reply to comment #2)
> Created an attachment (id=95136) 
> 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
> 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.
Should be this reassigned then? Vincent what you think?
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.
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.
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.
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.
Created attachment 104915 [details] [review]
- 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()
Created attachment 104917 [details] [review]
Fix a typo.
Looks okay, please commit. Thanks Bastien!
2008-02-11 Bastien Nocera <email@example.com>
reviewed by: Vincent Untz <firstname.lastname@example.org>
* gsm-sound.c: (get_filename_from_string),
(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.
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.
Created attachment 106171 [details] [review]
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.
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 <email@example.com>
* 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 <firstname.lastname@example.org>
* 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