User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:18.104.22.168) Gecko/20060508 Firefox/22.214.171.124 Build Identifier: MailNews 126.96.36.199 This patch to the Mozilla source code adds a generic handler to play back audio for applications like firefox or thunderbird. I made this patch, because I'd like to have a notification when new email arrives, but mozilla uses the Enlightenment Sound Daemon (ESD) for this purpose which doesn't work smoothly with my alsa setup. After applying this patch you can use any audio player on your system to handle playback. The handler is configured via the environment variable MOZILLA_AUDIO_HANDLER which contains a shell command to start an audio player which gets the audio stream from stdin. To play .wav or .voc files through alsa devices add the following line to /etc/profile (or some other appropriate place) and restart your shell before starting thunderbird: export MOZILLA_AUDIO_HANDLER="aplay - &>/dev/null" If your favourite notification is in mp3 format use mpg123: export MOZILLA_AUDIO_HANDLER="aoss mpg123 - &>/dev/null" I have setup a webpage about this page: http://llg.cubic.org/patches/mozillaaudio/ Reproducible: Always Steps to Reproduce: No but, needs to reproduce procedure Actual Results: -- Expected Results: --
Created attachment 230793 [details] [diff] [review] patch to nsSound.cpp in gtk2 widgets for a generic audio handler The nsSound.cpp file can be used unmodified for the gtk1 widgets too.
Interesting, but is there no way to automatically use the right subsystem without this environment variable?
On Linux (where I develop) the audio situation is currently a whole mess, because there are 5 major ways to access your soundcard. If use use KDE chances are high, the "arts" server is used. If you use GNOME, maybe "gstreamer" or "esd" are running. arts, gstreamer and esd then rely on either the old "OSS" or the new "ALSA" sound drivers to access your audio hardware. If you don't use any sophisticated audio (multiplexing server) you have to access OSS or ALSA directly. And then linux people from the audio community often have "jack" running, which gives us a sixth alternative. Now the correct method would be to add some audio configuration to the preferences and let the user choose his prefered way to output sound. But this currently goes beyond my knowledge of mozilla, and further I'm not sure if the mozilla code allows to customize the preferences for a single platform only, because on Windows, Mac, Solaris etc. there is only one (reasonable) sound API/interface. Therefore I have made this patch (which works for me at least) and lets the user configure his audio (totally barebone via env vars). I'm not afraid to touch more of mozilla if someone gives me some pointers where I can add a preferences dialog and how I can access the configured settings in the nsSound classes.
Can't we test to see which sound system is running, and use whichever one we find?
Bug 340314 has recently landed. Please test either branch or trunk and see if sound now Just Works for you. There is still a dependency on having esd, but not on having esd running. You just need the esd library.
(In reply to comment #5) > Bug 340314 has recently landed. Please test either branch or trunk and see if > sound now Just Works for you. There is still a dependency on having esd, but > not on having esd running. You just need the esd library. While Bug 340314 addressed a bug in parsing the .wav headers it is not related to this bug. I don't have generall problems playing .wav files with the currently used esd "method", but I don't want to use esd for playback and have therefore added a generic playback facility which lets me choose the linux audio system via environment variables.
(In reply to comment #4) > Can't we test to see which sound system is running, and use whichever one we > find? This could be done and could work satisfactory in some ways, but automagically detecting a sound system will choose the right one correctly in all cases. The cleanest way would be to modify the preferences dialogs and add a sound system configuration panel/section/tab. However I'm willing to help on this issue and would write some code to interface the different audio systems and then develop some detection routine. But please keep in mind that I do this in my spare time and will need some weeks for development and testing, since I can't developt on this a a daily/regular basis.
(In reply to comment #6) > While Bug 340314 addressed a bug in parsing the .wav headers No, it did not. Bug 68804 fixes wav parsing. > I don't have generall problems playing .wav files with the > currently used esd "method", but I don't want to use esd for playback and have > therefore added a generic playback facility which lets me choose the linux > audio system via environment variables. > You don't have to use esd. Esd provides a number of backends such as alsa (0.5 and 0.9) and OSS On most linux systems, if you manage to keep esd from starting, the code will now fall back to directly using the ALSA 0.9 backend.
When I run firefox -console, I see corruption in the console when playing a sound. Firefox plays no sound at all although flash inside a tab works fine. I have sound working. Mozilla should use what I have working. Lacking an interface for that in Firefox, it would be nice to be able to set an environment variable that fixes things, or put another way, at least makes me sure of what sound system it is trying to use. I think MOZ_AUDIO_WAV, MOZ_AUDIO_MP3 etc would have been very useful. ( This comes just after I found that MOZ_DISABLE_PANGO=1 would make Firefox menuitem fonts look like acceptable in knoppix). Environment variables, or an about:config setting... but something is needed. I am using the latest knoppix, which is 5.0.1 at present. Mozilla/5.0 (X11; U; Linux i686; en-US; rv:188.8.131.52) Gecko/20060326 Firefox/184.108.40.206 (Debian-1.5.dfsg+220.127.116.11-2)
(In reply to comment #9) > When I run firefox -console, I see corruption in the console when playing a > sound. This has already been fixed by bug 340314. The fix was shipped with firefox 18.104.22.168 and will be in the upcoming firefox 2.0 release.
(In reply to comment #8) > You don't have to use esd. Esd provides a number of backends such as alsa (0.5 > and 0.9) and OSS On most linux systems, if you manage to keep esd from > starting, the code will now fall back to directly using the ALSA 0.9 backend. In case anyone else couldn't get esd to do this, there are (on Ubuntu at least) two libesd packages. libesd0 uses OSS. To fall back on ALSA, you need libesd-alsa0.
This now longer applies to Mozilla code base starting from 2.0.