implement nsSound::PlaySystemSound() for linux

VERIFIED DUPLICATE of bug 179138

Status

SeaMonkey
MailNews: Message Display
P3
normal
VERIFIED DUPLICATE of bug 179138
16 years ago
13 years ago

People

(Reporter: (not reading, please use seth@sspitzer.org instead), Assigned: (not reading, please use seth@sspitzer.org instead))

Tracking

({helpwanted})

Trunk
Future
x86
Linux
helpwanted

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 obsolete attachments)

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.

Updated

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

Comment 4

16 years ago
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

Comment 7

16 years ago
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.
Depends on: 64475

Updated

16 years ago
Priority: -- → P3
Target Milestone: --- → mozilla0.9.8

Updated

16 years ago
Target Milestone: mozilla0.9.8 → mozilla0.9.9

Comment 9

16 years ago
Filed bug 110385 on the asynchrony issue.

Updated

16 years ago
Keywords: nsbeta1-
Target Milestone: mozilla0.9.9 → Future

Updated

16 years ago
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

Comment 12

16 years ago
Created attachment 61127 [details] [diff] [review]
The OS/2 version

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).

Comment 14

16 years ago
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

Comment 15

16 years ago
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 

Comment 16

16 years ago
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.

Comment 17

16 years ago
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.

Comment 18

16 years ago
Created attachment 77112 [details] [diff] [review]
Fix for Os/2

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 20

16 years ago
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 21

16 years ago
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+

Comment 22

16 years ago
Os/2 stuff checked in. You guys are on your own for Linux.

Comment 23

16 years ago
Just wonder why the Calendar already plays Sound on Linux, and the Mail News
couldn't ?
Attachment #77112 - Attachment is obsolete: true

Comment 24

16 years ago
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 );
}

Comment 25

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

Updated

16 years ago
QA Contact: sheelar → stephend

Comment 26

15 years ago
Perhaps with the demise of 64475 we should be depending on bug 64462
Depends on: 64462

Updated

15 years ago
Blocks: 177280

Comment 27

15 years ago
-> front end
Component: Mail Database → Mail Window Front End

Comment 28

15 years ago
Isn't sound already implemented on linux in 1.3b?

Comment 29

15 years ago
Nope, not implemented :-(

Are people actually working on this?

Comment 30

15 years ago
Comment #15 (specifying a command to run) would be the best for Unix/Linux.

Comment 31

15 years ago
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.

Comment 32

15 years ago
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.

Comment 33

14 years ago

*** This bug has been marked as a duplicate of 179138 ***
No longer blocks: 177280
Status: NEW → RESOLVED
Last Resolved: 14 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.