How to determine number of unprocessed bytes?

Started by paulscode, April 12, 2010, 00:44:46

Previous topic - Next topic

paulscode

I use AL10.AL_BUFFERS_PROCESSED, AL10.alSourceUnqueueBuffers, and AL10.alSourceQueueBuffers to dequeue/queue buffers when streaming audio.  I would like to be able to calculate the number of bytes left in the queue that have not been processed.  So far I can only figure out how many full buffers haven't been processed, which is not specific enough for my needs (I want to know exact byte location in the currently playing buffer).  I need to be able to query how many bytes of the current buffer have been processed and/or how many bytes are left to be processed.  Is there a method that returns either of these values?

For reference, this is the method I am using to dequeue/queue audio buffers:
/**
 * Queues up a byte[] buffer of data to be streamed.
 * @param buffer The next buffer to be played for a streaming source.
 * @return False if an error occurred or if the channel is shutting down.
 */
    @Override
    public boolean queueBuffer( byte[] buffer )
    {
        // Stream buffers can only be queued for streaming sources:
        if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING,
                        "Buffers may only be queued for streaming sources." ) )
            return false;
        
        //ByteBuffer byteBuffer = ByteBuffer.wrap( buffer, 0, buffer.length );
        ByteBuffer byteBuffer = (ByteBuffer) BufferUtils.createByteBuffer(
                                           buffer.length ).put( buffer ).flip();

        IntBuffer intBuffer = BufferUtils.createIntBuffer( 1 );

        AL10.alSourceUnqueueBuffers( ALSource.get( 0 ), intBuffer );
        if( checkALError() )
            return false;
        
        AL10.alBufferData( intBuffer.get(0), ALformat, byteBuffer, sampleRate );
        if( checkALError() )
            return false;
        
        AL10.alSourceQueueBuffers( ALSource.get( 0 ), intBuffer );
        if( checkALError() )
            return false;
        
        return true;
    }

Ciardhubh

Have you tried these? Never used them myself but just stumbled over them in the OpenAL Programmer's Guide.
AL10.alGetSourcei(source, AL11.AL_SEC_OFFSET)
AL10.alGetSourcei(source, AL11.AL_SAMPLE_OFFSET)
AL10.alGetSourcei(source, AL11.AL_BYTE_OFFSET)