private boolean fillStreamingSource(int sourceId, AudioStream stream, boolean looping) {
        boolean success = false;
        int processed = al.alGetSourcei(sourceId, AL_BUFFERS_PROCESSED);
        int unqueuedBufferBytes = 0;

        for (int i = 0; i < processed; i++) {
            int buffer;

            ib.clear().limit(1);
            al.alSourceUnqueueBuffers(sourceId, 1, ib);
            buffer = ib.get(0);

            // XXX: assume that reading from AudioStream always
            // gives BUFFER_SIZE amount of bytes! This might not always
            // be the case...
            unqueuedBufferBytes += BUFFER_SIZE;

            // Try to refill the buffer
            boolean filled = fillBuffer(stream, buffer);
            if (!filled && !stream.isEOF()) {
                throw new AssertionError();
            }

            if (!filled && looping) {
                stream.setTime(0);
                filled = fillBuffer(stream, buffer); // Try filling again
                if (!filled) {
                    throw new IllegalStateException("Looping streaming source "
                            + "was rewound but could not be filled");
                }
            }

            if (filled) {
                ib.clear().limit(1);
                ib.put(0, buffer);
                al.alSourceQueueBuffers(sourceId, 1, ib);
                // At least one buffer enqueued = success.
                success = true;
            } else {
                // No more data left to process.
                break;
            }
        }

        // Update the stream's internal counter for processed bytes
        stream.setUnqueuedBufferBytes(stream.getUnqueuedBufferBytes() + unqueuedBufferBytes);

        return success;
    }
Unqueues processed buffers from a streaming source and refills/requeues them.
Updates the stream's internal count of processed bytes.

@param sourceId The OpenAL source ID.
@param stream   The AudioStream.
@param looping  Whether the stream should loop internally.
@return True if at least one buffer was successfully refilled and requeued.
jme3-core/src/main/java/com/jme3/audio/openal/ALAudioRenderer.java