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: Jesse Chappell (jesse_AT_essej.net)
Date: Thu Jun 17 2004 - 22:24:43 EEST


Chris Cannam wrote on Thu, 17-Jun-2004:

> 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.
 
If you are using pthread_mutex_trylock() to lock the condition's
mutex in the RT thread, then you are ok. If you can't aqcuire
the lock (hence can't signal) that is usually OK because the other
thread is already doing work anyway.

jlc


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:20:07 EEST