[pulseaudio-discuss] source-sink loopback

Lennart Poettering lennart at poettering.net
Thu Aug 20 16:14:52 PDT 2009


On Wed, 19.08.09 23:57, pl bossart (bossart.nospam at gmail.com) wrote:

> 
> Thanks Lennart for your comments.
> 
> > pa_memchunk is a structure that is just a short way to store a pointer
> > plus and index and a size. You can allocate it on the stack or
> > wherever you want, but it's your job to allocate it, and how you do it
> > is up to you. Seldomly you'd malloc() it explcitly however. More
> > likely it is simply a part of some other struct or on the stack. It is
> > not ref counted or anything. It's just a quicker way of passing around
> > this triplet of data.
> >
> > That means that the create_memchunk() code is really not
> > necessary. You don't need to explicitly allocate a memblock into
> > it. As soon as you have a memchunk from the source just copy that
> > struct verbatim and you are fine.
> 
> Got it. This is really due to the way I developed the code. I started
> from module-sine and realized that the length of the chunk defined the
> pop() timing. I really wanted to have push and pop fire at the same
> time to understand PA timing internals and minimize the need for
> queuing. For the push(), the timing depends on the source latency but
> for the pop() this depends on the chunk size, not on the sink latency.
> However when I connected the two with the memblockq, I did not realize
> that the memblock allocation done in create_memchunk() became useless.
> Even worse the code in pa_memblockq_peek() removes the link to this
> initial memblock. I guess it must be reclaimed since it's not
> referenced by anyone...

memblocks which are not unreffed explicitly are leaked. We don't have
garbage collection (whcih is not really an option in RT
processes). You need to be careful to unref everything you allocated
or got a ref for.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list