[pulseaudio-discuss] source-sink loopback

Lennart Poettering lennart at poettering.net
Wed Aug 19 17:18:24 PDT 2009


On Tue, 18.08.09 10:42, pl bossart (bossart.nospam at gmail.com) wrote:

> Here the module-loopback code, turns out we can contribute freely to
> PulseAudio. Comments welcome.

Nice!

One comment:

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.

If you want to initialize a pa_memchunk then you can do so with
pa_memchunk_reset() which just sets all thre fields to NULL, i.e. does
about the same thing as pa_zero() (i.e. memset()). But mos of the time
you don't even need to do that.

You could compare the use of "memchunk" a bit with "extents" in file
system speak. 

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