Note: There are a few cases of duplicates in user autocompletion which are being worked on.

patch: Generic audio handler for Mozilla Applications

RESOLVED FIXED

Status

()

Core
Widget: Gtk
RESOLVED FIXED
11 years ago
8 years ago

People

(Reporter: Dirk Jagdmann, Unassigned)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Build Identifier: MailNews 1.5.0.4

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:  
--
(Reporter)

Comment 1

11 years ago
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?
(Reporter)

Comment 3

11 years ago
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?

Comment 5

11 years ago
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.
(Reporter)

Comment 6

11 years ago
(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.
(Reporter)

Comment 7

11 years ago
(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.

Comment 8

11 years ago
(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.

Comment 9

11 years ago
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:1.8.0.3) Gecko/20060326 Firefox/1.5.0.3 (Debian-1.5.dfsg+1.5.0.3-2)

Comment 10

11 years ago
(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 1.5.0.7 and will be in the upcoming firefox 2.0 release.

Comment 11

10 years ago
(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.
(Reporter)

Comment 12

8 years ago
This now longer applies to Mozilla code base starting from 2.0.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.