Hi,
I’m trying to integrate joal into JMF Renderer. I’ve made a simple console app which reads bytes from file and pass it to the buffers to be played. the app runs ok.
The same code is used in the Renderer but no sound is produced. While waiting for some buffer to be processed, which never happens I print the state of the source and
it says : AL_PLAYING.
Can you give some advice what can be wrong ? I’m testing this on Windows.
Here is the sample code which works in standalone app but not if used with JMf in a Renderer.
AL al = null;
int BUFFER_SIZE = 1000;
int NUM_BUFFERS = 2;
int[] buffers = new int[NUM_BUFFERS];
int[] source = new int[1];
try
{
ALut.alutInit();
al = ALFactory.getAL();
al.alGetError();
}
catch (ALException e)
{
System.err.println("Error initializing OpenAL");
e.printStackTrace();
}
int numberOfFilledBuffers = 0;
boolean playing = false;
al.alGenBuffers(NUM_BUFFERS, buffers, 0); check();
al.alGenSources(1, source, 0); check();
FileInputStream in = new FileInputStream("testwav.wav");
byte[] buff = new byte[1000];
while(in.read(buff) != -1)
{
if(!playing)
{
fillInBuffer(buffers[numberOfFilledBuffers], buff, 0, buff.length);
numberOfFilledBuffers++;
if(numberOfFilledBuffers == NUM_BUFFERS)
{
al.alSourceQueueBuffers(source[0], NUM_BUFFERS, buffers, 0);
al.alSourcePlay(source[0]);
playing = true;
}
continue;
}
int[] processed = new int[1];
processed[0] = 0;
while(processed[0] == 0)
{
al.alGetSourcei(source[0], AL.AL_BUFFERS_PROCESSED, processed, 0);
int[] state = new int[1];
al.alGetSourcei(source[0], AL.AL_SOURCE_STATE, state, 0);
System.out.println("state : " + state[0]);
Thread.sleep(10);
}
int[] buffer = new int[1];
al.alSourceUnqueueBuffers(source[0], 1, buffer, 0); check();
fillInBuffer(buffer[0], buff, 0, buff.length);
al.alSourceQueueBuffers(source[0], 1, buffer, 0); check();
}