On Thursday 17 Jun 2004 7:08 pm, Mario Lang wrote:
I think for this to work, I'd need some
prebuffering in between, and the audio thread somehow singaling to
the decoder thread when the buffer is too empty to safely continue
sleeping so that the decoder can start to fill more data into the
buffer.
One way to do this is to use pthread conditions. Have a ring buffer
between your decoder and RT threads, with the decoder sleeping for
short periods of time between reads using pthread_cond_timedwait or
similar. This causes the thread to sleep until a certain time has
elapsed or a condition has been signalled. You can then signal from
the RT thread using pthread_cond_signal to wake up the decoder thread
each time something is read from the ring buffer.
This is pretty much what we're doing in Rosegarden 0.9.8, but now that
I describe it, I realise I don't know for absolutely sure whether
pthread_cond_signal is itself RT-safe. More information or better
alternatives are welcome.
Chris