Project Escobar

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?

The scrolling was smooth, however the sound seemed to work only some of the time. i.e. some times the vulcan cannon made a sound effect, sometimes it did not. Same with the rockets and the enemy turrets.

JVM 1.4.2_03

[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]
it really shouldn’t be a problem accessing the audio as a non-root user, many java games run fine with sound on non root, how are you access the sound ?

Bugger Linux and all that sail in her. Just thought I’d make a small pile of flames and see what happens.

Blah^3 is remarkably scathing about anything to do with computers, but after 20 odd years no-one should blame him. Pray for his soul.

Cas :slight_smile:

[quote]Bugger Linux and all that sail in her. Just thought I’d make a small pile of flames and see what happens.

Cas :slight_smile:
[/quote]
bah, why you…, ok i understands its a pain, but write once run anywhere, is one of java’s strenghts, we here on the linux front don’t have much games and java is one of our hopes that one day it will be a strong gaming platform!

aside from that at least i’m safe from all the virus and spyware rubbish you window ppl have to live with ;D ;D ;D

hopefully project escobar is gonna make a fine addition to LINUX.

believe me, i was surprised to read that, too. this is how i load the sound files (found that somewhere in the java sound forums):


// ...
import javax.sound.sampled.*;

public class SoundClipStore {
    
    // ...
    
    static {
        Mixer.Info[] mixers = AudioSystem.getMixerInfo();
        for (int i = 0; i < mixers.length; i++) {
            if ("Java Sound Audio Engine".equals(mixers[i].getName())) {
                mixer = AudioSystem.getMixer(mixers[i]);
            }
        }
    }
    
    // ...
        
    private Clip getAudioClip(AudioInputStream stream) {
        try {
            // At present, ALAW and ULAW encodings must be converted
            // to PCM_SIGNED before it can be played
            AudioFormat format = stream.getFormat();

            if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
                format = new AudioFormat(
                AudioFormat.Encoding.PCM_SIGNED,
                format.getSampleRate(),
                format.getSampleSizeInBits() * 2,
                format.getChannels(),
                format.getFrameSize() * 2,
                format.getFrameRate(),
                true
                );
                stream = AudioSystem.getAudioInputStream(format, stream);
            }

            int bytelength = (int) (format.getFrameSize() * stream.getFrameLength());
            byte[] sampleData  = new byte[bytelength];
            stream.read(sampleData, 0, bytelength);
            
            DataLine.Info dataLineInfo = new DataLine.Info(Clip.class, format);
            if (!AudioSystem.isLineSupported(dataLineInfo)) {
                System.out.println("audio line not supported!");
            }
            
            Clip clip;
            try {
                if (mixer != null) {
                    clip = (Clip) mixer.getLine(dataLineInfo);
                }
                else {
                    clip = (Clip) AudioSystem.getLine(dataLineInfo);
                }
                clip.open(format, sampleData, 0, sampleData.length);
            }
            catch (LineUnavailableException ex)  {
                System.out.println("could not open sound!");
                ex.printStackTrace();
                return null;
            }
            
            return clip;
            
        } catch (Exception e) {
            System.out.println("unable to load sound!");
            e.printStackTrace();
        }
        
        return null;
    }
}

(sorry for the broken indentations)

i’m afraid everyone will now answer with “omg, use joal or lwjgl instead!” but i have no experience with these apis so far… :’(

[quote]The scrolling was smooth, however the sound seemed to work only some of the time. i.e. some times the vulcan cannon made a sound effect, sometimes it did not. Same with the rockets and the enemy turrets.

JVM 1.4.2_03
[/quote]
have you seen any stacktraces or errors in the console?

[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 :stuck_out_tongue: ;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 :(.

i fully agree. i just released a code update to prevent crashes if the sound initializing fails. unfortunately i don’t have a linux system to test. but it works with a simulated problem on my machine.

Well, I tried again to see what would happen on linux, but got so bored waiting for this problem:

[quote]the loading bar is for displaying how long it takes to preload the images and sounds into memory not from the webserver to your machine. maybe this is not the best way to do it (suggestions welcome) but it is my way of doing it.
[/quote]
that I killed it. It was a big fat window obliterating my desktop and that bar was crawling along painfully slowly so I couldn’t do anything else while I waited.

I’m afraid I still have absolutely no idea what you could be doing that would be taking so much time - how can you occupy a 1 Ghz processor for minutes to load something that’s already been downloaded? It is very frustrating though.

i have absolutely no idea what is going wrong on your machine. on all (windows) machines i tested it didn’t take longer than 10 seconds. as i said i don’t have a linux machine to test. do you have a console output where i can have a look at?

has anyone of the linux guys tested the game again?sound loading errors should now be ignored…

[quote]i have absolutely no idea what is going wrong on your machine.
[/quote]
Perhaps you could explain what it’s actually doing?

sorry but it still crashes at loading weapon sounds! ???

i have posted a code snippet above …

[quote]sorry but it still crashes at loading weapon sounds! ???
[/quote]
damn! >:( what appears on the console now?

You posted something about loading sounds. I thought the long pause is when it’s loading images?

iirc you are testing on a linux machine and all the linux guys complained about problems with loading sounds. thus i thought it’s a similar problem.
seems like there are more than one problem with the loading. can you provide a console output?

just a quick question how do u get console output?

you can activate console output in the webstart application.

i have a german one but translated it should be there:
file->settings->extended->show java console