Problem with the SourceDataLine object in MAC OS

Hello,

 I have written a one program that uses the javax.sound.sampled.SourceDataLine object to play sound. I have tested that program on both MAC and Windows OS.

 On windows OS the program works fine. On MAC OS, the program gives some strange behavior. 

 For example, If i have a SourceDataLine buffer of size 50000 bytes. In while loop i am calling available() method of the SourceDataLine. On windows platform, each call in loop give me some available bytes that i can write to buffer. Like 2000, 4000....etc.

But on MAC OS, i am not getting like that but instead SourceDataLine give me it when all buffer goes empty. I mean i am not getting like 2000,4000 …etc. but all buffer size like 50000 at once.

The problem is that i am not able to write data to source data line when it has some small amount of buffer free. Due to this, i am feeling some sound smoothness problem on MAC OS. Sound stops few seconds in between.

Thanks In Advance

I’ve had a lot of problems with SourceDataLine too. The main reason I haven’t used Clip is because it’s not possible to mute or adjust the volume without hearing noticeable clicks/pops on most (or all?) platforms. Which sounds really unprofessional.

Anyway, here’s the SourceDataLine player I’ve been using. The part where it writes data to the line is in the update(int) method, near the bottom:
http://code.google.com/p/pulpcore/source/browse/trunk/src/pulpcore/platform/applet/JavaSound.java

Hello,

I have done in the same way but it behaves differently on the mac Operating System. When i call line.available() it gives me free bytes when whole buffer goes empty. 

Regards

The code I linked to works on Mac. There’s a difference between Tiger and Leopard - the Tiger code path doesn’t use available() to determine how much data to write. Look near line 536.