Hello Guest

no sound while source is in state playing

  • 0 Replies
  • 8361 Views
no sound while source is in state playing
« on: September 12, 2007, 07:53:24 »
Hi,

I'm trying to integrate openal 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

int numberOfBuffers = 2;
int numberOfFilledBuffers = 0;
IntBuffer buffers = BufferUtils.createIntBuffer(numberOfBuffers);
boolean stopped;
boolean playing = false;
int alInputFormat;
           
// open
IntBuffer sources = BufferUtils.createIntBuffer(1);
AL10.alGenSources(sources);
int source = sources.get(0);
AL10.alGenBuffers(buffers);
           
FileInputStream in = new FileInputStream("testfile.wav");
byte[] buff = new byte[1000];
while(in.read(buff) != -1)
{
   // play
   if(!playing)
        {           
      fillInBuffer(buffers.get(numberOfFilledBuffers), buff, 0, buff.length);
      numberOfFilledBuffers++;

                if(numberOfFilledBuffers == numberOfBuffers)
                {
                        AL10.alSourceQueueBuffers(source, buffers);
                        check();
                         
                        AL10.alSourcePlay(source);
                        check();
                        playing = true;
      }
                    continue;
   }

   while(AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED) == 0)
        {
      System.out.println("state : " + AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE));
                Thread.sleep(3);
   }
               
   // update
        IntBuffer unqueueBuffer = BufferUtils.createIntBuffer(1);
        AL10.alSourceUnqueueBuffers(source, unqueueBuffer);
        fillInBuffer(unqueueBuffer.get(0), buff, 0, buff.length);
        unqueueBuffer.rewind();
        AL10.alSourceQueueBuffers(source, unqueueBuffer);
}


Thanks in advance
damencho
« Last Edit: September 12, 2007, 08:04:48 by damencho »