Closed Bug 104174 Opened 23 years ago Closed 22 years ago

implement nsSound::PlaySystemSound() for linux

Categories

(SeaMonkey :: MailNews: Message Display, defect, P3)

x86
Linux
defect

Tracking

(Not tracked)

VERIFIED DUPLICATE of bug 179138
Future

People

(Reporter: sspitzer, Assigned: sspitzer)

Details

(Keywords: helpwanted)

Attachments

(2 obsolete files)

PlaySystemSound works for windows, and with #104140, it will be done on mac. does linux have a concept of system sounds? if not, maybe we could do this: we currently call PlaySystemSound("Mailbeep") (in nsStatusBarBiffManager.cpp) to play the new mail sound. for linux, here is what I was thinking: NS_IMETHODIMP nsSound::PlaySystemSound(const char *aSoundAlias) { nsresult rv; nsCAutoString prefName("system.sound."); prefName += aSoundAlias; nsXPIDLCString soundPrefValue; rv = pref->CopyCharPref(prefName.get(), getter_Copies(soundPrefValue)); if (NS_SUCCEEDED(rv) && soundUrl.Length() > 0) { // create a nsURI, set the spec with soundPrefValue; rv = PlaySound(soundUrl); } else { rv = Beep(); } return rv; } then, in unix.js we'd define pref("system.sound.Mailbeep","chrome://messenger/content/newmailsound.wav"); if users want to override on linux, they'd set "system.sound.Mailbeep" in their prefs.js to be a local file url. comments?
+ rv = PlaySound(soundUrl); should be rv = Play(soundUrl); but you get the idea.
QA Contact: esther → sheelar
Well, linux doesn't have an asyncronous way of playing sounds really unless you count write(). It just writes to a device on the filesystem that may or may not be writable, may or may not exist, and may or may not be blocked by another program.
blizzard, the goal here would be to make it so on new mail we'd do something other than just beep (on linux). as far as making Play() async, that's be something else. or am I misunderstanding your point?
Why is the OS marked to win 2000? Anyway, the main problem here is that linux does not have a "default sound" So if we are going to make mail beep to the soundcard, we would need to "create" the beep ourselves. So i guess what i am trying to say is that we only need a UI for setting the sound we want to play, since this works already via a pref line, thus the fix should be trivial
OK, here's what I suspect that you would have to do. When you got the request to play you would pass in a stream ( I haven't looked at the interface ) into a new thread that would handle the playing so the main thread wouldn't be blocked. It would handle opening the device, reading from the moz stream, writing to the device, closing the device and then the thread could exit. It sounds reasonable and reasonably simple to implement. The only catch is where we put the file. Does it need to be in a .jar file? There may be issues reading from the other thread but I'm not sure - I've never worked with that part of the code.
blizzard, what you describe is the fix for making nsISound::Play() async on linux. this bug is about mapping PlaySystemSound() to Play(), using an .wav that we ship with (inside the messenger .jar) since there is no standard way of specifying system sounds on linux, like there is on mac or windows.
OS: Windows 2000 → Linux
Oh, yet another thread... You can select() on the /dev/dsp device, BTW, no need for a thread. If you already have a select() loop somewhere, you can just stick this in there. Excuse me if the architecture of the browser is not like that, I only hacked the bowels of XPCOM.
Oh, sorry. I completely missed the point of the bug. Seth, your solution looks fine to me. Like I said, though, we should probably put the sound outside of a jar file to make it easy to stream right to the device. res/ is probably the right place.
Priority: -- → P3
Target Milestone: --- → mozilla0.9.8
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Filed bug 110385 on the asynchrony issue.
Keywords: nsbeta1-
Target Milestone: mozilla0.9.9 → Future
Keywords: helpwanted
update, the system sound is now "_moz_mailbeep" see http://lxr.mozilla.org/mozilla/source/mailnews/base/src/nsStatusBarBiffManager.cpp#122 so the pref would be something like pref("system.sound._moz_mailbeep","res://newmailsound.wav");
mike and I traded some emails, he might be doing some of this for OS/2
Attached patch The OS/2 version (obsolete) (deleted) — Splinter Review
Here is the OS/2 version. Linux should look just about the same. Things are going to be weird on OS/2, though, and I'm looking for some help. I'd prefer not to write code that plays the audio explictly - I just want to invoke a sound player with the file that is passed in. Is there anyway to take a res:// URI and get the physical file location? Right now I'm using a file:/// URI
KDE and Gnome have system sounds. We should support those (at least the Gnome one, given that we're doing GTK themes).
why cant we just send the sound to /dev/dsp instead of figuring out how to pass the sound to ArtS and Esd and so forth? Let's make a method that would work on any linux system
agree why not a easy, unix way... run command after new mail... people could put there what they want, most of then would choose: play ~/sound/newmail.wav this way is simple and yet powerfull, all it needs is a few code lines and a new pref textarea to write the command
Please fix this soon. My new Compaq Presario 5320us has not internal speaker so I have no audio notification at all when I get new mail. Apparently many of the new Presarios have no internal speaker so this may affect a lot of users.
OK, I did this for OS/2 and my solution will probably work on all platforms. I just right out the data as a temporary file and then play it.
Attached patch Fix for Os/2 (obsolete) (deleted) — Splinter Review
This will probably work for other platforms, with just a different mechanism for playing the file.
Attachment #61127 - Attachment is obsolete: true
Comment on attachment 77112 [details] [diff] [review] Fix for Os/2 r=pedemont if you get rid of the GET_WORD defines
Attachment #77112 - Flags: review+
Comment on attachment 77112 [details] [diff] [review] Fix for Os/2 sr=blizzard because this is OS/2 only code. I am also making a change to this code to only work with WAV files by looking for RIFF like Linux does.
Attachment #77112 - Flags: superreview+
Comment on attachment 77112 [details] [diff] [review] Fix for Os/2 a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #77112 - Flags: approval+
Os/2 stuff checked in. You guys are on your own for Linux.
Just wonder why the Calendar already plays Sound on Linux, and the Mail News couldn't ?
Attachment #77112 - Attachment is obsolete: true
Here's the function to play a sound in Linux calendar: function playSound( ThisURL ) { ThisURL = "chrome://calendar/content/sound.wav"; var url = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(); url = url.QueryInterface(Components.interfaces.nsIURL); url.spec = ThisURL; var sample = Components.classes["@mozilla.org/sound;1"].createInstance(); sample = sample.QueryInterface(Components.interfaces.nsISound); sample.play( url ); }
A temporary cure for those of us pineing for a sound other than "BEEP" on Linux: Download softbeep (http://www.stud.uni-hamburg.de/users/lennart/projects/softbeep/), which lets you "wrap" any program's "bell" sound to do something else. I just run "softbeep mozilla" and all my beeping woes go away. Its a hack job, but it'll have to do until PlaySystemSound() does something other than ::gdk_beep().
QA Contact: sheelar → stephend
Perhaps with the demise of 64475 we should be depending on bug 64462
Depends on: 64462
Blocks: 177280
-> front end
Component: Mail Database → Mail Window Front End
Isn't sound already implemented on linux in 1.3b?
Nope, not implemented :-( Are people actually working on this?
Comment #15 (specifying a command to run) would be the best for Unix/Linux.
Yes, a command could be an option, but using something like libao would be preferable, which will automatically select the proper sound output mechanism for the system.
I'm not sure what "libao" provides, but seeing as this bug has been open for 17 months, it may be time for someone to provide a "hack" (i.e. a command-line option) to get this going. And I'm not saying I'm above being the one to make the hack. It'll just take me a little while to make the time to learn the build environment, bug-submission procedure, etc.
*** This bug has been marked as a duplicate of 179138 ***
No longer blocks: 177280
Status: NEW → RESOLVED
Closed: 22 years ago
No longer depends on: 64462, 64475
Resolution: --- → DUPLICATE
Verified dup
Status: RESOLVED → VERIFIED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: