[quote]googled a bit and found that:
i've experienced kinda similar problem today and
i found that this exception will only be threw if
i run the program as a non-root user in my linux
box. probably it's related to the permission for
accessing the audio device...
could someone be so kind and test this?
[/quote]
No, that person doesn’t understand what they are talking about >:(.
Unfortunately, I probably don’t either ;D. I used to know this stuff, but these days it’s vague and wooly and maybe I’m almost completely wrong, just going by half-remembered truths ::).
The main problem with linux is that permissions for accessing and using the sound devices are “antiquated”. Off the top of my head, it’s basically treated like a “file”: you can obtain “write” access to it, which locks it (grabs a lock just like a synchronization lock) and prevents anyone else from using it.
To say this is moronic is an understatement: why in the name of all that is good would you NOT want your sounds to play simultaneously? It’s like saying that different windows would get to “lock” the desktop. (and I could be misleading you here, however c.f. my final paragraph!)
However (there’s always a “but”…), it’s not always like this. Often, things don’t get given that exclusive audio device access at all. I believe this is conventionally known as:
“Bloody NIH-fool Linus and his refusal to adopt modern code practices and the resulting train wreck piece of crud that is the linux kernel”
Or, possibly:
“Device driver authors are all the Spawn of Satan and enjoy deliberately writing shitty code so that people’s computers misbehave and crash randomly and unpredictably - and the poor OS authors tend to get all the blame because usually the driver crashes a totally unrelated piece of code!”
Certainly, this is the root cause of the: “Windows 95 has always worked perfectly for me and never crashed, but when I upgraded to Windows XP it crashes every 2 hours forever” (does happen to a lot of people). The way that some people’s windows PC’s crash “all the time” and others - running the identical OS - almost never do is usually down to badly written device drivers.
…
So. I promised a spectacular last paragraph, and here it is. Those write-locks are write locks, on a file. So…you can use all the standard linux tools for finding out what has locked that file, why, and removing it!.
Standard thing to type when your sound doesn’t work:
“fuser -uv /dev/dsp”
…whic gives you a list of which actual program has locked the audio device. Typical culprits are web browsers - some days they don’t lock it, some days they do. It gives you the process ID’s, so then you do:
kill -s 9 [pid]
Or, less dangerously, just close down your browser. However, kill is more satisfying, and makes sure you close the CORRECT browser if you have more than one running at once. Sadly, mozilla closes all windows if you do this :(.
But because it’s such an incredibly common problem in linux, and the user has no control over preventing it, and it’s a PITA to workaround, and most users don’t know how to, you MUST write your code to “not crash” if sound can’t be initialized. Sorry :(.