Re: [linux-audio-dev] Multithreaded programming for a poll model?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Multithreaded programming for a poll model?
From: Chris Cannam (cannam_AT_all-day-breakfast.com)
Date: Thu Jun 17 2004 - 22:26:51 EEST


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


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Thu Jun 17 2004 - 22:02:59 EEST