Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problem with Java Sound Audio Engine  (Read 3527 times)
0 Members and 1 Guest are viewing this topic.
Offline Scarzzurs
« Posted 2008-10-29 20:43:12 »

So, i took a look at my game engine's sound utilities, as i've had a lot of bug reports on this in particular.

It seems the world is entirely different once you change from mixer to mixer. This ofcourse makes it almost impossible to make something cross-platform as each system has it's own mixer. Yet, it seems that all have the mixer called Java Sound Audio Engine, so i made it possible to select a mixer in my program and started to test...

On my windows vista machine i got a fatal error that crashed the entire jvm.
It did however get even worse on my friend's apple mac laptop. Here it not only crashed, but it crashed with a segmentation error!

I tested a could of times on my windows vista machine and here it seemed that calls to drain sometimes would start an infinite loop, draining the cpu rather than my SourceDataLine Tongue
It also seemed that the LineListener i added didn't always get the update calls i'd expect.

Right now i have the feeling that the java sound api is some kind of joke as long as there aren't atleast one proper mixer available on all systems...
The only possitive thing i can say is that i actually got sound playing on all systems, before they eventual crashed.

So my question is, how do i get crossplatform audio in my games, preferably using the standard java API?
If more information is needed about my system, setup and code, please let me know and i'll try to supply it :-)

- Scarzzurs

My games and Projects:
BlastingPixels.com,
Old website
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #1 - Posted 2008-10-30 11:12:00 »

JavaSound is not without it's problems, but it's the only way to get sound in pure java and IME it's pretty stable if you use it as intended. I never ever had JavaSound crash on me like that myself Shocked
I'd file a bug report if I were you.

Maybe you could post some code that demonstrates the problem?

You could also take a look at OpenAL (using JOAL or LWJGL). It's faster and supports 3D sound, but IMHO the API is nowhere near as nice as JavaSound, and you'll have to deal with .dll's, .so's, code signing, etc.

Offline Scarzzurs
« Reply #2 - Posted 2008-10-30 11:33:48 »

Thanks for the reply. Just less than an hour ago i found a possible solution to the problem...
I did some test on windows only for now:

It seems that the drain method of SourceDataLine only acts properly if the start event of the line has been fired. It doesn't matter if the fire event was fired and the data was drained by itself underway, but the drain method is totaly unreliable if the start event was fired first. I'll hopefully be testing on my friends mac again later today, and i'm really hoping this is the problem.

I was afraid it would be a problem on my side, but i couldn't find where it says that the start even must be fired before a call to drain.
Does the api state this anywhere?
In either case i think it's wrong that pure java gives segmentation fault, and the crash i got on windows vista.

I'll be testing it further and will be uploading a new version of my latest game featuring this workaround update to my engine.

Btw. i did consider OpenAL and other libraries, but like you said it's not as clean as Java Sound...

- Scarzzurs

My games and Projects:
BlastingPixels.com,
Old website
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2008-10-30 15:51:36 »

Maybe use another mixer. I loop on all mixers and I choose the mixer that supports my line and that supports the highest count of simultaneously opened lines, I do it for each OggClip so that each sound sample might use a different mixer if required. Why do you need to call drain() before start()??

Offline Scarzzurs
« Reply #4 - Posted 2008-10-30 17:07:04 »

I wanted to check that i could play sound on all systems. My friend (on mac) and i (on windows) seemed to both have this mixer. That's why i tried to test that. Also, i want to give the user the ability to select a device, rather than selecting a (otherwise) random mixer on each machine...

I don't want to call drain() before start(). I want to call drain() after open(), start() and write(), and then after the drain() i want to close() the line. However if the drain() is called before the start event (started some time after some data has been written to the line), it acts all up. Sorry if i sounded all confusing, hope i cleared it up somewhat...

Thanks for the suggestion though Smiley

Edit:
My friend tested the game, and the sound was playing perfectly, sounding exactly as on my machine. Smiley

- Scarzzurs

My games and Projects:
BlastingPixels.com,
Old website
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (11 views)
2014-09-21 23:33:17

BurntPizza (29 views)
2014-09-21 02:42:18

BurntPizza (19 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (30 views)
2014-09-19 03:14:18

Dwinin (47 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!