play_ringbuffer doesn't loop
Hello. We have a project where we're trying to use rtmixer to play sounds that continuously loop. We thought the RingBuffer class and play_ringbuffer would allow us to do that, but it doesn't seem to loop. I noticed "looping?" is listed under planned functionality in the docs, so we wanted to check if we totally misunderstood the intended functionality before we continued debugging.
For reference, we've been discussing the issue here.
I'm not sure if I fully understand the problem, but I have the feeling that it has to do with the interpretation of the term "ring buffer".
I guess it could be understood as a buffer filled with some audio data where the audio callback reads from and when it reaches the end, it starts from the beginning.
That's not exactly what the PortAudio ring buffer (and therefore the rtmixer.RingBuffer) is.
You should rather think of it as a FIFO (first in, first out) queue that's used for sending data from one thread to another. Only one thread is allowed to write into the queue and one thread is allowed to read from it. The fact that internally a ring buffer is used is more of an implementation detail and not really relevant for its usage.
The idea of play_ringbuffer() is that the user provides a ring buffer (= a queue) and the audio callback will read (and play back) whatever is in the queue. It's the responsibility of the user to write data into the queue quickly enough so that it doesn't run dry.
Therefore, I don't think it makes sense to have a "loop" mode when playing from a "queue". The user is responsible for filling the queue, so if they want a loop, they have to provide the same audio data over and over again, for however long they want.
OTOH, the play_buffer() method could get a "loop" mode, where it would just start playing from the beginning of the buffer whenever it reaches the end. But this is not implemented yet.