private void attachStreamToSource(int sourceId, AudioStream stream, boolean looping) {
        boolean success = false;

        // Reset the stream. Typically, happens if it finished playing on its own and got reclaimed.
        // Note that AudioNode.stop() already resets the stream since it might not be at the EOF when stopped.
        if (stream.isEOF()) {
            stream.setTime(0);
        }

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

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

            if (filled) {
                ib.clear().limit(1);
                ib.put(id).flip();
                al.alSourceQueueBuffers(sourceId, 1, ib);
                success = true;
            }
        }

        if (!success) {
            // should never happen
            throw new IllegalStateException("No valid data could be read from stream");
        }
    }
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